]> Git Repo - VerusCoin.git/blame - configure.ac
Merge branch 'dev' into jl777
[VerusCoin.git] / configure.ac
CommitLineData
35b8af92
CF
1dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
2AC_PREREQ([2.60])
f11099e2
SB
3define(_CLIENT_VERSION_MAJOR, 1)
4define(_CLIENT_VERSION_MINOR, 0)
1dd95be4 5define(_CLIENT_VERSION_REVISION, 15)
998202ba 6define(_CLIENT_VERSION_BUILD, 50)
6fe11af7
JG
7define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50)))
8define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1)))
998202ba 9define(_CLIENT_VERSION_IS_RELEASE, true)
e466df93 10define(_COPYRIGHT_YEAR, 2017)
6fe11af7 11AC_INIT([Zcash],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_SUFFIX(_ZC_BUILD_VAL)],[https://github.com/zcash/zcash/issues],[zcash])
e5438111 12AC_CONFIG_SRCDIR([src/main.cpp])
13AC_CONFIG_HEADERS([src/config/bitcoin-config.h])
52a5f903 14AC_CONFIG_AUX_DIR([build-aux])
15AC_CONFIG_MACRO_DIR([build-aux/m4])
1723862e 16
c5d645e2
CF
17BITCOIN_DAEMON_NAME=zcashd
18BITCOIN_CLI_NAME=zcash-cli
19BITCOIN_TX_NAME=zcash-tx
20
bc9fff11
RN
21dnl Unless the user specified ARFLAGS, force it to be cr
22AC_ARG_VAR(ARFLAGS, [Flags for the archiver, defaults to <cr> if not set])
23if test "x${ARFLAGS+set}" != "xset"; then
24 ARFLAGS="cr"
25fi
26
35b8af92 27AC_CANONICAL_HOST
1723862e 28
35b8af92
CF
29AH_TOP([#ifndef BITCOIN_CONFIG_H])
30AH_TOP([#define BITCOIN_CONFIG_H])
31AH_BOTTOM([#endif //BITCOIN_CONFIG_H])
32
35b8af92
CF
33dnl faketime breaks configure and is only needed for make. Disable it here.
34unset FAKETIME
35
eefb766c 36dnl Automake init set-up and checks
051698a0 37AM_INIT_AUTOMAKE([no-define subdir-objects foreign tar-pax])
35b8af92
CF
38
39dnl faketime messes with timestamps and causes configure to be re-run.
40dnl --disable-maintainer-mode can be used to bypass this.
41AM_MAINTAINER_MODE([enable])
42
43dnl make the compilation flags quiet unless V=1 is used
44m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
45
eefb766c 46dnl Compiler checks (here before libtool).
47if test "x${CXXFLAGS+set}" = "xset"; then
48 CXXFLAGS_overridden=yes
49else
50 CXXFLAGS_overridden=no
51fi
c4da0970 52
52a5f903 53AC_PROG_CXX
52a5f903 54m4_ifdef([AC_PROG_OBJCXX],[AC_PROG_OBJCXX])
eefb766c 55
56dnl By default, libtool for mingw refuses to link static libs into a dll for
57dnl fear of mixing pic/non-pic objects, and import/export complications. Since
58dnl we have those under control, re-enable that functionality.
59case $host in
60 *mingw*)
61 lt_cv_deplibs_check_method="pass_all"
62 ;;
63esac
4ba17236 64dnl Require C++11 compiler (no GNU extensions)
943f19fe 65AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory], [nodefault])
d812d95a
AT
66dnl Check if -latomic is required for <std::atomic>
67CHECK_ATOMIC
68
eefb766c 69dnl Libtool init checks.
19df238a 70LT_INIT([pic-only])
eefb766c 71
72dnl Check/return PATH for base programs.
52a5f903 73AC_PATH_TOOL(AR, ar)
74AC_PATH_TOOL(RANLIB, ranlib)
75AC_PATH_TOOL(STRIP, strip)
76AC_PATH_TOOL(GCOV, gcov)
77AC_PATH_PROG(LCOV, lcov)
52a5f903 78AC_PATH_PROG(GENHTML, genhtml)
79AC_PATH_PROG([GIT], [git])
80AC_PATH_PROG(CCACHE,ccache)
81AC_PATH_PROG(XGETTEXT,xgettext)
82AC_PATH_PROG(HEXDUMP,hexdump)
56734f4b
TH
83AC_PATH_TOOL(READELF,readelf)
84AC_PATH_TOOL(CPPFILT,c++filt)
eefb766c 85
4f9e993b
WL
86# Enable wallet
87AC_ARG_ENABLE([wallet],
88 [AS_HELP_STRING([--enable-wallet],
89 [enable wallet (default is yes)])],
90 [enable_wallet=$enableval],
91 [enable_wallet=yes])
92
2cc0a252
JG
93AC_ARG_ENABLE([mining],
94 [AS_HELP_STRING([--enable-mining],
95 [enable mining (default is yes)])],
96 [enable_mining=$enableval],
97 [enable_mining=yes])
98
802ea76b
SB
99AC_ARG_ENABLE([rust],
100 [AS_HELP_STRING([--enable-rust],
101 [enable rust (default is yes)])],
102 [enable_rust=$enableval],
103 [enable_rust=yes])
104
99eb947a
S
105AC_ARG_ENABLE([proton],
106 [AS_HELP_STRING([--disable-proton],
107 [disable Proton (AMQP messaging)])],
108 [use_proton=$enableval],
109 [use_proton=yes])
35b8af92 110
35b8af92
CF
111AC_ARG_ENABLE(tests,
112 AS_HELP_STRING([--enable-tests],[compile tests (default is yes)]),
113 [use_tests=$enableval],
114 [use_tests=yes])
115
c4379e3a
JG
116AC_ARG_ENABLE([asan],
117 [AS_HELP_STRING([--enable-asan],
118 [instrument the executables with asan (default is no)])],
119 [use_asan=$enableval],
120 [use_asan=no])
35b8af92 121
c4379e3a
JG
122AC_ARG_ENABLE([tsan],
123 [AS_HELP_STRING([--enable-tsan],
124 [instrument the executables with tsan (default is no)])],
125 [use_tsan=$enableval],
126 [use_tsan=no])
47b9374e 127
9d365796 128if test x$TARGET_OS = xdarwin; then
35b8af92
CF
129AC_ARG_ENABLE([hardening],
130 [AS_HELP_STRING([--enable-hardening],
131 [attempt to harden the resulting executables (default is yes)])],
132 [use_hardening=$enableval],
e891d64b 133 [use_hardening=no])
9d365796 134else
135AC_ARG_ENABLE([hardening],
136 [AS_HELP_STRING([--enable-hardening],
137 [attempt to harden the resulting executables (default is yes)])],
138 [use_hardening=$enableval],
139 [use_hardening=yes])
140fi
141
e432a5f0
CF
142AC_ARG_ENABLE([reduce-exports],
143 [AS_HELP_STRING([--enable-reduce-exports],
3ee028f1 144 [attempt to reduce exported symbols in the resulting executables (default is no)])],
e432a5f0 145 [use_reduce_exports=$enableval],
3ee028f1 146 [use_reduce_exports=no])
e432a5f0 147
35b8af92
CF
148AC_ARG_ENABLE([ccache],
149 [AS_HELP_STRING([--enable-ccache],
e18e1001 150 [use ccache for building (default is yes if ccache is found)])],
35b8af92
CF
151 [use_ccache=$enableval],
152 [use_ccache=auto])
153
154AC_ARG_ENABLE([lcov],
155 [AS_HELP_STRING([--enable-lcov],
156 [enable lcov testing (default is no)])],
157 [use_lcov=yes],
158 [use_lcov=no])
159
d5aab704
CF
160AC_ARG_ENABLE([glibc-back-compat],
161 [AS_HELP_STRING([--enable-glibc-back-compat],
aa367306 162 [enable backwards compatibility with glibc])],
d5aab704
CF
163 [use_glibc_compat=$enableval],
164 [use_glibc_compat=no])
165
f200002c 166AC_ARG_ENABLE([zmq],
1afb8431 167 [AS_HELP_STRING([--disable-zmq],
168 [disable ZMQ notifications])],
f200002c
JG
169 [use_zmq=$enableval],
170 [use_zmq=yes])
171
35b8af92
CF
172AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], [])
173
abfcaefe 174AC_ARG_ENABLE(man,
1b5e712c 175 [AS_HELP_STRING([--disable-man],
176 [do not install man pages (default is to install)])],,
abfcaefe 177 enable_man=yes)
178AM_CONDITIONAL(ENABLE_MAN, test "$enable_man" != no)
179
b197605e 180# Enable debug
f5f157b8 181AC_ARG_ENABLE([debug],
182 [AS_HELP_STRING([--enable-debug],
183 [use debug compiler flags and macros (default is no)])],
184 [enable_debug=$enableval],
185 [enable_debug=no])
186
5dd887fd
CF
187# Turn warnings into errors
188AC_ARG_ENABLE([werror],
189 [AS_HELP_STRING([--enable-werror],
c1fcdd01 190 [Treat all compiler warnings as errors (default is no)])],
5dd887fd
CF
191 [enable_werror=$enableval],
192 [enable_werror=no])
193
341ab745
CF
194AC_LANG_PUSH([C++])
195AX_CHECK_COMPILE_FLAG([-Werror],[CXXFLAG_WERROR="-Werror"],[CXXFLAG_WERROR=""])
196
f5f157b8 197if test "x$enable_debug" = xyes; then
ae1565b5 198 CPPFLAGS="$CPPFLAGS -DDEBUG -DDEBUG_LOCKORDER"
f5f157b8 199 if test "x$GCC" = xyes; then
ae1565b5 200 CFLAGS="$CFLAGS -g3 -O0"
f5f157b8 201 fi
b197605e 202
f5f157b8 203 if test "x$GXX" = xyes; then
ae1565b5 204 CXXFLAGS="$CXXFLAGS -g3 -O0"
f5f157b8 205 fi
b197605e 206fi
f5f157b8 207
5dd887fd
CF
208ERROR_CXXFLAGS=
209if test "x$enable_werror" = "xyes"; then
210 if test "x$CXXFLAG_WERROR" = "x"; then
211 AC_MSG_ERROR("enable-werror set but -Werror is not usable")
212 fi
c1fcdd01 213 ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror"
5dd887fd
CF
214fi
215
123e4f87 216if test "x$CXXFLAGS_overridden" = "xno"; then
341ab745
CF
217 AX_CHECK_COMPILE_FLAG([-Wall],[CXXFLAGS="$CXXFLAGS -Wall"],,[[$CXXFLAG_WERROR]])
218 AX_CHECK_COMPILE_FLAG([-Wextra],[CXXFLAGS="$CXXFLAGS -Wextra"],,[[$CXXFLAG_WERROR]])
219 AX_CHECK_COMPILE_FLAG([-Wformat],[CXXFLAGS="$CXXFLAGS -Wformat"],,[[$CXXFLAG_WERROR]])
d35ebc7b 220 AX_CHECK_COMPILE_FLAG([-Wvla],[CXXFLAGS="$CXXFLAGS -Wvla"],,[[$CXXFLAG_WERROR]])
341ab745
CF
221 AX_CHECK_COMPILE_FLAG([-Wformat-security],[CXXFLAGS="$CXXFLAGS -Wformat-security"],,[[$CXXFLAG_WERROR]])
222
223 ## Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
224 ## unknown options if any other warning is produced. Test the -Wfoo case, and
225 ## set the -Wno-foo case if it works.
226 AX_CHECK_COMPILE_FLAG([-Wunused-parameter],[CXXFLAGS="$CXXFLAGS -Wno-unused-parameter"],,[[$CXXFLAG_WERROR]])
227 AX_CHECK_COMPILE_FLAG([-Wself-assign],[CXXFLAGS="$CXXFLAGS -Wno-self-assign"],,[[$CXXFLAG_WERROR]])
228 AX_CHECK_COMPILE_FLAG([-Wunused-local-typedef],[CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"],,[[$CXXFLAG_WERROR]])
229 AX_CHECK_COMPILE_FLAG([-Wdeprecated-register],[CXXFLAGS="$CXXFLAGS -Wno-deprecated-register"],,[[$CXXFLAG_WERROR]])
123e4f87 230fi
55fca515 231CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
35b8af92 232
b7a4ecc1
LD
233AC_ARG_WITH([utils],
234 [AS_HELP_STRING([--with-utils],
8b78a819 235 [build zcash-cli zcash-tx wallet-utility (default=yes)])],
b7a4ecc1
LD
236 [build_bitcoin_utils=$withval],
237 [build_bitcoin_utils=yes])
238
239AC_ARG_WITH([libs],
240 [AS_HELP_STRING([--with-libs],
241 [build libraries (default=yes)])],
242 [build_bitcoin_libs=$withval],
243 [build_bitcoin_libs=yes])
244
245AC_ARG_WITH([daemon],
246 [AS_HELP_STRING([--with-daemon],
247 [build bitcoind daemon (default=yes)])],
248 [build_bitcoind=$withval],
249 [build_bitcoind=yes])
250
35b8af92
CF
251use_pkgconfig=yes
252case $host in
253 *mingw*)
254
96b9603c 255 #pkgconfig does more harm than good with MinGW
35b8af92
CF
256 use_pkgconfig=no
257
258 TARGET_OS=windows
259 AC_CHECK_LIB([mingwthrd], [main],, AC_MSG_ERROR(lib missing))
260 AC_CHECK_LIB([kernel32], [main],, AC_MSG_ERROR(lib missing))
261 AC_CHECK_LIB([user32], [main],, AC_MSG_ERROR(lib missing))
262 AC_CHECK_LIB([gdi32], [main],, AC_MSG_ERROR(lib missing))
263 AC_CHECK_LIB([comdlg32], [main],, AC_MSG_ERROR(lib missing))
264 AC_CHECK_LIB([winspool], [main],, AC_MSG_ERROR(lib missing))
265 AC_CHECK_LIB([winmm], [main],, AC_MSG_ERROR(lib missing))
266 AC_CHECK_LIB([shell32], [main],, AC_MSG_ERROR(lib missing))
267 AC_CHECK_LIB([comctl32], [main],, AC_MSG_ERROR(lib missing))
268 AC_CHECK_LIB([ole32], [main],, AC_MSG_ERROR(lib missing))
269 AC_CHECK_LIB([oleaut32], [main],, AC_MSG_ERROR(lib missing))
270 AC_CHECK_LIB([uuid], [main],, AC_MSG_ERROR(lib missing))
271 AC_CHECK_LIB([rpcrt4], [main],, AC_MSG_ERROR(lib missing))
272 AC_CHECK_LIB([advapi32], [main],, AC_MSG_ERROR(lib missing))
273 AC_CHECK_LIB([ws2_32], [main],, AC_MSG_ERROR(lib missing))
274 AC_CHECK_LIB([mswsock], [main],, AC_MSG_ERROR(lib missing))
275 AC_CHECK_LIB([shlwapi], [main],, AC_MSG_ERROR(lib missing))
276 AC_CHECK_LIB([iphlpapi], [main],, AC_MSG_ERROR(lib missing))
c589f5f2
CF
277 AC_CHECK_LIB([crypt32], [main],, AC_MSG_ERROR(lib missing))
278
575e70c0
CF
279 # -static is interpreted by libtool, where it has a different meaning.
280 # In libtool-speak, it's -all-static.
e0077de5 281 AX_CHECK_LINK_FLAG([[-static]],[LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static"])
575e70c0 282
35b8af92
CF
283 AC_PATH_PROG([MAKENSIS], [makensis], none)
284 if test x$MAKENSIS = xnone; then
285 AC_MSG_WARN("makensis not found. Cannot create installer.")
286 fi
287
5ceb9c96
CF
288 AC_PATH_TOOL(WINDRES, windres, none)
289 if test x$WINDRES = xnone; then
290 AC_MSG_ERROR("windres not found")
291 fi
292
b77dfdc9 293 CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB"
35b8af92 294 LEVELDB_TARGET_FLAGS="TARGET_OS=OS_WINDOWS_CROSSCOMPILE"
123e4f87
LD
295 if test "x$CXXFLAGS_overridden" = "xno"; then
296 CXXFLAGS="$CXXFLAGS -w"
297 fi
2f87b38e
WL
298 case $host in
299 i?86-*) WINDOWS_BITS=32 ;;
300 x86_64-*) WINDOWS_BITS=64 ;;
301 *) AC_MSG_ERROR("Could not determine win32/win64 for installer") ;;
302 esac
303 AC_SUBST(WINDOWS_BITS)
9ed8979e
CF
304
305 dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against.
306 dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override
307 dnl its command here, with the predeps/postdeps removed, and -static inserted. Postdeps are
308 dnl also overridden to prevent their insertion later.
309 dnl This should only affect dll's.
310 archive_cmds_CXX="\$CC -shared \$libobjs \$deplibs \$compiler_flags -static -o \$output_objdir/\$soname \${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib"
311 postdeps_CXX=
312
35b8af92
CF
313 ;;
314 *darwin*)
315 TARGET_OS=darwin
316 LEVELDB_TARGET_FLAGS="TARGET_OS=Darwin"
317 if test x$cross_compiling != xyes; then
b62bbb1f 318 BUILD_OS=darwin
35b8af92
CF
319 AC_CHECK_PROG([PORT],port, port)
320 if test x$PORT = xport; then
321 dnl add default macports paths
4c69ebed
PJ
322 CPPFLAGS="$CPPFLAGS -isystem /opt/local/include"
323 LIBS="$LIBS -L/opt/local/lib"
9cb7abaf
DH
324 if test -d /opt/local/include/db62; then
325 CPPFLAGS="$CPPFLAGS -I/opt/local/include/db62"
326 LIBS="$LIBS -L/opt/local/lib/db62"
4c69ebed 327 fi
35b8af92
CF
328 fi
329
e891d64b
JB
330dnl AC_CHECK_PROG([BREW],brew, brew)
331dnl if test x$BREW = xbrew; then
9d365796 332 dnl These Homebrew packages may be keg-only, meaning that they won't be found
333 dnl in expected paths because they may conflict with system files. Ask
334 dnl Homebrew where each one is located, then adjust paths accordingly.
335 dnl It's safe to add these paths even if the functionality is disabled by
336 dnl the user (--without-wallet for example).
9fedafba 337
e891d64b
JB
338dnl openssl_prefix=`$BREW --prefix openssl 2>/dev/null`
339dnl bdb_prefix=`$BREW --prefix berkeley-db4 2>/dev/null`
340dnl qt5_prefix=`$BREW --prefix qt5 2>/dev/null`
341dnl if test x$openssl_prefix != x; then
342dnl PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
343dnl export PKG_CONFIG_PATH
344dnl fi
345dnl if test x$bdb_prefix != x; then
346dnl CPPFLAGS="$CPPFLAGS -I$bdb_prefix/include"
347dnl LIBS="$LIBS -L$bdb_prefix/lib"
348dnl fi
349dnl if test x$qt5_prefix != x; then
350dnl PKG_CONFIG_PATH="$qt5_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
351dnl export PKG_CONFIG_PATH
352dnl fi
353dnl fi
b62bbb1f
CF
354 else
355 case $build_os in
356 *darwin*)
357 BUILD_OS=darwin
358 ;;
359 *)
360 AC_PATH_TOOL([INSTALLNAMETOOL], [install_name_tool], install_name_tool)
361 AC_PATH_TOOL([OTOOL], [otool], otool)
362 AC_PATH_PROGS([GENISOIMAGE], [genisoimage mkisofs],genisoimage)
b7f2cdc8
CF
363
364 dnl libtool will try to strip the static lib, which is a problem for
365 dnl cross-builds because strip attempts to call a hard-coded ld,
366 dnl which may not exist in the path. Stripping the .a is not
367 dnl necessary, so just disable it.
368 old_striplib=
b62bbb1f
CF
369 ;;
370 esac
35b8af92
CF
371 fi
372
9eb5a5fb 373 AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"])
35b8af92 374 CPPFLAGS="$CPPFLAGS -DMAC_OSX"
c459de2f 375 OBJCXXFLAGS="$CXXFLAGS"
35b8af92 376 ;;
ab123ad4
CF
377 *linux*)
378 TARGET_OS=linux
379 ;;
35b8af92 380 *)
35b8af92
CF
381 ;;
382esac
383
d7002714
CF
384if test x$use_pkgconfig = xyes; then
385 m4_ifndef([PKG_PROG_PKG_CONFIG], [AC_MSG_ERROR(PKG_PROG_PKG_CONFIG macro not found. Please install pkg-config and re-run autogen.sh.)])
386 m4_ifdef([PKG_PROG_PKG_CONFIG], [
387 PKG_PROG_PKG_CONFIG
388 if test x"$PKG_CONFIG" = "x"; then
389 AC_MSG_ERROR(pkg-config not found.)
47b9374e 390 fi
d7002714 391 ])
47b9374e
MC
392fi
393
b77b4eda
LD
394if test x$use_lcov = xyes; then
395 if test x$LCOV = x; then
35b8af92
CF
396 AC_MSG_ERROR("lcov testing requested but lcov not found")
397 fi
b77b4eda 398 if test x$GCOV = x; then
35b8af92
CF
399 AC_MSG_ERROR("lcov testing requested but gcov not found")
400 fi
b77b4eda 401 if test x$GENHTML = x; then
35b8af92
CF
402 AC_MSG_ERROR("lcov testing requested but genhtml not found")
403 fi
6ecb05dd
JG
404 LCOV="$LCOV --gcov-tool=$GCOV --rc lcov_branch_coverage=1"
405 GENHTML="$GENHTML --branch-coverage"
35b8af92
CF
406 AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"],
407 [AC_MSG_ERROR("lcov testing requested but --coverage flag does not work")])
408fi
409
4414f5ff
WL
410dnl Check for endianness
411AC_C_BIGENDIAN
35b8af92
CF
412
413dnl Check for pthread compile/link requirements
414AX_PTHREAD
35b8af92
CF
415
416# The following macro will add the necessary defines to bitcoin-config.h, but
417# they also need to be passed down to any subprojects. Pull the results out of
418# the cache and add them to CPPFLAGS.
419AC_SYS_LARGEFILE
a60838d0
WL
420# detect POSIX or GNU variant of strerror_r
421AC_FUNC_STRERROR_R
35b8af92
CF
422
423if test x$ac_cv_sys_file_offset_bits != x &&
424 test x$ac_cv_sys_file_offset_bits != xno &&
425 test x$ac_cv_sys_file_offset_bits != xunknown; then
426 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
427fi
428
429if test x$ac_cv_sys_large_files != x &&
430 test x$ac_cv_sys_large_files != xno &&
431 test x$ac_cv_sys_large_files != xunknown; then
432 CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files"
433fi
434
435AX_CHECK_LINK_FLAG([[-Wl,--large-address-aware]], [LDFLAGS="$LDFLAGS -Wl,--large-address-aware"])
436
f36a40f7
CF
437AX_GCC_FUNC_ATTRIBUTE([visibility])
438AX_GCC_FUNC_ATTRIBUTE([dllexport])
439AX_GCC_FUNC_ATTRIBUTE([dllimport])
440
d5aab704
CF
441if test x$use_glibc_compat != xno; then
442
d68e2111
CF
443 #glibc absorbed clock_gettime in 2.17. librt (its previous location) is safe to link
444 #in anyway for back-compat.
445 AC_CHECK_LIB([rt],[clock_gettime],, AC_MSG_ERROR(lib missing))
446
d5aab704
CF
447 #__fdelt_chk's params and return type have changed from long unsigned int to long int.
448 # See which one is present here.
449 AC_MSG_CHECKING(__fdelt_chk type)
e2a98d27 450 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef _FORTIFY_SOURCE
8021cf8d
CF
451 #undef _FORTIFY_SOURCE
452 #endif
453 #define _FORTIFY_SOURCE 2
d5aab704 454 #include <sys/select.h>
e2a98d27 455 extern "C" long unsigned int __fdelt_warn(long unsigned int);]],[[]])],
d5aab704
CF
456 [ fdelt_type="long unsigned int"],
457 [ fdelt_type="long int"])
458 AC_MSG_RESULT($fdelt_type)
459 AC_DEFINE_UNQUOTED(FDELT_TYPE, $fdelt_type,[parameter and return value type for __fdelt_chk])
d68e2111
CF
460else
461 AC_SEARCH_LIBS([clock_gettime],[rt])
d5aab704
CF
462fi
463
c459de2f
CF
464if test x$TARGET_OS != xwindows; then
465 # All windows code is PIC, forcing it on just adds useless compile warnings
466 AX_CHECK_COMPILE_FLAG([-fPIC],[PIC_FLAGS="-fPIC"])
467fi
468
c4379e3a
JG
469#asan and tsan cannot be used together
470if test x$use_asan$use_tsan == xyesyes; then
471 AC_MSG_ERROR(asan and tsan cannot be simultaneously enabled)
472fi
473
474# using asan flag to enable address sanitizer and undefined behavior sanitizer
475if test x$use_asan == xyes; then
476 AX_CHECK_LINK_FLAG([-static-libstdc++],[SAN_LDFLAGS="$SAN_LDFLAGS -static-libstdc++"],[AC_MSG_ERROR(Cannot statically link -static-libstdc++)])
477 AX_CHECK_LINK_FLAG([-static-libasan],[SAN_LDFLAGS="$SAN_LDFLAGS -static-libasan"],[AC_MSG_ERROR(Cannot statically link -static-libasan)])
478 AX_CHECK_COMPILE_FLAG([-fsanitize=address],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fsanitize=address"],[AC_MSG_ERROR(Cannot enable -fsanitize=address)])
479 AX_CHECK_COMPILE_FLAG([-fsanitize=undefined],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fsanitize=undefined"],[AC_MSG_ERROR(Cannot enable -fsanitize=undefined)])
480 AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fno-omit-frame-pointer"],[AC_MSG_ERROR(Cannot enable -fno-omit-frame-pointer)])
481fi
482
483# using tsan flag to enable address thread sanitizer
484# TSAN is supported on Linux x84_64 and tested on Ubuntu 12.04
485# Non-position-independent executables are not supported. Use with -fPIE and -pie flags
486# libc/libstdc++ static linking is not supported
487if test x$use_tsan == xyes; then
488 AX_CHECK_COMPILE_FLAG([-fsanitize=thread],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fsanitize=thread"],[AC_MSG_ERROR(Cannot enable -fsanitize=thread)])
489 AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fno-omit-frame-pointer"],[AC_MSG_ERROR(Cannot enable -fno-omit-frame-pointer)])
490fi
491
35b8af92 492if test x$use_hardening != xno; then
5d37904b 493 AX_CHECK_COMPILE_FLAG([-Wformat],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wformat"],[AC_MSG_ERROR(Cannot enable -Wformat)])
6dcb7067 494 AX_CHECK_COMPILE_FLAG([-Wformat-security],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wformat-security"],[AC_MSG_ERROR(Cannot enable -Wformat-security)],[-Wformat])
b00b98ae
TH
495 AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"],[AC_MSG_ERROR(Cannot enable -Wstack-protector)])
496 AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"],[AC_MSG_ERROR(Cannot enable -fstack-protector-all)])
35b8af92 497
9b4e03b2
LD
498 AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[
499 AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[
500 HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE"
b00b98ae 501 ],[AC_MSG_ERROR(Cannot enable -U_FORTIFY_SOURCE)])
9b4e03b2 502 HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2"
b00b98ae 503 ],[AC_MSG_ERROR(Cannot enable -D_FORTIFY_SOURCE=2)])
35b8af92 504
01ea54be 505 #AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_ERROR(Cannot enable RELRO)])
506 #AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_ERROR(Cannot enable BIND_NOW)])
35b8af92
CF
507
508 if test x$TARGET_OS != xwindows; then
eccd5856 509 # All windows code is PIC, forcing it on just adds useless compile warnings
9d365796 510 AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_ERROR(Cannot enable RELRO)])
511 AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_ERROR(Cannot enable BIND_NOW)])
b00b98ae
TH
512 AX_CHECK_COMPILE_FLAG([-fPIE],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fPIE"],[AC_MSG_ERROR(Cannot enable -fPIE)])
513 AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"],[AC_MSG_ERROR(Cannot enable -pie)])
514 else
515 # These are only available on Windows.
516 AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"],[AC_MSG_ERROR(Cannot enable --dynamicbase)])
517 AX_CHECK_LINK_FLAG([[-Wl,--nxcompat]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"],[AC_MSG_ERROR(Cannot enable --nxcompat)])
8a932154 518 AX_CHECK_LINK_FLAG([[-Wl,--high-entropy-va]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--high-entropy-va"],[AC_MSG_ERROR(Cannot enable ASLR)])
35b8af92
CF
519 fi
520
811a765b
CF
521 case $host in
522 *mingw*)
523 AC_CHECK_LIB([ssp], [main],, AC_MSG_ERROR(lib missing))
524 ;;
525 esac
35b8af92
CF
526fi
527
528dnl this flag screws up non-darwin gcc even when the check fails. special-case it.
529if test x$TARGET_OS = xdarwin; then
530 AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"])
531fi
532
8ea6d37a 533AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h])
caf6150e
HL
534AC_SEARCH_LIBS([getaddrinfo_a], [anl], [AC_DEFINE(HAVE_GETADDRINFO_A, 1, [Define this symbol if you have getaddrinfo_a])])
535AC_SEARCH_LIBS([inet_pton], [nsl resolv], [AC_DEFINE(HAVE_INET_PTON, 1, [Define this symbol if you have inet_pton])])
f2647cc0 536
494f6e7d
PJ
537AC_CHECK_DECLS([strnlen])
538
4414f5ff 539AC_CHECK_DECLS([le16toh, le32toh, le64toh, htole16, htole32, htole64, be16toh, be32toh, be64toh, htobe16, htobe32, htobe64],,,
f2647cc0
CF
540 [#if HAVE_ENDIAN_H
541 #include <endian.h>
8ea6d37a
AV
542 #elif HAVE_SYS_ENDIAN_H
543 #include <sys/endian.h>
f2647cc0 544 #endif])
35b8af92 545
4414f5ff
WL
546AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64],,,
547 [#if HAVE_BYTESWAP_H
548 #include <byteswap.h>
549 #endif])
550
35b8af92
CF
551dnl Check for MSG_NOSIGNAL
552AC_MSG_CHECKING(for MSG_NOSIGNAL)
e2a98d27 553AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]],
554 [[ int f = MSG_NOSIGNAL; ]])],
35b8af92
CF
555 [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MSG_NOSIGNAL, 1,[Define this symbol if you have MSG_NOSIGNAL]) ],
556 [ AC_MSG_RESULT(no)]
557)
558
e432a5f0
CF
559AC_MSG_CHECKING([for visibility attribute])
560AC_LINK_IFELSE([AC_LANG_SOURCE([
561 int foo_def( void ) __attribute__((visibility("default")));
562 int main(){}
563 ])],
564 [
565 AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE,1,[Define if the visibility attribute is supported.])
566 AC_MSG_RESULT(yes)
567 ],
568 [
569 AC_MSG_RESULT(no)
570 if test x$use_reduce_exports = xyes; then
3448b132 571 AC_MSG_ERROR([Cannot find a working visibility attribute. Use --disable-reduce-exports.])
e432a5f0 572 fi
e432a5f0
CF
573 ]
574)
575
3ee028f1 576if test x$use_reduce_exports = xyes; then
e432a5f0 577 AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[RE_CXXFLAGS="-fvisibility=hidden"],
3448b132 578 [AC_MSG_ERROR([Cannot set default symbol visibility. Use --disable-reduce-exports.])])
e432a5f0
CF
579fi
580
4a290b52
LD
581LEVELDB_CPPFLAGS=
582LIBLEVELDB=
583LIBMEMENV=
584AM_CONDITIONAL([EMBEDDED_LEVELDB],[true])
585AC_SUBST(LEVELDB_CPPFLAGS)
586AC_SUBST(LIBLEVELDB)
587AC_SUBST(LIBMEMENV)
588
4f9e993b
WL
589if test x$enable_wallet != xno; then
590 dnl Check for libdb_cxx only if wallet enabled
9cb7abaf 591 BITCOIN_FIND_BDB62
4f9e993b 592fi
35b8af92 593
99eb947a
S
594dnl Check Qpid Proton headers and library exist
595if test x$use_proton = xyes; then
596 AC_CHECK_HEADERS([proton/connection.hpp],
597 [],
598 [AC_MSG_WARN([Proton headers not found, disabling Proton support])
599 use_proton=no])
600 AC_CHECK_LIB([qpid-proton-cpp], [main],
601 [PROTON_LIBS="-lqpid-proton-cpp -lqpid-proton"],
602 [AC_MSG_WARN([Proton libraries not found, disabling Proton support])
603 use_proton=no])
604fi
605if test x$use_proton = xyes; then
606 AC_DEFINE(ENABLE_PROTON, 1, [Define to 1 to enable Proton functions])
607else
608 AC_DEFINE(ENABLE_PROTON, 0, [Define to 1 to enable Proton functions])
35b8af92
CF
609fi
610
38ba3c66 611if test x$build_bitcoin_utils$build_bitcoind$use_tests = xnonono; then
b7a4ecc1
LD
612 use_boost=no
613else
614 use_boost=yes
615fi
616
617if test x$use_boost = xyes; then
618
35b8af92 619dnl Check for boost libs
6df5f51b 620dnl We need Boost >= 1.62 to fix a potential security bug (https://github.com/zcash/zcash/issues/1241)
621AX_BOOST_BASE([1.62])
35b8af92
CF
622AX_BOOST_SYSTEM
623AX_BOOST_FILESYSTEM
624AX_BOOST_PROGRAM_OPTIONS
625AX_BOOST_THREAD
626AX_BOOST_CHRONO
627
b7a4ecc1
LD
628fi
629
3ee028f1 630if test x$use_reduce_exports = xyes; then
e432a5f0
CF
631 CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS"
632 AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]], [RELDFLAGS="-Wl,--exclude-libs,ALL"])
633fi
634
35b8af92 635if test x$use_tests = xyes; then
152e51c7
CF
636
637 if test x$HEXDUMP = x; then
638 AC_MSG_ERROR(hexdump is required for tests)
639 fi
640
641
b7a4ecc1
LD
642 if test x$use_boost = xyes; then
643
35b8af92 644 AX_BOOST_UNIT_TEST_FRAMEWORK
e4b991e5
WL
645
646 dnl Determine if -DBOOST_TEST_DYN_LINK is needed
647 AC_MSG_CHECKING([for dynamic linked boost test])
648 TEMP_LIBS="$LIBS"
a7d1f035 649 LIBS="$LIBS $BOOST_LDFLAGS $BOOST_UNIT_TEST_FRAMEWORK_LIB"
e4b991e5
WL
650 TEMP_CPPFLAGS="$CPPFLAGS"
651 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
652 AC_LINK_IFELSE([AC_LANG_SOURCE([
653 #define BOOST_TEST_DYN_LINK
654 #define BOOST_TEST_MAIN
655 #include <boost/test/unit_test.hpp>
656
657 ])],
658 [AC_MSG_RESULT(yes)]
659 [TESTDEFS="$TESTDEFS -DBOOST_TEST_DYN_LINK"],
660 [AC_MSG_RESULT(no)])
661 LIBS="$TEMP_LIBS"
662 CPPFLAGS="$TEMP_CPPFLAGS"
b7a4ecc1
LD
663
664 fi
35b8af92
CF
665fi
666
b7a4ecc1 667if test x$use_boost = xyes; then
ca66717d 668BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB $BOOST_CHRONO_LIB"
b7a4ecc1 669fi
c8ba8ef6 670
35b8af92 671if test x$use_pkgconfig = xyes; then
d7002714 672 : dnl
35b8af92
CF
673 m4_ifdef(
674 [PKG_CHECK_MODULES],
675 [
6b099402
CF
676 PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)])
677 PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)])
df377ca8
WL
678 if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests != xnononono; then
679 PKG_CHECK_MODULES([EVENT], [libevent],, [AC_MSG_ERROR(libevent not found.)])
680 if test x$TARGET_OS != xwindows; then
681 PKG_CHECK_MODULES([EVENT_PTHREADS], [libevent_pthreads],, [AC_MSG_ERROR(libevent_pthreads not found.)])
682 fi
683 fi
effe8a5f
JC
684
685 if test "x$use_zmq" = "xyes"; then
686 PKG_CHECK_MODULES([ZMQ],[libzmq >= 4],
687 [AC_DEFINE([ENABLE_ZMQ],[1],[Define to 1 to enable ZMQ functions])],
688 [AC_DEFINE([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])
689 AC_MSG_WARN([libzmq version 4.x or greater not found, disabling])
690 use_zmq=no])
691 else
692 AC_DEFINE_UNQUOTED([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])
c8ba8ef6 693 fi
35b8af92
CF
694 ]
695 )
696else
c4da0970
NW
697 # BUG: Fix this:
698 echo 'BUG: configure does not yet check for the following dependencies if pkg-config is not on the system: libcrypto++, libgmp'
699
35b8af92 700 AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing))
6b099402 701 AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing))
35b8af92
CF
702
703 AC_CHECK_HEADER([openssl/ssl.h],, AC_MSG_ERROR(libssl headers missing),)
6b099402 704 AC_CHECK_LIB([ssl], [main],SSL_LIBS=-lssl, AC_MSG_ERROR(libssl missing))
35b8af92 705
df377ca8
WL
706 if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests != xnononono; then
707 AC_CHECK_HEADER([event2/event.h],, AC_MSG_ERROR(libevent headers missing),)
708 AC_CHECK_LIB([event],[main],EVENT_LIBS=-levent,AC_MSG_ERROR(libevent missing))
709 if test x$TARGET_OS != xwindows; then
710 AC_CHECK_LIB([event_pthreads],[main],EVENT_PTHREADS_LIBS=-levent_pthreads,AC_MSG_ERROR(libevent_pthreads missing))
711 fi
712 fi
713
effe8a5f
JC
714 if test "x$use_zmq" = "xyes"; then
715 AC_CHECK_HEADER([zmq.h],
716 [AC_DEFINE([ENABLE_ZMQ],[1],[Define to 1 to enable ZMQ functions])],
717 [AC_MSG_WARN([zmq.h not found, disabling zmq support])
718 use_zmq=no
719 AC_DEFINE([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])])
720 AC_CHECK_LIB([zmq],[zmq_ctx_shutdown],ZMQ_LIBS=-lzmq,
721 [AC_MSG_WARN([libzmq >= 4.0 not found, disabling zmq support])
722 use_zmq=no
723 AC_DEFINE([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])])
724 else
725 AC_DEFINE_UNQUOTED([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])
726 fi
727
00bcf223 728 if test "x$use_zmq" = "xyes"; then
729 dnl Assume libzmq was built for static linking
730 case $host in
731 *mingw*)
732 ZMQ_CFLAGS="$ZMQ_CFLAGS -DZMQ_STATIC"
733 ;;
734 esac
c8ba8ef6
CF
735 fi
736fi
35b8af92 737
c4da0970
NW
738# These packages don't provide pkgconfig config files across all
739# platforms, so we use older autoconf detection mechanisms:
9d365796 740if test x$TARGET_OS = xdarwin; then
c4da0970
NW
741AC_CHECK_HEADER([gmp.h],,AC_MSG_ERROR(libgmp headers missing))
742AC_CHECK_LIB([gmp],[[__gmpn_sub_n]],GMP_LIBS=-lgmp, [AC_MSG_ERROR(libgmp missing)])
743
744AC_CHECK_HEADER([gmpxx.h],,AC_MSG_ERROR(libgmpxx headers missing))
745AC_CHECK_LIB([gmpxx],[main],GMPXX_LIBS=-lgmpxx, [AC_MSG_ERROR(libgmpxx missing)])
9d365796 746fi
747
748#AC_CHECK_HEADER([gmp.h],,AC_MSG_ERROR(libgmp headers missing))
749#AC_CHECK_LIB([gmp],[[__gmpn_sub_n]],GMP_LIBS=-lgmp, [AC_MSG_ERROR(libgmp missing)])
750
751#AC_CHECK_HEADER([gmpxx.h],,AC_MSG_ERROR(libgmpxx headers missing))
752#AC_CHECK_LIB([gmpxx],[main],GMPXX_LIBS=-lgmpxx, [AC_MSG_ERROR(libgmpxx missing)])
c4da0970 753
c4da0970
NW
754# libsnark header layout is broken unless cpp's -I is passed with the
755# libsnark directory, so for now we use this hideous workaround:
756echo 'Hunting for libsnark include directory...'
757[LIBSNARK_INCDIR="$(echo "$CPPFLAGS" | sed 's,^.*-I\([^ ]*/include\).*$,\1/libsnark,')"]
758if test -d "$LIBSNARK_INCDIR"; then
759 echo "Found libsnark include directory: $LIBSNARK_INCDIR"
760else
39b00d05 761#AC_MSG_ERROR(libsnark include directory not found)
08211cf0 762echo "libsnark include directory not found ($LIBSNARK_INCDIR)"
c4da0970
NW
763fi
764
765CPPFLAGS="-I$LIBSNARK_INCDIR $CPPFLAGS"
766
767# Now check for libsnark compilability using traditional autoconf tests:
9d365796 768if test x$TARGET_OS = xdarwin; then
c4da0970
NW
769AC_CHECK_HEADER([libsnark/gadgetlib1/gadget.hpp],,AC_MSG_ERROR(libsnark headers missing))
770AC_CHECK_LIB([snark],[main],LIBSNARK_LIBS=-lsnark, [AC_MSG_ERROR(libsnark missing)], [-lgmpxx])
9d365796 771fi
772#AC_CHECK_HEADER([libsnark/gadgetlib1/gadget.hpp],,AC_MSG_ERROR(libsnark headers missing))
773#AC_CHECK_LIB([snark],[main],LIBSNARK_LIBS=-lsnark, [AC_MSG_ERROR(libsnark missing)], [-lgmpxx])
c4da0970 774
802ea76b
SB
775RUST_LIBS=""
776if test x$enable_rust != xno; then
777 RUST_LIBS="-lrustzcash"
778fi
779
daad2c27
JG
780dnl Check for OpenMP support
781AX_OPENMP(
782 [AC_DEFINE(HAVE_OPENMP, 1, [Define if OpenMP is enabled])
783 AM_CONDITIONAL([HAVE_OPENMP], [true])
784 CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"],
785 [AC_MSG_WARN([OpenMP not supported, disabling multithreading])
786 AC_DEFINE(HAVE_OPENMP, 0, [Define if OpenMP is enabled])
787 AM_CONDITIONAL([HAVE_OPENMP], [false])])
c4da0970 788
8f23c734
JG
789# Gitian uses a config.site that sets depends_prefix, and then sets --prefix=/
790# build.sh just uses --prefix
791if test x$depends_prefix != x; then
792 LIBSNARK_DEPINST="$depends_prefix"
793else
794 LIBSNARK_DEPINST="$prefix"
795fi
796
704337b2
JG
797# Additional Zcash flags
798AX_CHECK_COMPILE_FLAG([-fwrapv],[CXXFLAGS="$CXXFLAGS -fwrapv"])
799AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing],[CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"])
800AX_CHECK_COMPILE_FLAG([-Wno-builtin-declaration-mismatch],[CXXFLAGS="$CXXFLAGS -Wno-builtin-declaration-mismatch"],,[[$CXXFLAG_WERROR]])
801
1c518c38 802LIBZCASH_LIBS="-lgmp -lgmpxx -lboost_system -lcrypto -lsodium $RUST_LIBS"
a19eeace 803
e18e1001 804AC_MSG_CHECKING([whether to build bitcoind])
f930341d
LD
805AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
806AC_MSG_RESULT($build_bitcoind)
807
8b78a819 808AC_MSG_CHECKING([whether to build utils (zcash-cli zcash-tx wallet-utility)])
c101c769 809AM_CONDITIONAL([BUILD_BITCOIN_UTILS], [test x$build_bitcoin_utils = xyes])
810AC_MSG_RESULT($build_bitcoin_utils)
f930341d 811
cdd36c6c
CF
812AC_MSG_CHECKING([whether to build libraries])
813AM_CONDITIONAL([BUILD_BITCOIN_LIBS], [test x$build_bitcoin_libs = xyes])
814if test x$build_bitcoin_libs = xyes; then
815 AC_DEFINE(HAVE_CONSENSUS_LIB, 1, [Define this symbol if the consensus lib has been built])
08d6b02d 816 AC_CONFIG_FILES([libzcashconsensus.pc:libzcashconsensus.pc.in])
cdd36c6c 817fi
e463edc1 818
cdd36c6c
CF
819AC_MSG_RESULT($build_bitcoin_libs)
820
35b8af92
CF
821AC_LANG_POP
822
823if test "x$use_ccache" != "xno"; then
e18e1001 824 AC_MSG_CHECKING(if ccache should be used)
35b8af92
CF
825 if test x$CCACHE = x; then
826 if test "x$use_ccache" = "xyes"; then
827 AC_MSG_ERROR([ccache not found.]);
828 else
35b8af92
CF
829 use_ccache=no
830 fi
831 else
832 use_ccache=yes
833 CC="$ac_cv_path_CCACHE $CC"
834 CXX="$ac_cv_path_CCACHE $CXX"
835 fi
836 AC_MSG_RESULT($use_ccache)
837fi
386efb76
CF
838if test "x$use_ccache" = "xyes"; then
839 AX_CHECK_PREPROC_FLAG([-Qunused-arguments],[CPPFLAGS="-Qunused-arguments $CPPFLAGS"])
840fi
35b8af92 841
4f9e993b
WL
842dnl enable wallet
843AC_MSG_CHECKING([if wallet should be enabled])
844if test x$enable_wallet != xno; then
845 AC_MSG_RESULT(yes)
846 AC_DEFINE_UNQUOTED([ENABLE_WALLET],[1],[Define to 1 to enable wallet functions])
847
848else
849 AC_MSG_RESULT(no)
4f9e993b
WL
850fi
851
2cc0a252
JG
852dnl enable mining
853AC_MSG_CHECKING([if mining should be enabled])
854if test x$enable_mining != xno; then
855 AC_MSG_RESULT(yes)
856 AC_DEFINE(ENABLE_MINING, 1, [Define to 1 to enable mining functions])
857
858else
859 AC_MSG_RESULT(no)
860fi
861
802ea76b
SB
862dnl enable rust
863AC_MSG_CHECKING([if rust should be enabled])
864if test x$enable_rust != xno; then
865 AC_MSG_RESULT(yes)
866 AC_DEFINE(ENABLE_RUST, 1, [Define to 1 to enable Rust language dependent functions])
867
868else
869 AC_MSG_RESULT(no)
870fi
871
f200002c 872AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"])
35b8af92 873
99eb947a
S
874AM_CONDITIONAL([ENABLE_PROTON], [test "x$use_proton" = "xyes"])
875
e18e1001 876AC_MSG_CHECKING([whether to build test_bitcoin])
35b8af92 877if test x$use_tests = xyes; then
e18e1001 878 AC_MSG_RESULT([yes])
2762638a 879 BUILD_TEST="yes"
e18e1001
LD
880else
881 AC_MSG_RESULT([no])
2762638a 882 BUILD_TEST=""
35b8af92
CF
883fi
884
e432a5f0 885AC_MSG_CHECKING([whether to reduce exports])
3ee028f1 886if test x$use_reduce_exports = xyes; then
e432a5f0
CF
887 AC_MSG_RESULT([yes])
888else
889 AC_MSG_RESULT([no])
890fi
891
38ba3c66 892if test x$build_bitcoin_utils$build_bitcoin_libs$build_bitcoind$use_tests = xnononono; then
abecfc42 893 AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-libs --with-daemon or --enable-tests])
a9dbcf03
LD
894fi
895
35b8af92 896AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin])
b62bbb1f 897AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin])
35b8af92 898AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows])
b77b4eda 899AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes])
2cc0a252 900AM_CONDITIONAL([ENABLE_MINING],[test x$enable_mining = xyes])
802ea76b 901AM_CONDITIONAL([ENABLE_RUST],[test x$enable_rust = xyes])
2762638a 902AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
b77b4eda 903AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes])
d5aab704 904AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes])
56734f4b 905AM_CONDITIONAL([HARDEN],[test x$use_hardening = xyes])
c4379e3a
JG
906AM_CONDITIONAL([ASAN],[test x$use_asan = xyes])
907AM_CONDITIONAL([TSAN],[test x$use_tsan = xyes])
35b8af92
CF
908
909AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
910AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])
911AC_DEFINE(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION, [Build revision])
912AC_DEFINE(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD, [Version Build])
913AC_DEFINE(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE, [Version is release])
914AC_DEFINE(COPYRIGHT_YEAR, _COPYRIGHT_YEAR, [Version is release])
915AC_SUBST(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR)
916AC_SUBST(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR)
917AC_SUBST(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION)
918AC_SUBST(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD)
919AC_SUBST(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE)
920AC_SUBST(COPYRIGHT_YEAR, _COPYRIGHT_YEAR)
c5d645e2
CF
921AC_SUBST(BITCOIN_DAEMON_NAME)
922AC_SUBST(BITCOIN_CLI_NAME)
923AC_SUBST(BITCOIN_TX_NAME)
35b8af92 924
e432a5f0 925AC_SUBST(RELDFLAGS)
5dd887fd 926AC_SUBST(ERROR_CXXFLAGS)
c4379e3a
JG
927AC_SUBST(SAN_CXXFLAGS)
928AC_SUBST(SAN_LDFLAGS)
c459de2f
CF
929AC_SUBST(HARDENED_CXXFLAGS)
930AC_SUBST(HARDENED_CPPFLAGS)
931AC_SUBST(HARDENED_LDFLAGS)
932AC_SUBST(PIC_FLAGS)
933AC_SUBST(PIE_FLAGS)
e0077de5 934AC_SUBST(LIBTOOL_APP_LDFLAGS)
35b8af92 935AC_SUBST(BOOST_LIBS)
35b8af92
CF
936AC_SUBST(TESTDEFS)
937AC_SUBST(LEVELDB_TARGET_FLAGS)
d7002714
CF
938AC_SUBST(CRYPTO_LIBS)
939AC_SUBST(SSL_LIBS)
940AC_SUBST(EVENT_LIBS)
941AC_SUBST(EVENT_PTHREADS_LIBS)
942AC_SUBST(ZMQ_LIBS)
c4da0970
NW
943AC_SUBST(GMP_LIBS)
944AC_SUBST(GMPXX_LIBS)
8f23c734 945AC_SUBST(LIBSNARK_DEPINST)
1785bdb9 946AC_SUBST(LIBZCASH_LIBS)
99eb947a 947AC_SUBST(PROTON_LIBS)
b6a990de 948AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile src/test/buildenv.py])
35b8af92 949AC_CONFIG_FILES([qa/pull-tester/run-bitcoind-for-test.sh],[chmod +x qa/pull-tester/run-bitcoind-for-test.sh])
7667850d 950AC_CONFIG_FILES([qa/pull-tester/tests-config.sh],[chmod +x qa/pull-tester/tests-config.sh])
07a99017
PW
951
952dnl boost's m4 checks do something really nasty: they export these vars. As a
953dnl result, they leak into secp256k1's configure and crazy things happen.
954dnl Until this is fixed upstream and we've synced, we'll just un-export them.
0dc86138 955CPPFLAGS_TEMP="$CPPFLAGS"
cf61b544 956unset CPPFLAGS
0dc86138
CF
957CPPFLAGS="$CPPFLAGS_TEMP"
958
959LDFLAGS_TEMP="$LDFLAGS"
cf61b544 960unset LDFLAGS
0dc86138
CF
961LDFLAGS="$LDFLAGS_TEMP"
962
963LIBS_TEMP="$LIBS"
964unset LIBS
965LIBS="$LIBS_TEMP"
966
967PKGCONFIG_PATH_TEMP="$PKG_CONFIG_PATH"
968unset PKG_CONFIG_PATH
969PKG_CONFIG_PATH="$PKGCONFIG_PATH_TEMP"
970
971PKGCONFIG_LIBDIR_TEMP="$PKG_CONFIG_LIBDIR"
972unset PKG_CONFIG_LIBDIR
973PKG_CONFIG_LIBDIR="$PKGCONFIG_LIBDIR_TEMP"
974
c1afe40a 975ac_configure_args="${ac_configure_args} --disable-shared --with-pic --with-bignum=no --enable-module-recovery"
9e74de25 976AC_CONFIG_SUBDIRS([src/secp256k1 src/snark src/univalue src/cryptoconditions])
07a99017 977
35b8af92 978AC_OUTPUT
a98356fe
CF
979
980dnl Taken from https://wiki.debian.org/RpathIssue
981case $host in
982 *-*-linux-gnu)
983 AC_MSG_RESULT([Fixing libtool for -rpath problems.])
984 sed < libtool > libtool-2 \
985 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_IS_A_FOOL__ "/'
986 mv libtool-2 libtool
987 chmod 755 libtool
988 ;;
989esac
0bcd85be
JS
990
991echo
992echo "Options used to compile and link:"
993echo " with wallet = $enable_wallet"
0100c794
JG
994echo " with rust = $enable_rust"
995echo " with proton = $use_proton"
0bcd85be
JS
996echo " with zmq = $use_zmq"
997echo " with test = $use_tests"
998echo " debug enabled = $enable_debug"
5dd887fd 999echo " werror = $enable_werror"
0bcd85be
JS
1000echo
1001echo " target os = $TARGET_OS"
1002echo " build os = $BUILD_OS"
1003echo
1004echo " CC = $CC"
1005echo " CFLAGS = $CFLAGS"
1006echo " CPPFLAGS = $CPPFLAGS"
1007echo " CXX = $CXX"
1008echo " CXXFLAGS = $CXXFLAGS"
1009echo " LDFLAGS = $LDFLAGS"
bc9fff11 1010echo " ARFLAGS = $ARFLAGS"
0bcd85be 1011echo
This page took 0.343922 seconds and 4 git commands to generate.