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

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