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

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