You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

configure.ac 39KB

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