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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  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/config/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([endian.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h])
  317. AC_CHECK_DECLS([le32toh, le64toh, htole32, htole64, be32toh, be64toh, htobe32, htobe64],,,
  318. [#if HAVE_ENDIAN_H
  319. #include <endian.h>
  320. #endif])
  321. dnl Check for MSG_NOSIGNAL
  322. AC_MSG_CHECKING(for MSG_NOSIGNAL)
  323. AC_TRY_COMPILE([#include <sys/socket.h>],
  324. [ int f = MSG_NOSIGNAL; ],
  325. [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MSG_NOSIGNAL, 1,[Define this symbol if you have MSG_NOSIGNAL]) ],
  326. [ AC_MSG_RESULT(no)]
  327. )
  328. LEVELDB_CPPFLAGS=
  329. LIBLEVELDB=
  330. LIBMEMENV=
  331. AM_CONDITIONAL([EMBEDDED_LEVELDB],[true])
  332. AC_SUBST(LEVELDB_CPPFLAGS)
  333. AC_SUBST(LIBLEVELDB)
  334. AC_SUBST(LIBMEMENV)
  335. if test x$enable_wallet != xno; then
  336. dnl Check for libdb_cxx only if wallet enabled
  337. BITCOIN_FIND_BDB48
  338. fi
  339. dnl Check for libminiupnpc (optional)
  340. if test x$use_upnp != xno; then
  341. AC_CHECK_HEADERS(
  342. [miniupnpc/miniwget.h miniupnpc/miniupnpc.h miniupnpc/upnpcommands.h miniupnpc/upnperrors.h],
  343. [AC_CHECK_LIB([miniupnpc], [main],, [have_miniupnpc=no])],
  344. [have_miniupnpc=no]
  345. )
  346. fi
  347. dnl Check for boost libs
  348. AX_BOOST_BASE
  349. AX_BOOST_SYSTEM
  350. AX_BOOST_FILESYSTEM
  351. AX_BOOST_PROGRAM_OPTIONS
  352. AX_BOOST_THREAD
  353. AX_BOOST_CHRONO
  354. if test x$use_tests = xyes; then
  355. if test x$HEXDUMP = x; then
  356. AC_MSG_ERROR(hexdump is required for tests)
  357. fi
  358. AX_BOOST_UNIT_TEST_FRAMEWORK
  359. dnl Determine if -DBOOST_TEST_DYN_LINK is needed
  360. AC_MSG_CHECKING([for dynamic linked boost test])
  361. TEMP_LIBS="$LIBS"
  362. LIBS="$LIBS $BOOST_UNIT_TEST_FRAMEWORK_LIB"
  363. TEMP_CPPFLAGS="$CPPFLAGS"
  364. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  365. AC_LINK_IFELSE([AC_LANG_SOURCE([
  366. #define BOOST_TEST_DYN_LINK
  367. #define BOOST_TEST_MAIN
  368. #include <boost/test/unit_test.hpp>
  369. ])],
  370. [AC_MSG_RESULT(yes)]
  371. [TESTDEFS="$TESTDEFS -DBOOST_TEST_DYN_LINK"],
  372. [AC_MSG_RESULT(no)])
  373. LIBS="$TEMP_LIBS"
  374. CPPFLAGS="$TEMP_CPPFLAGS"
  375. fi
  376. BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB"
  377. BOOST_INCLUDES="$BOOST_CPPFLAGS"
  378. dnl Boost >= 1.50 uses sleep_for rather than the now-deprecated sleep, however
  379. dnl it was broken from 1.50 to 1.52 when backed by nanosleep. Use sleep_for if
  380. dnl a working version is available, else fall back to sleep. sleep was removed
  381. dnl after 1.56.
  382. dnl If neither is available, abort.
  383. dnl If sleep_for is used, boost_chrono becomes a requirement.
  384. if test x$ax_cv_boost_chrono = xyes; then
  385. dnl Allow passing extra needed dependency libraries for boost-chrono from static gitian build
  386. BOOST_CHRONO_LIB="$BOOST_CHRONO_LIB $BOOST_CHRONO_EXTRALIBS"
  387. TEMP_LIBS="$LIBS"
  388. LIBS="$LIBS $BOOST_LIBS $BOOST_CHRONO_LIB"
  389. TEMP_CPPFLAGS="$CPPFLAGS"
  390. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  391. AC_TRY_LINK([
  392. #include <boost/thread/thread.hpp>
  393. #include <boost/version.hpp>
  394. ],[
  395. #if BOOST_VERSION >= 105000 && (!defined(BOOST_HAS_NANOSLEEP) || BOOST_VERSION >= 105200)
  396. boost::this_thread::sleep_for(boost::chrono::milliseconds(0));
  397. #else
  398. choke me
  399. #endif
  400. ],
  401. [boost_sleep=yes; BOOST_LIBS="$BOOST_LIBS $BOOST_CHRONO_LIB";
  402. AC_DEFINE(HAVE_WORKING_BOOST_SLEEP_FOR, 1, [Define this symbol if boost sleep_for works])],
  403. [boost_sleep=no])
  404. LIBS="$TEMP_LIBS"
  405. CPPFLAGS="$TEMP_CPPFLAGS"
  406. fi
  407. if test x$boost_sleep != xyes; then
  408. TEMP_LIBS="$LIBS"
  409. LIBS="$LIBS $BOOST_LIBS"
  410. TEMP_CPPFLAGS="$CPPFLAGS"
  411. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  412. AC_TRY_LINK([
  413. #include <boost/version.hpp>
  414. #include <boost/thread.hpp>
  415. #include <boost/date_time/posix_time/posix_time_types.hpp>
  416. ],[
  417. #if BOOST_VERSION <= 105600
  418. boost::this_thread::sleep(boost::posix_time::milliseconds(0));
  419. #else
  420. choke me
  421. #endif
  422. ],
  423. [boost_sleep=yes; AC_DEFINE(HAVE_WORKING_BOOST_SLEEP, 1, [Define this symbol if boost sleep works])],
  424. [boost_sleep=no])
  425. LIBS="$TEMP_LIBS"
  426. CPPFLAGS="$TEMP_CPPFLAGS"
  427. fi
  428. if test x$boost_sleep != xyes; then
  429. 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)
  430. fi
  431. AC_ARG_WITH([cli],
  432. [AS_HELP_STRING([--with-cli],
  433. [with CLI (default is yes)])],
  434. [build_bitcoin_cli=$withval],
  435. [build_bitcoin_cli=yes])
  436. AC_ARG_WITH([daemon],
  437. [AS_HELP_STRING([--with-daemon],
  438. [with daemon (default is yes)])],
  439. [build_bitcoind=$withval],
  440. [build_bitcoind=yes])
  441. BITCOIN_QT_INIT
  442. if test x$use_pkgconfig = xyes; then
  443. if test x$PKG_CONFIG == x; then
  444. AC_MSG_ERROR(pkg-config not found.)
  445. fi
  446. : #NOP
  447. m4_ifdef(
  448. [PKG_CHECK_MODULES],
  449. [
  450. PKG_CHECK_MODULES([SSL], [libssl], [INCLUDES="$INCLUDES $SSL_CFLAGS"; LIBS="$LIBS $SSL_LIBS"], [AC_MSG_ERROR(openssl not found.)])
  451. PKG_CHECK_MODULES([CRYPTO], [libcrypto], [INCLUDES="$INCLUDES $CRYPTO_CFLAGS"; LIBS="$LIBS $CRYPTO_LIBS"], [AC_MSG_ERROR(libcrypto not found.)])
  452. BITCOIN_QT_CHECK([PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [BITCOIN_QT_FAIL(libprotobuf not found)])])
  453. if test x$use_qr != xno; then
  454. BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])])
  455. fi
  456. ]
  457. )
  458. else
  459. AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing))
  460. AC_CHECK_LIB([crypto], [main],, AC_MSG_ERROR(libcrypto missing))
  461. AC_CHECK_HEADER([openssl/ssl.h],, AC_MSG_ERROR(libssl headers missing),)
  462. AC_CHECK_LIB([ssl], [main],, AC_MSG_ERROR(libssl missing))
  463. BITCOIN_QT_CHECK(AC_CHECK_LIB([protobuf] ,[main],,BITCOIN_QT_FAIL(libprotobuf not found)))
  464. if test x$use_qr != xno; then
  465. BITCOIN_QT_CHECK([AC_CHECK_LIB([qrencode], [main],, [have_qrencode=no])])
  466. BITCOIN_QT_CHECK([AC_CHECK_HEADER([qrencode.h],, have_qrencode=no)])
  467. fi
  468. fi
  469. BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path)
  470. AC_MSG_CHECKING([whether to build bitcoind])
  471. AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
  472. AC_MSG_RESULT($build_bitcoind)
  473. AC_MSG_CHECKING([whether to build bitcoin-cli])
  474. AM_CONDITIONAL([BUILD_BITCOIN_CLI], [test x$build_bitcoin_cli = xyes])
  475. AC_MSG_RESULT($build_bitcoin_cli)
  476. dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus
  477. BITCOIN_QT_CONFIGURE([$use_pkgconfig], [qt4])
  478. AC_LANG_POP
  479. if test "x$use_ccache" != "xno"; then
  480. AC_MSG_CHECKING(if ccache should be used)
  481. if test x$CCACHE = x; then
  482. if test "x$use_ccache" = "xyes"; then
  483. AC_MSG_ERROR([ccache not found.]);
  484. else
  485. use_ccache=no
  486. fi
  487. else
  488. use_ccache=yes
  489. CC="$ac_cv_path_CCACHE $CC"
  490. CXX="$ac_cv_path_CCACHE $CXX"
  491. fi
  492. AC_MSG_RESULT($use_ccache)
  493. fi
  494. dnl enable wallet
  495. AC_MSG_CHECKING([if wallet should be enabled])
  496. if test x$enable_wallet != xno; then
  497. AC_MSG_RESULT(yes)
  498. AC_DEFINE_UNQUOTED([ENABLE_WALLET],[1],[Define to 1 to enable wallet functions])
  499. else
  500. AC_MSG_RESULT(no)
  501. fi
  502. dnl enable upnp support
  503. AC_MSG_CHECKING([whether to build with support for UPnP])
  504. if test x$have_miniupnpc = xno; then
  505. if test x$use_upnp = xyes; then
  506. AC_MSG_ERROR("UPnP requested but cannot be built. use --without-miniupnpc")
  507. fi
  508. AC_MSG_RESULT(no)
  509. else
  510. if test x$use_upnp != xno; then
  511. AC_MSG_RESULT(yes)
  512. AC_MSG_CHECKING([whether to build with UPnP enabled by default])
  513. use_upnp=yes
  514. upnp_setting=0
  515. if test x$use_upnp_default != xno; then
  516. use_upnp_default=yes
  517. upnp_setting=1
  518. fi
  519. AC_MSG_RESULT($use_upnp_default)
  520. AC_DEFINE_UNQUOTED([USE_UPNP],[$upnp_setting],[UPnP support not compiled if undefined, otherwise value (0 or 1) determines default state])
  521. if test x$TARGET_OS = xwindows; then
  522. CPPFLAGS="$CPPFLAGS -DSTATICLIB"
  523. fi
  524. else
  525. AC_MSG_RESULT(no)
  526. fi
  527. fi
  528. dnl these are only used when qt is enabled
  529. if test x$bitcoin_enable_qt != xno; then
  530. BUILD_QT=qt
  531. dnl enable dbus support
  532. AC_MSG_CHECKING([whether to build GUI with support for D-Bus])
  533. if test x$bitcoin_enable_qt_dbus != xno; then
  534. AC_DEFINE([USE_DBUS],[1],[Define if dbus support should be compiled in])
  535. fi
  536. AC_MSG_RESULT($bitcoin_enable_qt_dbus)
  537. dnl enable qr support
  538. AC_MSG_CHECKING([whether to build GUI with support for QR codes])
  539. if test x$have_qrencode = xno; then
  540. if test x$use_qr == xyes; then
  541. AC_MSG_ERROR("QR support requested but cannot be built. use --without-qrencode")
  542. fi
  543. AC_MSG_RESULT(no)
  544. else
  545. if test x$use_qr != xno; then
  546. AC_MSG_RESULT(yes)
  547. AC_DEFINE([USE_QRCODE],[1],[Define if QR support should be compiled in])
  548. use_qr=yes
  549. else
  550. AC_MSG_RESULT(no)
  551. fi
  552. fi
  553. if test x$XGETTEXT == x; then
  554. AC_MSG_WARN("xgettext is required to update qt translations")
  555. fi
  556. AC_MSG_CHECKING([whether to build test_bitcoin-qt])
  557. if test x$use_tests$bitcoin_enable_qt_test = xyesyes; then
  558. AC_MSG_RESULT([yes])
  559. BUILD_TEST_QT="test"
  560. else
  561. AC_MSG_RESULT([no])
  562. fi
  563. fi
  564. AC_MSG_CHECKING([whether to build test_bitcoin])
  565. if test x$use_tests = xyes; then
  566. AC_MSG_RESULT([yes])
  567. BUILD_TEST="test"
  568. else
  569. AC_MSG_RESULT([no])
  570. fi
  571. if test "x$use_tests$build_bitcoind$use_qt" = "xnonono"; then
  572. AC_MSG_ERROR([No targets! Please specify at least one of: --enable-cli --enable-daemon --enable-gui or --enable-tests])
  573. fi
  574. AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin])
  575. AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin])
  576. AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows])
  577. AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet == xyes])
  578. AM_CONDITIONAL([ENABLE_TESTS],[test x$use_tests == xyes])
  579. AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt == xyes])
  580. AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$use_tests$bitcoin_enable_qt_test = xyesyes])
  581. AM_CONDITIONAL([USE_QRCODE], [test x$use_qr = xyes])
  582. AM_CONDITIONAL([USE_LCOV],[test x$use_lcov == xyes])
  583. AM_CONDITIONAL([USE_COMPARISON_TOOL],[test x$use_comparison_tool != xno])
  584. AM_CONDITIONAL([USE_COMPARISON_TOOL_REORG_TESTS],[test x$use_comparison_tool_reorg_test != xno])
  585. AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes])
  586. AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
  587. AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])
  588. AC_DEFINE(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION, [Build revision])
  589. AC_DEFINE(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD, [Version Build])
  590. AC_DEFINE(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE, [Version is release])
  591. AC_DEFINE(COPYRIGHT_YEAR, _COPYRIGHT_YEAR, [Version is release])
  592. AC_SUBST(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR)
  593. AC_SUBST(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR)
  594. AC_SUBST(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION)
  595. AC_SUBST(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD)
  596. AC_SUBST(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE)
  597. AC_SUBST(COPYRIGHT_YEAR, _COPYRIGHT_YEAR)
  598. AC_SUBST(USE_UPNP)
  599. AC_SUBST(USE_QRCODE)
  600. AC_SUBST(INCLUDES)
  601. AC_SUBST(BOOST_LIBS)
  602. AC_SUBST(TESTDEFS)
  603. AC_SUBST(LEVELDB_TARGET_FLAGS)
  604. AC_SUBST(BUILD_TEST)
  605. AC_SUBST(BUILD_QT)
  606. AC_SUBST(BUILD_TEST_QT)
  607. AC_CONFIG_FILES([Makefile src/Makefile share/setup.nsi share/qt/Info.plist])
  608. AC_CONFIG_FILES([qa/pull-tester/run-bitcoind-for-test.sh],[chmod +x qa/pull-tester/run-bitcoind-for-test.sh])
  609. AC_CONFIG_FILES([qa/pull-tester/build-tests.sh],[chmod +x qa/pull-tester/build-tests.sh])
  610. AC_OUTPUT