]> Git Repo - VerusCoin.git/blob - zcutil/build.sh
Merge remote-tracking branch 'mike/dev' into dev
[VerusCoin.git] / zcutil / build.sh
1 #!/usr/bin/env bash
2
3 set -eu -o pipefail
4
5 function cmd_pref() {
6     if type -p "$2" > /dev/null; then
7         eval "$1=$2"
8     else
9         eval "$1=$3"
10     fi
11 }
12
13 # If a g-prefixed version of the command exists, use it preferentially.
14 function gprefix() {
15     cmd_pref "$1" "g$2" "$2"
16 }
17
18 gprefix READLINK readlink
19 cd "$(dirname "$("$READLINK" -f "$0")")/.."
20
21 # Allow user overrides to $MAKE. Typical usage for users who need it:
22 #   MAKE=gmake ./zcutil/build.sh -j$(nproc)
23 if [[ -z "${MAKE-}" ]]; then
24     MAKE=make
25 fi
26
27 # Allow overrides to $BUILD and $HOST for porters. Most users will not need it.
28 #   BUILD=i686-pc-linux-gnu ./zcutil/build.sh
29 if [[ -z "${BUILD-}" ]]; then
30     BUILD="$(./depends/config.guess)"
31 fi
32 if [[ -z "${HOST-}" ]]; then
33     HOST="$BUILD"
34 fi
35
36 # Allow users to set arbitrary compile flags. Most users will not need this.
37 if [[ -z "${CONFIGURE_FLAGS-}" ]]; then
38     CONFIGURE_FLAGS=""
39 fi
40
41 if [ "x$*" = 'x--help' ]
42 then
43     cat <<EOF
44 Usage:
45
46 $0 --help
47   Show this help message and exit.
48
49 $0 [ --enable-lcov || --disable-tests ] [ --disable-mining ] [ --enable-proton ] [ MAKEARGS... ]
50   Build Zcash and most of its transitive dependencies from
51   source. MAKEARGS are applied to both dependencies and Zcash itself.
52
53   If --enable-lcov is passed, Zcash is configured to add coverage
54   instrumentation, thus enabling "make cov" to work.
55   If --disable-tests is passed instead, the Zcash tests are not built.
56
57   If --disable-mining is passed, Zcash is configured to not build any mining
58   code. It must be passed after the test arguments, if present.
59
60   If --enable-proton is passed, Zcash is configured to build the Apache Qpid Proton
61   library required for AMQP support. This library is not built by default.
62   It must be passed after the test/mining arguments, if present.
63 EOF
64     exit 0
65 fi
66
67 set -x
68
69 # If --enable-lcov is the first argument, enable lcov coverage support:
70 LCOV_ARG=''
71 HARDENING_ARG='--enable-hardening'
72 TEST_ARG=''
73 if [ "x${1:-}" = 'x--enable-lcov' ]
74 then
75     LCOV_ARG='--enable-lcov'
76     HARDENING_ARG='--disable-hardening'
77     shift
78 elif [ "x${1:-}" = 'x--disable-tests' ]
79 then
80     TEST_ARG='--enable-tests=no'
81     shift
82 fi
83
84 # If --disable-mining is the next argument, disable mining code:
85 MINING_ARG=''
86 if [ "x${1:-}" = 'x--disable-mining' ]
87 then
88     MINING_ARG='--enable-mining=no'
89     shift
90 fi
91
92 # If --enable-proton is the next argument, enable building Proton code:
93 PROTON_ARG='--enable-proton=no'
94 if [ "x${1:-}" = 'x--enable-proton' ]
95 then
96     PROTON_ARG=''
97     shift
98 fi
99
100 eval "$MAKE" --version
101 as --version
102 ld -v
103
104 HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1
105 ./autogen.sh
106
107 # 0x03 2020-01-03, do not use '-Wno-builtin-declaration-mismatch or -Werror on GCC <v8
108 if [ "$(gcc --version|head -1 | awk '{print $4}' | cut -d"." -f1)" -lt 8 ]; then
109         # version <8
110         CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CPPFLAGS='-g' CXXFLAGS='-g'
111 else
112         # version 8 and up
113         CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CPPFLAGS='-g -Wno-builtin-declaration-mismatch -Werror' CXXFLAGS='-g'
114 fi
115 "$MAKE" "$@" V=1
This page took 0.033257 seconds and 4 git commands to generate.