2016-11-10 22:10:53 -08:00
|
|
|
#!/usr/bin/env bash
|
2015-11-24 11:23:36 -08:00
|
|
|
|
2016-04-18 11:15:34 -07:00
|
|
|
set -eu -o pipefail
|
|
|
|
|
2017-10-28 17:10:09 -07:00
|
|
|
function cmd_pref() {
|
|
|
|
if type -p "$2" > /dev/null; then
|
|
|
|
eval "$1=$2"
|
|
|
|
else
|
|
|
|
eval "$1=$3"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# If a g-prefixed version of the command exists, use it preferentially.
|
|
|
|
function gprefix() {
|
|
|
|
cmd_pref "$1" "g$2" "$2"
|
|
|
|
}
|
|
|
|
|
|
|
|
gprefix READLINK readlink
|
2017-10-29 05:22:55 -07:00
|
|
|
cd "$(dirname "$("$READLINK" -f "$0")")/.."
|
2017-10-28 17:10:09 -07:00
|
|
|
|
2016-11-10 22:10:53 -08:00
|
|
|
# Allow user overrides to $MAKE. Typical usage for users who need it:
|
|
|
|
# MAKE=gmake ./zcutil/build.sh -j$(nproc)
|
|
|
|
if [[ -z "${MAKE-}" ]]; then
|
|
|
|
MAKE=make
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Allow overrides to $BUILD and $HOST for porters. Most users will not need it.
|
|
|
|
# BUILD=i686-pc-linux-gnu ./zcutil/build.sh
|
|
|
|
if [[ -z "${BUILD-}" ]]; then
|
2017-10-29 05:22:55 -07:00
|
|
|
BUILD="$(./depends/config.guess)"
|
2016-11-10 22:10:53 -08:00
|
|
|
fi
|
|
|
|
if [[ -z "${HOST-}" ]]; then
|
2017-10-29 05:22:55 -07:00
|
|
|
HOST="$BUILD"
|
2016-11-10 22:10:53 -08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Allow override to $CC and $CXX for porters. Most users will not need it.
|
|
|
|
if [[ -z "${CC-}" ]]; then
|
|
|
|
CC=gcc
|
|
|
|
fi
|
|
|
|
if [[ -z "${CXX-}" ]]; then
|
|
|
|
CXX=g++
|
|
|
|
fi
|
|
|
|
|
2018-07-06 04:33:24 -07:00
|
|
|
# Allow users to set arbitrary compile flags. Most users will not need this.
|
2017-03-09 18:39:18 -08:00
|
|
|
if [[ -z "${CONFIGURE_FLAGS-}" ]]; then
|
|
|
|
CONFIGURE_FLAGS=""
|
|
|
|
fi
|
|
|
|
|
2016-04-18 11:15:34 -07:00
|
|
|
if [ "x$*" = 'x--help' ]
|
|
|
|
then
|
|
|
|
cat <<EOF
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
$0 --help
|
|
|
|
Show this help message and exit.
|
|
|
|
|
2018-03-28 08:55:45 -07:00
|
|
|
$0 [ --enable-lcov || --disable-tests ] [ --disable-mining ] [ --enable-proton ] [ --disable-libs ] [ MAKEARGS... ]
|
2016-04-18 11:15:34 -07:00
|
|
|
Build Zcash and most of its transitive dependencies from
|
2016-11-06 12:35:55 -08:00
|
|
|
source. MAKEARGS are applied to both dependencies and Zcash itself.
|
|
|
|
|
|
|
|
If --enable-lcov is passed, Zcash is configured to add coverage
|
2016-04-18 11:15:34 -07:00
|
|
|
instrumentation, thus enabling "make cov" to work.
|
2016-11-06 12:35:55 -08:00
|
|
|
If --disable-tests is passed instead, the Zcash tests are not built.
|
2016-11-06 11:40:34 -08:00
|
|
|
|
|
|
|
If --disable-mining is passed, Zcash is configured to not build any mining
|
|
|
|
code. It must be passed after the test arguments, if present.
|
2017-03-18 05:47:24 -07:00
|
|
|
|
2017-05-10 08:54:58 -07:00
|
|
|
If --enable-proton is passed, Zcash is configured to build the Apache Qpid Proton
|
|
|
|
library required for AMQP support. This library is not built by default.
|
2018-03-28 08:55:45 -07:00
|
|
|
It must be passed after the test/mining arguments, if present.
|
2016-04-18 11:15:34 -07:00
|
|
|
EOF
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -x
|
2015-11-24 11:23:36 -08:00
|
|
|
|
2016-04-18 11:15:34 -07:00
|
|
|
# If --enable-lcov is the first argument, enable lcov coverage support:
|
|
|
|
LCOV_ARG=''
|
2016-08-11 14:15:50 -07:00
|
|
|
HARDENING_ARG='--enable-hardening'
|
2016-11-06 12:35:55 -08:00
|
|
|
TEST_ARG=''
|
2016-04-18 11:15:34 -07:00
|
|
|
if [ "x${1:-}" = 'x--enable-lcov' ]
|
|
|
|
then
|
|
|
|
LCOV_ARG='--enable-lcov'
|
2016-08-11 14:15:50 -07:00
|
|
|
HARDENING_ARG='--disable-hardening'
|
2016-04-18 11:15:34 -07:00
|
|
|
shift
|
2016-11-06 12:35:55 -08:00
|
|
|
elif [ "x${1:-}" = 'x--disable-tests' ]
|
|
|
|
then
|
|
|
|
TEST_ARG='--enable-tests=no'
|
|
|
|
shift
|
2016-04-18 11:15:34 -07:00
|
|
|
fi
|
|
|
|
|
2016-11-06 11:40:34 -08:00
|
|
|
# If --disable-mining is the next argument, disable mining code:
|
|
|
|
MINING_ARG=''
|
|
|
|
if [ "x${1:-}" = 'x--disable-mining' ]
|
|
|
|
then
|
|
|
|
MINING_ARG='--enable-mining=no'
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
2017-05-10 08:54:58 -07:00
|
|
|
# If --enable-proton is the next argument, enable building Proton code:
|
|
|
|
PROTON_ARG='--enable-proton=no'
|
|
|
|
if [ "x${1:-}" = 'x--enable-proton' ]
|
2017-03-25 09:03:22 -07:00
|
|
|
then
|
2017-05-10 08:54:58 -07:00
|
|
|
PROTON_ARG=''
|
2017-03-25 09:03:22 -07:00
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
2018-04-13 21:08:18 -07:00
|
|
|
PREFIX="$(pwd)/depends/$HOST/"
|
2015-11-24 11:23:36 -08:00
|
|
|
|
2017-05-11 22:02:00 -07:00
|
|
|
eval "$MAKE" --version
|
|
|
|
eval "$CC" --version
|
|
|
|
eval "$CXX" --version
|
|
|
|
as --version
|
2017-05-31 00:38:02 -07:00
|
|
|
ld -v
|
2017-05-11 22:02:00 -07:00
|
|
|
|
2018-03-28 08:55:45 -07:00
|
|
|
HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1
|
2015-11-24 11:23:36 -08:00
|
|
|
./autogen.sh
|
2018-04-06 07:09:50 -07:00
|
|
|
CC="$CC" CXX="$CXX" ./configure --prefix="${PREFIX}" --host="$HOST" --build="$BUILD" "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS --enable-werror CXXFLAGS='-g'
|
2016-11-10 22:10:53 -08:00
|
|
|
"$MAKE" "$@" V=1
|