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