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

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