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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  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, 9)
  5. define(_CLIENT_VERSION_REVISION, 99)
  6. define(_CLIENT_VERSION_BUILD, 0)
  7. define(_CLIENT_VERSION_IS_RELEASE, false)
  8. define(_COPYRIGHT_YEAR, 2014)
  9. AC_INIT([Bitcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@bitcoin.org],[bitcoin])
  10. AC_CONFIG_SRCDIR([src/main.cpp])
  11. AC_CONFIG_HEADERS([src/config/bitcoin-config.h])
  12. AC_CONFIG_AUX_DIR([build-aux])
  13. AC_CONFIG_MACRO_DIR([build-aux/m4])
  14. LT_INIT([disable-shared])
  15. AC_CANONICAL_HOST
  16. AH_TOP([#ifndef BITCOIN_CONFIG_H])
  17. AH_TOP([#define BITCOIN_CONFIG_H])
  18. AH_BOTTOM([#endif //BITCOIN_CONFIG_H])
  19. # This m4 will only be used if a system copy cannot be found. This is helpful
  20. # on systems where autotools are installed but the pkg-config macros are not in
  21. # a default location. It is currently used for building on OSX where autotools
  22. # are preinstalled but pkg-config comes from macports or homebrew. It should
  23. # probably be removed when building on <= 10.6 is no longer supported.
  24. m4_include([pkg.m4])
  25. dnl faketime breaks configure and is only needed for make. Disable it here.
  26. unset FAKETIME
  27. if test "x${CXXFLAGS+set}" = "xset"; then
  28. CXXFLAGS_overridden=yes
  29. else
  30. CXXFLAGS_overridden=no
  31. fi
  32. dnl ==============================================================
  33. dnl Setup for automake
  34. dnl ==============================================================
  35. AM_INIT_AUTOMAKE([no-define subdir-objects foreign])
  36. dnl faketime messes with timestamps and causes configure to be re-run.
  37. dnl --disable-maintainer-mode can be used to bypass this.
  38. AM_MAINTAINER_MODE([enable])
  39. dnl make the compilation flags quiet unless V=1 is used
  40. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  41. dnl Checks for programs.
  42. AC_PROG_CXX
  43. AC_PROG_CC
  44. AC_PROG_CPP
  45. AC_PROG_CXXCPP
  46. AC_PROG_INSTALL
  47. AC_PROG_OBJC
  48. AC_PROG_LN_S
  49. m4_ifdef([AC_PROG_OBJCXX],[AC_PROG_OBJCXX])
  50. AC_PROG_MKDIR_P
  51. AC_PROG_SED
  52. AC_PATH_TOOL(AR, ar)
  53. AC_PATH_TOOL(RANLIB, ranlib)
  54. AC_PATH_TOOL(STRIP, strip)
  55. AC_PATH_TOOL(GCOV, gcov)
  56. AC_PATH_PROG(LCOV, lcov)
  57. AC_PATH_PROG(JAVA, java)
  58. AC_PATH_PROG(GENHTML, genhtml)
  59. AC_PATH_PROG([GIT], [git])
  60. AC_PATH_PROG(CCACHE,ccache)
  61. AC_PATH_PROG(XGETTEXT,xgettext)
  62. AC_PATH_PROG(HEXDUMP,hexdump)
  63. PKG_PROG_PKG_CONFIG
  64. # Enable wallet
  65. AC_ARG_ENABLE([wallet],
  66. [AS_HELP_STRING([--enable-wallet],
  67. [enable wallet (default is yes)])],
  68. [enable_wallet=$enableval],
  69. [enable_wallet=yes])
  70. AC_ARG_WITH([miniupnpc],
  71. [AS_HELP_STRING([--with-miniupnpc],
  72. [enable UPNP (default is yes if libminiupnpc is found)])],
  73. [use_upnp=$withval],
  74. [use_upnp=auto])
  75. AC_ARG_ENABLE([upnp-default],
  76. [AS_HELP_STRING([--enable-upnp-default],
  77. [if UPNP is enabled, turn it on at startup (default is no)])],
  78. [use_upnp_default=$enableval],
  79. [use_upnp_default=no])
  80. AC_ARG_ENABLE(tests,
  81. AS_HELP_STRING([--enable-tests],[compile tests (default is yes)]),
  82. [use_tests=$enableval],
  83. [use_tests=yes])
  84. AC_ARG_WITH([comparison-tool],
  85. AS_HELP_STRING([--with-comparison-tool],[path to java comparison tool (requires --enable-tests)]),
  86. [use_comparison_tool=$withval],
  87. [use_comparison_tool=no])
  88. AC_ARG_ENABLE([comparison-tool-reorg-tests],
  89. AS_HELP_STRING([--enable-comparison-tool-reorg-tests],[enable expensive reorg tests in the comparison tool (default no)]),
  90. [use_comparison_tool_reorg_tests=$enableval],
  91. [use_comparison_tool_reorg_tests=no])
  92. AC_ARG_WITH([qrencode],
  93. [AS_HELP_STRING([--with-qrencode],
  94. [enable QR code support (default is yes if qt is enabled and libqrencode is found)])],
  95. [use_qr=$withval],
  96. [use_qr=auto])
  97. AC_ARG_ENABLE([hardening],
  98. [AS_HELP_STRING([--enable-hardening],
  99. [attempt to harden the resulting executables (default is yes)])],
  100. [use_hardening=$enableval],
  101. [use_hardening=yes])
  102. AC_ARG_ENABLE([reduce-exports],
  103. [AS_HELP_STRING([--enable-reduce-exports],
  104. [attempt to reduce exported symbols in the resulting executables (default is yes)])],
  105. [use_reduce_exports=$enableval],
  106. [use_reduce_exports=auto])
  107. AC_ARG_ENABLE([ccache],
  108. [AS_HELP_STRING([--enable-ccache],
  109. [use ccache for building (default is yes if ccache is found)])],
  110. [use_ccache=$enableval],
  111. [use_ccache=auto])
  112. AC_ARG_ENABLE([lcov],
  113. [AS_HELP_STRING([--enable-lcov],
  114. [enable lcov testing (default is no)])],
  115. [use_lcov=yes],
  116. [use_lcov=no])
  117. AC_ARG_ENABLE([glibc-back-compat],
  118. [AS_HELP_STRING([--enable-glibc-back-compat],
  119. [enable backwards compatibility with glibc and libstdc++])],
  120. [use_glibc_compat=$enableval],
  121. [use_glibc_compat=no])
  122. AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], [])
  123. # Enable debug
  124. AC_ARG_ENABLE([debug],
  125. [AS_HELP_STRING([--enable-debug],
  126. [use debug compiler flags and macros (default is no)])],
  127. [enable_debug=$enableval],
  128. [enable_debug=no])
  129. if test "x$enable_debug" = xyes; then
  130. if test "x$GCC" = xyes; then
  131. CFLAGS="-g3 -O0 -DDEBUG"
  132. fi
  133. if test "x$GXX" = xyes; then
  134. CXXFLAGS="-g3 -O0 -DDEBUG"
  135. fi
  136. fi
  137. ## TODO: Remove these hard-coded paths and flags. They are here for the sake of
  138. ## compatibility with the legacy buildsystem.
  139. ##
  140. if test "x$CXXFLAGS_overridden" = "xno"; then
  141. CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter"
  142. fi
  143. CPPFLAGS="$CPPFLAGS -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
  144. AC_LANG_PUSH([C++])
  145. use_pkgconfig=yes
  146. case $host in
  147. *mingw*)
  148. #pkgconfig does more harm than good with MinGW
  149. use_pkgconfig=no
  150. TARGET_OS=windows
  151. AC_CHECK_LIB([mingwthrd], [main],, AC_MSG_ERROR(lib missing))
  152. AC_CHECK_LIB([kernel32], [main],, AC_MSG_ERROR(lib missing))
  153. AC_CHECK_LIB([user32], [main],, AC_MSG_ERROR(lib missing))
  154. AC_CHECK_LIB([gdi32], [main],, AC_MSG_ERROR(lib missing))
  155. AC_CHECK_LIB([comdlg32], [main],, AC_MSG_ERROR(lib missing))
  156. AC_CHECK_LIB([winspool], [main],, AC_MSG_ERROR(lib missing))
  157. AC_CHECK_LIB([winmm], [main],, AC_MSG_ERROR(lib missing))
  158. AC_CHECK_LIB([shell32], [main],, AC_MSG_ERROR(lib missing))
  159. AC_CHECK_LIB([comctl32], [main],, AC_MSG_ERROR(lib missing))
  160. AC_CHECK_LIB([ole32], [main],, AC_MSG_ERROR(lib missing))
  161. AC_CHECK_LIB([oleaut32], [main],, AC_MSG_ERROR(lib missing))
  162. AC_CHECK_LIB([uuid], [main],, AC_MSG_ERROR(lib missing))
  163. AC_CHECK_LIB([rpcrt4], [main],, AC_MSG_ERROR(lib missing))
  164. AC_CHECK_LIB([advapi32], [main],, AC_MSG_ERROR(lib missing))
  165. AC_CHECK_LIB([ws2_32], [main],, AC_MSG_ERROR(lib missing))
  166. AC_CHECK_LIB([mswsock], [main],, AC_MSG_ERROR(lib missing))
  167. AC_CHECK_LIB([shlwapi], [main],, AC_MSG_ERROR(lib missing))
  168. AC_CHECK_LIB([iphlpapi], [main],, AC_MSG_ERROR(lib missing))
  169. AC_CHECK_LIB([crypt32], [main],, AC_MSG_ERROR(lib missing))
  170. AX_CHECK_LINK_FLAG([[-static-libgcc]],[LDFLAGS="$LDFLAGS -static-libgcc"])
  171. AX_CHECK_LINK_FLAG([[-static-libstdc++]],[LDFLAGS="$LDFLAGS -static-libstdc++"])
  172. # -static is interpreted by libtool, where it has a different meaning.
  173. # In libtool-speak, it's -all-static.
  174. AX_CHECK_LINK_FLAG([[-static]],[LDFLAGS="$LDFLAGS -static"; LIBTOOL_LDFLAGS="$LIBTOOL_LDFLAGS -all-static"])
  175. AC_PATH_PROG([MAKENSIS], [makensis], none)
  176. if test x$MAKENSIS = xnone; then
  177. AC_MSG_WARN("makensis not found. Cannot create installer.")
  178. fi
  179. AC_PATH_TOOL(WINDRES, windres, none)
  180. if test x$WINDRES = xnone; then
  181. AC_MSG_ERROR("windres not found")
  182. fi
  183. CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB"
  184. LEVELDB_TARGET_FLAGS="TARGET_OS=OS_WINDOWS_CROSSCOMPILE"
  185. if test "x$CXXFLAGS_overridden" = "xno"; then
  186. CXXFLAGS="$CXXFLAGS -w"
  187. fi
  188. case $host in
  189. i?86-*) WINDOWS_BITS=32 ;;
  190. x86_64-*) WINDOWS_BITS=64 ;;
  191. *) AC_MSG_ERROR("Could not determine win32/win64 for installer") ;;
  192. esac
  193. AC_SUBST(WINDOWS_BITS)
  194. ;;
  195. *darwin*)
  196. TARGET_OS=darwin
  197. LEVELDB_TARGET_FLAGS="TARGET_OS=Darwin"
  198. if test x$cross_compiling != xyes; then
  199. BUILD_OS=darwin
  200. AC_CHECK_PROG([PORT],port, port)
  201. if test x$PORT = xport; then
  202. dnl add default macports paths
  203. CPPFLAGS="$CPPFLAGS -isystem /opt/local/include -I/opt/local/include/db48"
  204. LIBS="$LIBS -L/opt/local/lib -L/opt/local/lib/db48"
  205. fi
  206. AC_CHECK_PROG([BREW],brew, brew)
  207. if test x$BREW = xbrew; then
  208. dnl These Homebrew packages may be bottled, meaning that they won't be found
  209. dnl in expected paths because they may conflict with system files. Ask
  210. dnl Homebrew where each one is located, then adjust paths accordingly.
  211. dnl It's safe to add these paths even if the functionality is disabled by
  212. dnl the user (--without-wallet or --without-gui for example).
  213. openssl_prefix=`$BREW --prefix openssl 2>/dev/null`
  214. bdb_prefix=`$BREW --prefix berkeley-db4 2>/dev/null`
  215. qt5_prefix=`$BREW --prefix qt5 2>/dev/null`
  216. if test x$openssl_prefix != x; then
  217. export PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
  218. fi
  219. if test x$bdb_prefix != x; then
  220. CPPFLAGS="$CPPFLAGS -I$bdb_prefix/include"
  221. LIBS="$LIBS -L$bdb_prefix/lib"
  222. fi
  223. if test x$qt5_prefix != x; then
  224. export PKG_CONFIG_PATH="$qt5_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
  225. fi
  226. fi
  227. else
  228. case $build_os in
  229. *darwin*)
  230. BUILD_OS=darwin
  231. ;;
  232. *)
  233. AC_PATH_TOOL([INSTALLNAMETOOL], [install_name_tool], install_name_tool)
  234. AC_PATH_TOOL([OTOOL], [otool], otool)
  235. AC_PATH_PROGS([GENISOIMAGE], [genisoimage mkisofs],genisoimage)
  236. ;;
  237. esac
  238. fi
  239. CPPFLAGS="$CPPFLAGS -DMAC_OSX"
  240. ;;
  241. *linux*)
  242. TARGET_OS=linux
  243. ;;
  244. *)
  245. ;;
  246. esac
  247. if test x$use_comparison_tool != xno; then
  248. AC_SUBST(JAVA_COMPARISON_TOOL, $use_comparison_tool)
  249. fi
  250. if test x$use_comparison_tool_reorg_tests != xno; then
  251. if test x$use_comparison_tool == x; then
  252. AC_MSG_ERROR("comparison tool reorg tests but comparison tool was not specified")
  253. fi
  254. AC_SUBST(COMPARISON_TOOL_REORG_TESTS, 1)
  255. else
  256. AC_SUBST(COMPARISON_TOOL_REORG_TESTS, 0)
  257. fi
  258. if test x$use_lcov == xyes; then
  259. if test x$LCOV == x; then
  260. AC_MSG_ERROR("lcov testing requested but lcov not found")
  261. fi
  262. if test x$GCOV == x; then
  263. AC_MSG_ERROR("lcov testing requested but gcov not found")
  264. fi
  265. if test x$JAVA == x; then
  266. AC_MSG_ERROR("lcov testing requested but java not found")
  267. fi
  268. if test x$GENHTML == x; then
  269. AC_MSG_ERROR("lcov testing requested but genhtml not found")
  270. fi
  271. if test x$use_comparison_tool == x; then
  272. AC_MSG_ERROR("lcov testing requested but comparison tool was not specified")
  273. fi
  274. LCOV="$LCOV --gcov-tool=$GCOV"
  275. AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"],
  276. [AC_MSG_ERROR("lcov testing requested but --coverage flag does not work")])
  277. fi
  278. dnl Require little endian
  279. AC_C_BIGENDIAN([AC_MSG_ERROR("Big Endian not supported")])
  280. dnl Check for pthread compile/link requirements
  281. AX_PTHREAD
  282. # The following macro will add the necessary defines to bitcoin-config.h, but
  283. # they also need to be passed down to any subprojects. Pull the results out of
  284. # the cache and add them to CPPFLAGS.
  285. AC_SYS_LARGEFILE
  286. # detect POSIX or GNU variant of strerror_r
  287. AC_FUNC_STRERROR_R
  288. if test x$ac_cv_sys_file_offset_bits != x &&
  289. test x$ac_cv_sys_file_offset_bits != xno &&
  290. test x$ac_cv_sys_file_offset_bits != xunknown; then
  291. CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
  292. fi
  293. if test x$ac_cv_sys_large_files != x &&
  294. test x$ac_cv_sys_large_files != xno &&
  295. test x$ac_cv_sys_large_files != xunknown; then
  296. CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files"
  297. fi
  298. AX_CHECK_LINK_FLAG([[-Wl,--large-address-aware]], [LDFLAGS="$LDFLAGS -Wl,--large-address-aware"])
  299. if test x$use_glibc_compat != xno; then
  300. #__fdelt_chk's params and return type have changed from long unsigned int to long int.
  301. # See which one is present here.
  302. AC_MSG_CHECKING(__fdelt_chk type)
  303. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef _FORTIFY_SOURCE
  304. #undef _FORTIFY_SOURCE
  305. #endif
  306. #define _FORTIFY_SOURCE 2
  307. #include <sys/select.h>
  308. extern "C" long unsigned int __fdelt_warn(long unsigned int);]],[[]])],
  309. [ fdelt_type="long unsigned int"],
  310. [ fdelt_type="long int"])
  311. AC_MSG_RESULT($fdelt_type)
  312. AC_DEFINE_UNQUOTED(FDELT_TYPE, $fdelt_type,[parameter and return value type for __fdelt_chk])
  313. fi
  314. if test x$use_hardening != xno; then
  315. AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"])
  316. AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"])
  317. AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[
  318. AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[
  319. HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE"
  320. ])
  321. HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2"
  322. ])
  323. AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"])
  324. AX_CHECK_LINK_FLAG([[-Wl,--nxcompat]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"])
  325. AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"])
  326. AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"])
  327. if test x$TARGET_OS != xwindows; then
  328. # All windows code is PIC, forcing it on just adds useless compile warnings
  329. AX_CHECK_COMPILE_FLAG([-fPIE],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fPIE"])
  330. AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"])
  331. fi
  332. CXXFLAGS="$CXXFLAGS $HARDENED_CXXFLAGS"
  333. CPPFLAGS="$CPPFLAGS $HARDENED_CPPFLAGS"
  334. LDFLAGS="$LDFLAGS $HARDENED_LDFLAGS"
  335. OBJCXXFLAGS="$CXXFLAGS"
  336. fi
  337. dnl this flag screws up non-darwin gcc even when the check fails. special-case it.
  338. if test x$TARGET_OS = xdarwin; then
  339. AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"])
  340. fi
  341. AC_CHECK_HEADERS([endian.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h])
  342. AC_SEARCH_LIBS([getaddrinfo_a], [anl], [AC_DEFINE(HAVE_GETADDRINFO_A, 1, [Define this symbol if you have getaddrinfo_a])])
  343. AC_SEARCH_LIBS([inet_pton], [nsl resolv], [AC_DEFINE(HAVE_INET_PTON, 1, [Define this symbol if you have inet_pton])])
  344. AC_CHECK_DECLS([le32toh, le64toh, htole32, htole64, be32toh, be64toh, htobe32, htobe64],,,
  345. [#if HAVE_ENDIAN_H
  346. #include <endian.h>
  347. #endif])
  348. dnl Check for MSG_NOSIGNAL
  349. AC_MSG_CHECKING(for MSG_NOSIGNAL)
  350. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]],
  351. [[ int f = MSG_NOSIGNAL; ]])],
  352. [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MSG_NOSIGNAL, 1,[Define this symbol if you have MSG_NOSIGNAL]) ],
  353. [ AC_MSG_RESULT(no)]
  354. )
  355. AC_SEARCH_LIBS([clock_gettime],[rt])
  356. AC_MSG_CHECKING([for visibility attribute])
  357. AC_LINK_IFELSE([AC_LANG_SOURCE([
  358. int foo_def( void ) __attribute__((visibility("default")));
  359. int main(){}
  360. ])],
  361. [
  362. AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE,1,[Define if the visibility attribute is supported.])
  363. AC_MSG_RESULT(yes)
  364. ],
  365. [
  366. AC_MSG_RESULT(no)
  367. if test x$use_reduce_exports = xyes; then
  368. AC_MSG_ERROR([Cannot find a working visibility attribute. Use --disable-reduced-exports.])
  369. fi
  370. AC_MSG_WARN([Cannot find a working visibility attribute. Disabling reduced exports.])
  371. use_reduce_exports=no
  372. ]
  373. )
  374. if test x$use_reduce_exports != xno; then
  375. AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[RE_CXXFLAGS="-fvisibility=hidden"],
  376. [
  377. if test x$use_reduce_exports = xyes; then
  378. AC_MSG_ERROR([Cannot set default symbol visibility. Use --disable-reduced-exports.])
  379. fi
  380. AC_MSG_WARN([Cannot set default symbol visibility. Disabling reduced exports.])
  381. use_reduce_exports=no
  382. ])
  383. fi
  384. LEVELDB_CPPFLAGS=
  385. LIBLEVELDB=
  386. LIBMEMENV=
  387. AM_CONDITIONAL([EMBEDDED_LEVELDB],[true])
  388. AC_SUBST(LEVELDB_CPPFLAGS)
  389. AC_SUBST(LIBLEVELDB)
  390. AC_SUBST(LIBMEMENV)
  391. if test x$enable_wallet != xno; then
  392. dnl Check for libdb_cxx only if wallet enabled
  393. BITCOIN_FIND_BDB48
  394. fi
  395. dnl Check for libminiupnpc (optional)
  396. if test x$use_upnp != xno; then
  397. AC_CHECK_HEADERS(
  398. [miniupnpc/miniwget.h miniupnpc/miniupnpc.h miniupnpc/upnpcommands.h miniupnpc/upnperrors.h],
  399. [AC_CHECK_LIB([miniupnpc], [main],, [have_miniupnpc=no])],
  400. [have_miniupnpc=no]
  401. )
  402. fi
  403. dnl Check for boost libs
  404. AX_BOOST_BASE
  405. AX_BOOST_SYSTEM
  406. AX_BOOST_FILESYSTEM
  407. AX_BOOST_PROGRAM_OPTIONS
  408. AX_BOOST_THREAD
  409. AX_BOOST_CHRONO
  410. if test x$use_reduce_exports != xno; then
  411. AC_MSG_CHECKING([for working boost reduced exports])
  412. TEMP_CPPFLAGS="$CPPFLAGS"
  413. CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS"
  414. AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
  415. @%:@include <boost/version.hpp>
  416. ]], [[
  417. #if BOOST_VERSION >= 104900
  418. // Everything is okay
  419. #else
  420. # error Boost version is too old
  421. #endif
  422. ]])],[
  423. AC_MSG_RESULT(yes)
  424. ],[:
  425. if test x$use_reduce_exports = xauto; then
  426. use_reduce_exports=no
  427. else
  428. if test x$use_reduce_exports = xyes; then
  429. AC_MSG_ERROR([boost versions < 1.49 are known to be broken with reduced exports. Use --disable-reduced-exports.])
  430. fi
  431. fi
  432. AC_MSG_RESULT(no)
  433. AC_MSG_WARN([boost versions < 1.49 are known to have symbol visibility issues. Disabling reduced exports.])
  434. ])
  435. CPPFLAGS="$TEMP_CPPFLAGS"
  436. fi
  437. if test x$use_reduce_exports != xno; then
  438. CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS"
  439. AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]], [RELDFLAGS="-Wl,--exclude-libs,ALL"])
  440. fi
  441. if test x$use_tests = xyes; then
  442. if test x$HEXDUMP = x; then
  443. AC_MSG_ERROR(hexdump is required for tests)
  444. fi
  445. AX_BOOST_UNIT_TEST_FRAMEWORK
  446. dnl Determine if -DBOOST_TEST_DYN_LINK is needed
  447. AC_MSG_CHECKING([for dynamic linked boost test])
  448. TEMP_LIBS="$LIBS"
  449. LIBS="$LIBS $BOOST_UNIT_TEST_FRAMEWORK_LIB"
  450. TEMP_CPPFLAGS="$CPPFLAGS"
  451. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  452. AC_LINK_IFELSE([AC_LANG_SOURCE([
  453. #define BOOST_TEST_DYN_LINK
  454. #define BOOST_TEST_MAIN
  455. #include <boost/test/unit_test.hpp>
  456. ])],
  457. [AC_MSG_RESULT(yes)]
  458. [TESTDEFS="$TESTDEFS -DBOOST_TEST_DYN_LINK"],
  459. [AC_MSG_RESULT(no)])
  460. LIBS="$TEMP_LIBS"
  461. CPPFLAGS="$TEMP_CPPFLAGS"
  462. fi
  463. BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB"
  464. dnl Boost >= 1.50 uses sleep_for rather than the now-deprecated sleep, however
  465. dnl it was broken from 1.50 to 1.52 when backed by nanosleep. Use sleep_for if
  466. dnl a working version is available, else fall back to sleep. sleep was removed
  467. dnl after 1.56.
  468. dnl If neither is available, abort.
  469. dnl If sleep_for is used, boost_chrono becomes a requirement.
  470. if test x$ax_cv_boost_chrono = xyes; then
  471. TEMP_LIBS="$LIBS"
  472. LIBS="$BOOST_LIBS $BOOST_CHRONO_LIB $LIBS"
  473. TEMP_CPPFLAGS="$CPPFLAGS"
  474. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  475. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  476. #include <boost/thread/thread.hpp>
  477. #include <boost/version.hpp>
  478. ]],[[
  479. #if BOOST_VERSION >= 105000 && (!defined(BOOST_HAS_NANOSLEEP) || BOOST_VERSION >= 105200)
  480. boost::this_thread::sleep_for(boost::chrono::milliseconds(0));
  481. #else
  482. choke me
  483. #endif
  484. ]])],
  485. [boost_sleep=yes; BOOST_LIBS="$BOOST_LIBS $BOOST_CHRONO_LIB";
  486. AC_DEFINE(HAVE_WORKING_BOOST_SLEEP_FOR, 1, [Define this symbol if boost sleep_for works])],
  487. [boost_sleep=no])
  488. LIBS="$TEMP_LIBS"
  489. CPPFLAGS="$TEMP_CPPFLAGS"
  490. fi
  491. if test x$boost_sleep != xyes; then
  492. TEMP_LIBS="$LIBS"
  493. LIBS="$BOOST_LIBS $LIBS"
  494. TEMP_CPPFLAGS="$CPPFLAGS"
  495. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  496. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  497. #include <boost/version.hpp>
  498. #include <boost/thread.hpp>
  499. #include <boost/date_time/posix_time/posix_time_types.hpp>
  500. ]],[[
  501. #if BOOST_VERSION <= 105600
  502. boost::this_thread::sleep(boost::posix_time::milliseconds(0));
  503. #else
  504. choke me
  505. #endif
  506. ]])],
  507. [boost_sleep=yes; AC_DEFINE(HAVE_WORKING_BOOST_SLEEP, 1, [Define this symbol if boost sleep works])],
  508. [boost_sleep=no])
  509. LIBS="$TEMP_LIBS"
  510. CPPFLAGS="$TEMP_CPPFLAGS"
  511. fi
  512. if test x$boost_sleep != xyes; then
  513. AC_MSG_ERROR(No working boost sleep implementation found.)
  514. fi
  515. AC_ARG_WITH([utils],
  516. [AS_HELP_STRING([--with-utils],
  517. [build bitcoin-cli bitcoin-tx (default=yes)])],
  518. [build_bitcoin_utils=$withval],
  519. [build_bitcoin_utils=yes])
  520. AC_ARG_WITH([daemon],
  521. [AS_HELP_STRING([--with-daemon],
  522. [build bitcoind daemon (default=yes)])],
  523. [build_bitcoind=$withval],
  524. [build_bitcoind=yes])
  525. BITCOIN_QT_INIT
  526. if test x$use_pkgconfig = xyes; then
  527. if test x"$PKG_CONFIG" == "x"; then
  528. AC_MSG_ERROR(pkg-config not found.)
  529. fi
  530. : #NOP
  531. m4_ifdef(
  532. [PKG_CHECK_MODULES],
  533. [
  534. PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)])
  535. PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)])
  536. BITCOIN_QT_CHECK([PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [BITCOIN_QT_FAIL(libprotobuf not found)])])
  537. if test x$use_qr != xno; then
  538. BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])])
  539. fi
  540. ]
  541. )
  542. else
  543. AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing))
  544. AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing))
  545. AC_CHECK_HEADER([openssl/ssl.h],, AC_MSG_ERROR(libssl headers missing),)
  546. AC_CHECK_LIB([ssl], [main],SSL_LIBS=-lssl, AC_MSG_ERROR(libssl missing))
  547. BITCOIN_QT_CHECK(AC_CHECK_LIB([protobuf] ,[main],,BITCOIN_QT_FAIL(libprotobuf not found)))
  548. if test x$use_qr != xno; then
  549. BITCOIN_QT_CHECK([AC_CHECK_LIB([qrencode], [main],, [have_qrencode=no])])
  550. BITCOIN_QT_CHECK([AC_CHECK_HEADER([qrencode.h],, have_qrencode=no)])
  551. fi
  552. fi
  553. BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path)
  554. AC_MSG_CHECKING([whether to build bitcoind])
  555. AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
  556. AC_MSG_RESULT($build_bitcoind)
  557. AC_MSG_CHECKING([whether to build utils (bitcoin-cli bitcoin-tx)])
  558. AM_CONDITIONAL([BUILD_BITCOIN_UTILS], [test x$build_bitcoin_utils = xyes])
  559. AC_MSG_RESULT($build_bitcoin_utils)
  560. dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus
  561. BITCOIN_QT_CONFIGURE([$use_pkgconfig], [qt4])
  562. AC_LANG_POP
  563. if test "x$use_ccache" != "xno"; then
  564. AC_MSG_CHECKING(if ccache should be used)
  565. if test x$CCACHE = x; then
  566. if test "x$use_ccache" = "xyes"; then
  567. AC_MSG_ERROR([ccache not found.]);
  568. else
  569. use_ccache=no
  570. fi
  571. else
  572. use_ccache=yes
  573. CC="$ac_cv_path_CCACHE $CC"
  574. CXX="$ac_cv_path_CCACHE $CXX"
  575. fi
  576. AC_MSG_RESULT($use_ccache)
  577. fi
  578. if test "x$use_ccache" = "xyes"; then
  579. AX_CHECK_PREPROC_FLAG([-Qunused-arguments],[CPPFLAGS="-Qunused-arguments $CPPFLAGS"])
  580. fi
  581. dnl enable wallet
  582. AC_MSG_CHECKING([if wallet should be enabled])
  583. if test x$enable_wallet != xno; then
  584. AC_MSG_RESULT(yes)
  585. AC_DEFINE_UNQUOTED([ENABLE_WALLET],[1],[Define to 1 to enable wallet functions])
  586. else
  587. AC_MSG_RESULT(no)
  588. fi
  589. dnl enable upnp support
  590. AC_MSG_CHECKING([whether to build with support for UPnP])
  591. if test x$have_miniupnpc = xno; then
  592. if test x$use_upnp = xyes; then
  593. AC_MSG_ERROR("UPnP requested but cannot be built. use --without-miniupnpc")
  594. fi
  595. AC_MSG_RESULT(no)
  596. else
  597. if test x$use_upnp != xno; then
  598. AC_MSG_RESULT(yes)
  599. AC_MSG_CHECKING([whether to build with UPnP enabled by default])
  600. use_upnp=yes
  601. upnp_setting=0
  602. if test x$use_upnp_default != xno; then
  603. use_upnp_default=yes
  604. upnp_setting=1
  605. fi
  606. AC_MSG_RESULT($use_upnp_default)
  607. AC_DEFINE_UNQUOTED([USE_UPNP],[$upnp_setting],[UPnP support not compiled if undefined, otherwise value (0 or 1) determines default state])
  608. if test x$TARGET_OS = xwindows; then
  609. MINIUPNPC_CPPFLAGS="-DSTATICLIB -DMINIUPNP_STATICLIB"
  610. fi
  611. else
  612. AC_MSG_RESULT(no)
  613. fi
  614. fi
  615. dnl these are only used when qt is enabled
  616. if test x$bitcoin_enable_qt != xno; then
  617. BUILD_QT=qt
  618. dnl enable dbus support
  619. AC_MSG_CHECKING([whether to build GUI with support for D-Bus])
  620. if test x$bitcoin_enable_qt_dbus != xno; then
  621. AC_DEFINE([USE_DBUS],[1],[Define if dbus support should be compiled in])
  622. fi
  623. AC_MSG_RESULT($bitcoin_enable_qt_dbus)
  624. dnl enable qr support
  625. AC_MSG_CHECKING([whether to build GUI with support for QR codes])
  626. if test x$have_qrencode = xno; then
  627. if test x$use_qr == xyes; then
  628. AC_MSG_ERROR("QR support requested but cannot be built. use --without-qrencode")
  629. fi
  630. AC_MSG_RESULT(no)
  631. else
  632. if test x$use_qr != xno; then
  633. AC_MSG_RESULT(yes)
  634. AC_DEFINE([USE_QRCODE],[1],[Define if QR support should be compiled in])
  635. use_qr=yes
  636. else
  637. AC_MSG_RESULT(no)
  638. fi
  639. fi
  640. if test x$XGETTEXT == x; then
  641. AC_MSG_WARN("xgettext is required to update qt translations")
  642. fi
  643. AC_MSG_CHECKING([whether to build test_bitcoin-qt])
  644. if test x$use_tests$bitcoin_enable_qt_test = xyesyes; then
  645. AC_MSG_RESULT([yes])
  646. BUILD_TEST_QT="test"
  647. else
  648. AC_MSG_RESULT([no])
  649. fi
  650. fi
  651. AC_MSG_CHECKING([whether to build test_bitcoin])
  652. if test x$use_tests = xyes; then
  653. AC_MSG_RESULT([yes])
  654. BUILD_TEST="test"
  655. else
  656. AC_MSG_RESULT([no])
  657. fi
  658. AC_MSG_CHECKING([whether to reduce exports])
  659. if test x$use_reduce_exports != xno; then
  660. AC_MSG_RESULT([yes])
  661. else
  662. AC_MSG_RESULT([no])
  663. fi
  664. if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests = xnononono; then
  665. AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-daemon --with-gui or --enable-tests])
  666. fi
  667. AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin])
  668. AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin])
  669. AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows])
  670. AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet == xyes])
  671. AM_CONDITIONAL([ENABLE_TESTS],[test x$use_tests == xyes])
  672. AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt == xyes])
  673. AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$use_tests$bitcoin_enable_qt_test = xyesyes])
  674. AM_CONDITIONAL([USE_QRCODE], [test x$use_qr = xyes])
  675. AM_CONDITIONAL([USE_LCOV],[test x$use_lcov == xyes])
  676. AM_CONDITIONAL([USE_COMPARISON_TOOL],[test x$use_comparison_tool != xno])
  677. AM_CONDITIONAL([USE_COMPARISON_TOOL_REORG_TESTS],[test x$use_comparison_tool_reorg_test != xno])
  678. AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes])
  679. AM_CONDITIONAL([USE_LIBSECP256K1],[test x$use_libsecp256k1 = xyes])
  680. AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
  681. AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])
  682. AC_DEFINE(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION, [Build revision])
  683. AC_DEFINE(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD, [Version Build])
  684. AC_DEFINE(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE, [Version is release])
  685. AC_DEFINE(COPYRIGHT_YEAR, _COPYRIGHT_YEAR, [Version is release])
  686. AC_SUBST(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR)
  687. AC_SUBST(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR)
  688. AC_SUBST(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION)
  689. AC_SUBST(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD)
  690. AC_SUBST(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE)
  691. AC_SUBST(COPYRIGHT_YEAR, _COPYRIGHT_YEAR)
  692. AC_SUBST(RELDFLAGS)
  693. AC_SUBST(LIBTOOL_LDFLAGS)
  694. AC_SUBST(USE_UPNP)
  695. AC_SUBST(USE_QRCODE)
  696. AC_SUBST(BOOST_LIBS)
  697. AC_SUBST(TESTDEFS)
  698. AC_SUBST(LEVELDB_TARGET_FLAGS)
  699. AC_SUBST(BUILD_TEST)
  700. AC_SUBST(BUILD_QT)
  701. AC_SUBST(BUILD_TEST_QT)
  702. AC_SUBST(MINIUPNPC_CPPFLAGS)
  703. AC_CONFIG_FILES([Makefile src/Makefile share/setup.nsi share/qt/Info.plist src/test/buildenv.py])
  704. AC_CONFIG_FILES([qa/pull-tester/run-bitcoind-for-test.sh],[chmod +x qa/pull-tester/run-bitcoind-for-test.sh])
  705. AC_CONFIG_FILES([qa/pull-tester/build-tests.sh],[chmod +x qa/pull-tester/build-tests.sh])
  706. AC_OUTPUT
  707. dnl Taken from https://wiki.debian.org/RpathIssue
  708. case $host in
  709. *-*-linux-gnu)
  710. AC_MSG_RESULT([Fixing libtool for -rpath problems.])
  711. sed < libtool > libtool-2 \
  712. 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_IS_A_FOOL__ "/'
  713. mv libtool-2 libtool
  714. chmod 755 libtool
  715. ;;
  716. esac