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 43KB

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