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

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