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

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