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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  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, 8)
  5. define(_CLIENT_VERSION_REVISION, 99)
  6. define(_CLIENT_VERSION_BUILD, 0)
  7. define(_CLIENT_VERSION_IS_RELEASE, false)
  8. define(_COPYRIGHT_YEAR, 2013)
  9. AC_INIT([Bitcoin],[_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. dnl ==============================================================
  25. dnl Setup for automake
  26. dnl ==============================================================
  27. AM_INIT_AUTOMAKE([no-define subdir-objects foreign])
  28. dnl faketime messes with timestamps and causes configure to be re-run.
  29. dnl --disable-maintainer-mode can be used to bypass this.
  30. AM_MAINTAINER_MODE([enable])
  31. dnl make the compilation flags quiet unless V=1 is used
  32. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  33. AC_ARG_WITH([miniupnpc],
  34. [AS_HELP_STRING([--with-miniupnpc],
  35. [enable UPNP (default is yes if libminiupnpc is found)])],
  36. [use_upnp=$withval],
  37. [use_upnp=auto])
  38. AC_ARG_ENABLE([upnp-default],
  39. [AS_HELP_STRING([--enable-upnp-default],
  40. [if UPNP is enabled, turn it on at startup (default is no)])],
  41. [use_upnp_default=$enableval],
  42. [use_upnp_default=no])
  43. dnl enable ipv6 support
  44. AC_ARG_ENABLE([ipv6],
  45. [AS_HELP_STRING([--enable-ipv6],
  46. [enable ipv6 (default is yes)])],
  47. [use_ipv6=$enableval],
  48. [use_ipv6=yes])
  49. dnl enable qt support
  50. AC_ARG_WITH([qt],
  51. [AS_HELP_STRING([--with-qt],
  52. [enable qt (default is yes)])],
  53. [use_qt=$withval],
  54. [use_qt=yes])
  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_WITH([qtdbus],
  73. [AS_HELP_STRING([--with-qtdbus],
  74. [enable DBus support (default is yes if qt is enabled and QtDBus is found)])],
  75. [use_dbus=$withval],
  76. [use_dbus=auto])
  77. AC_ARG_ENABLE([hardening],
  78. [AS_HELP_STRING([--enable-hardening],
  79. [attempt to harden the resulting executables (default is yes)])],
  80. [use_hardening=$enableval],
  81. [use_hardening=yes])
  82. AC_ARG_ENABLE([ccache],
  83. [AS_HELP_STRING([--enable-ccache],
  84. [enable building with ccache (default is yes if ccache is found)])],
  85. [use_ccache=$enableval],
  86. [use_ccache=auto])
  87. AC_ARG_ENABLE([lcov],
  88. [AS_HELP_STRING([--enable-lcov],
  89. [enable lcov testing (default is no)])],
  90. [use_lcov=yes],
  91. [use_lcov=no])
  92. AC_ARG_WITH([qt-incdir],[AS_HELP_STRING([--with-qt-incdir=INC_DIR],[specify qt include path (overridden by pkgconfig)])], [qt_include_path=$withval], [])
  93. AC_ARG_WITH([qt-libdir],[AS_HELP_STRING([--with-qt-libdir=LIB_DIR],[specify qt lib path (overridden by pkgconfig)])], [qt_lib_path=$withval], [])
  94. AC_ARG_WITH([qt-bindir],[AS_HELP_STRING([--with-qt-bindir=BIN_DIR],[specify qt bin path])], [qt_bin_path=$withval], [])
  95. AC_ARG_WITH([qt-plugindir],[AS_HELP_STRING([--with-qt-plugindir=PLUGIN_DIR],[specify qt plugin path (overridden by pkgconfig)])], [qt_plugin_path=$withval], [])
  96. AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], [])
  97. AC_CONFIG_SRCDIR([src])
  98. AC_CONFIG_HEADERS([src/bitcoin-config.h])
  99. dnl Checks for programs.
  100. AC_PROG_CXX
  101. AC_PROG_CC
  102. AC_PROG_CPP
  103. AC_PROG_CXXCPP
  104. AC_PROG_INSTALL
  105. AC_PROG_OBJC
  106. m4_ifdef([AC_PROG_OBJCXX],[AC_PROG_OBJCXX])
  107. AC_PROG_MKDIR_P
  108. AC_PROG_SED
  109. AC_PATH_TOOL(AR, ar)
  110. AC_PATH_TOOL(RANLIB, ranlib)
  111. AC_PATH_TOOL(STRIP, strip)
  112. AC_PATH_TOOL(GCOV, gcov)
  113. AC_PATH_PROG(LCOV, lcov)
  114. AC_PATH_PROG(JAVA, java)
  115. AC_PATH_PROG(GENHTML, genhtml)
  116. AC_PATH_PROG([GIT], [git])
  117. AC_PATH_PROGS([MOC], [moc-qt4 moc4 moc],, $qt_bin_path:$PATH)
  118. AC_PATH_PROGS([UIC], [uic-qt4 uic4 uic],, $qt_bin_path:$PATH)
  119. AC_PATH_PROGS([RCC], [rcc-qt4 rcc4 rcc],, $qt_bin_path:$PATH)
  120. AC_PATH_PROGS([LRELEASE], [lrelease-qt4 lrelease4 lrelease],, $qt_bin_path:$PATH)
  121. AC_PATH_PROGS([LUPDATE], [lupdate-qt4 lupdate4 lupdate],, $qt_bin_path:$PATH)
  122. AC_PATH_PROG([PROTOC], [protoc],, $protoc_bin_path:$PATH)
  123. AC_PATH_PROG(CCACHE,ccache)
  124. AC_PATH_PROG(XGETTEXT,xgettext)
  125. AC_PATH_PROG(HEXDUMP,hexdump)
  126. PKG_PROG_PKG_CONFIG
  127. ## TODO: Remove these hard-coded paths and flags. They are here for the sake of
  128. ## compatibility with the legacy buildsystem.
  129. ##
  130. CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter"
  131. CPPFLAGS="$CPPFLAGS -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
  132. AC_LANG_PUSH([C++])
  133. use_pkgconfig=yes
  134. case $host in
  135. *mingw*)
  136. #pkgconfig does more harm than good with MinGW
  137. use_pkgconfig=no
  138. TARGET_OS=windows
  139. AC_CHECK_LIB([mingwthrd], [main],, AC_MSG_ERROR(lib missing))
  140. AC_CHECK_LIB([kernel32], [main],, AC_MSG_ERROR(lib missing))
  141. AC_CHECK_LIB([user32], [main],, AC_MSG_ERROR(lib missing))
  142. AC_CHECK_LIB([gdi32], [main],, AC_MSG_ERROR(lib missing))
  143. AC_CHECK_LIB([comdlg32], [main],, AC_MSG_ERROR(lib missing))
  144. AC_CHECK_LIB([winspool], [main],, AC_MSG_ERROR(lib missing))
  145. AC_CHECK_LIB([winmm], [main],, AC_MSG_ERROR(lib missing))
  146. AC_CHECK_LIB([shell32], [main],, AC_MSG_ERROR(lib missing))
  147. AC_CHECK_LIB([comctl32], [main],, AC_MSG_ERROR(lib missing))
  148. AC_CHECK_LIB([ole32], [main],, AC_MSG_ERROR(lib missing))
  149. AC_CHECK_LIB([oleaut32], [main],, AC_MSG_ERROR(lib missing))
  150. AC_CHECK_LIB([uuid], [main],, AC_MSG_ERROR(lib missing))
  151. AC_CHECK_LIB([rpcrt4], [main],, AC_MSG_ERROR(lib missing))
  152. AC_CHECK_LIB([advapi32], [main],, AC_MSG_ERROR(lib missing))
  153. AC_CHECK_LIB([ws2_32], [main],, AC_MSG_ERROR(lib missing))
  154. AC_CHECK_LIB([mswsock], [main],, AC_MSG_ERROR(lib missing))
  155. AC_CHECK_LIB([shlwapi], [main],, AC_MSG_ERROR(lib missing))
  156. AC_CHECK_LIB([iphlpapi], [main],, AC_MSG_ERROR(lib missing))
  157. AC_CHECK_LIB([crypt32], [main],, AC_MSG_ERROR(lib missing))
  158. AX_CHECK_LINK_FLAG([[-static-libgcc]],[LDFLAGS="$LDFLAGS -static-libgcc"])
  159. AX_CHECK_LINK_FLAG([[-static-libstdc++]],[LDFLAGS="$LDFLAGS -static-libstdc++"])
  160. AC_PATH_PROG([MAKENSIS], [makensis], none)
  161. if test x$MAKENSIS = xnone; then
  162. AC_MSG_WARN("makensis not found. Cannot create installer.")
  163. fi
  164. AC_PATH_TOOL(WINDRES, windres, none)
  165. if test x$WINDRES = xnone; then
  166. AC_MSG_ERROR("windres not found")
  167. fi
  168. CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB"
  169. LEVELDB_TARGET_FLAGS="TARGET_OS=OS_WINDOWS_CROSSCOMPILE"
  170. CXXFLAGS="$CXXFLAGS -w"
  171. ;;
  172. *darwin*)
  173. TARGET_OS=darwin
  174. LEVELDB_TARGET_FLAGS="TARGET_OS=Darwin"
  175. if test x$cross_compiling != xyes; then
  176. AC_CHECK_PROG([PORT],port, port)
  177. if test x$PORT = xport; then
  178. dnl add default macports paths
  179. CPPFLAGS="$CPPFLAGS -I/opt/local/include -I/opt/local/include/db48"
  180. LIBS="$LIBS -L/opt/local/lib -L/opt/local/lib/db48"
  181. fi
  182. AC_CHECK_PROG([BREW],brew, brew)
  183. if test x$BREW = xbrew; then
  184. dnl add default homebrew paths
  185. openssl_prefix=`$BREW --prefix openssl`
  186. bdb_prefix=`$BREW --prefix berkeley-db4`
  187. export PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
  188. CPPFLAGS="$CPPFLAGS -I$bdb_prefix/include"
  189. LIBS="$LIBS -L/$bdb_prefix/lib"
  190. fi
  191. fi
  192. if test x$use_qt = xyes; then
  193. MOC_DEFS="-DQ_OS_MAC"
  194. base_frameworks="-framework Foundation -framework ApplicationServices -framework AppKit"
  195. AX_CHECK_LINK_FLAG([[$base_frameworks]],[LIBS="$LIBS $base_frameworks"],[AC_MSG_ERROR(could not find base frameworks)])
  196. fi
  197. CPPFLAGS="$CPPFLAGS -DMAC_OSX"
  198. TESTDEFS="-DBOOST_TEST_DYN_LINK"
  199. ;;
  200. *)
  201. TESTDEFS="-DBOOST_TEST_DYN_LINK"
  202. ;;
  203. esac
  204. if test x$use_comparison_tool != xno; then
  205. AC_SUBST(JAVA_COMPARISON_TOOL, $use_comparison_tool)
  206. fi
  207. if test x$use_comparison_tool_reorg_tests != xno; then
  208. if test x$use_comparison_tool == x; then
  209. AC_MSG_ERROR("comparison tool reorg tests but comparison tool was not specified")
  210. fi
  211. AC_SUBST(COMPARISON_TOOL_REORG_TESTS, 1)
  212. else
  213. AC_SUBST(COMPARISON_TOOL_REORG_TESTS, 0)
  214. fi
  215. if test x$use_lcov == xyes; then
  216. if test x$LCOV == x; then
  217. AC_MSG_ERROR("lcov testing requested but lcov not found")
  218. fi
  219. if test x$GCOV == x; then
  220. AC_MSG_ERROR("lcov testing requested but gcov not found")
  221. fi
  222. if test x$JAVA == x; then
  223. AC_MSG_ERROR("lcov testing requested but java not found")
  224. fi
  225. if test x$GENHTML == x; then
  226. AC_MSG_ERROR("lcov testing requested but genhtml not found")
  227. fi
  228. if test x$use_comparison_tool == x; then
  229. AC_MSG_ERROR("lcov testing requested but comparison tool was not specified")
  230. fi
  231. LCOV="$LCOV --gcov-tool=$GCOV"
  232. AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"],
  233. [AC_MSG_ERROR("lcov testing requested but --coverage flag does not work")])
  234. fi
  235. dnl Require little endian
  236. AC_C_BIGENDIAN([AC_MSG_ERROR("Big Endian not supported")])
  237. dnl Check for pthread compile/link requirements
  238. AX_PTHREAD
  239. INCLUDES="$INCLUDES $PTHREAD_CFLAGS"
  240. # The following macro will add the necessary defines to bitcoin-config.h, but
  241. # they also need to be passed down to any subprojects. Pull the results out of
  242. # the cache and add them to CPPFLAGS.
  243. AC_SYS_LARGEFILE
  244. if test x$ac_cv_sys_file_offset_bits != x &&
  245. test x$ac_cv_sys_file_offset_bits != xno &&
  246. test x$ac_cv_sys_file_offset_bits != xunknown; then
  247. CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
  248. fi
  249. if test x$ac_cv_sys_large_files != x &&
  250. test x$ac_cv_sys_large_files != xno &&
  251. test x$ac_cv_sys_large_files != xunknown; then
  252. CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files"
  253. fi
  254. AX_CHECK_LINK_FLAG([[-Wl,--large-address-aware]], [LDFLAGS="$LDFLAGS -Wl,--large-address-aware"])
  255. if test x$use_hardening != xno; then
  256. AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"])
  257. AX_CHECK_COMPILE_FLAG([-fPIE],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fPIE"])
  258. AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2"])
  259. AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"])
  260. AX_CHECK_LINK_FLAG([[-Wl,--nxcompat]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"])
  261. AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [LDFLAGS="-Wl,-z,relro"])
  262. AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [LDFLAGS="-Wl,-z,now"])
  263. if test x$TARGET_OS != xwindows; then
  264. # -fstack-protector-all can produce broken binaries with mingw
  265. AX_CHECK_COMPILE_FLAG([-fno-stack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fno-stack-protector"])
  266. AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"])
  267. # -pie will link successfully with MinGW, but it's unsupported and leads to undeterministic binaries
  268. AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"])
  269. fi
  270. CXXFLAGS="$CXXFLAGS $HARDENED_CXXFLAGS"
  271. CPPFLAGS="$CPPFLAGS $HARDENED_CPPFLAGS"
  272. LDFLAGS="$LDFLAGS $HARDENED_LDFLAGS"
  273. OBJCXXFLAGS="$CXXFLAGS"
  274. fi
  275. dnl this flag screws up non-darwin gcc even when the check fails. special-case it.
  276. if test x$TARGET_OS = xdarwin; then
  277. AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"])
  278. fi
  279. AC_CHECK_HEADERS([stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h])
  280. dnl Check for MSG_NOSIGNAL
  281. AC_MSG_CHECKING(for MSG_NOSIGNAL)
  282. AC_TRY_COMPILE([#include <sys/socket.h>],
  283. [ int f = MSG_NOSIGNAL; ],
  284. [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MSG_NOSIGNAL, 1,[Define this symbol if you have MSG_NOSIGNAL]) ],
  285. [ AC_MSG_RESULT(no)]
  286. )
  287. dnl Check for libdb_cxx
  288. BITCOIN_FIND_BDB48
  289. dnl Check for libminiupnpc (optional)
  290. if test x$use_upnp != xno; then
  291. AC_CHECK_LIB([miniupnpc], [main],, [have_miniupnpc=no])
  292. fi
  293. dnl Check for boost libs
  294. AX_BOOST_BASE
  295. AX_BOOST_SYSTEM
  296. AX_BOOST_FILESYSTEM
  297. AX_BOOST_PROGRAM_OPTIONS
  298. AX_BOOST_THREAD
  299. AX_BOOST_CHRONO
  300. if test x$use_tests = xyes; then
  301. if test x$HEXDUMP = x; then
  302. AC_MSG_ERROR(hexdump is required for tests)
  303. fi
  304. AX_BOOST_UNIT_TEST_FRAMEWORK
  305. fi
  306. BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB"
  307. BOOST_INCLUDES="$BOOST_CPPFLAGS"
  308. dnl Boost >= 1.50 uses sleep_for rather than the now-deprecated sleep, however
  309. dnl it was broken from 1.50 to 1.52 when backed by nanosleep. Use sleep_for if
  310. dnl a working version is available, else fall back to sleep. sleep was removed
  311. dnl after 1.56.
  312. dnl If neither is available, abort.
  313. dnl If sleep_for is used, boost_chrono becomes a requirement.
  314. if test x$ax_cv_boost_chrono = xyes; then
  315. TEMP_LIBS="$LIBS"
  316. LIBS="$LIBS $BOOST_LIBS $BOOST_CHRONO_LIB"
  317. AC_TRY_LINK([
  318. #include <boost/thread/thread.hpp>
  319. #include <boost/version.hpp>
  320. ],[
  321. #if BOOST_VERSION >= 105000 && (!defined(BOOST_HAS_NANOSLEEP) || BOOST_VERSION >= 105200)
  322. boost::this_thread::sleep_for(boost::chrono::milliseconds(0));
  323. #else
  324. choke me
  325. #endif
  326. ],
  327. [boost_sleep=yes; BOOST_LIBS="$BOOST_LIBS $BOOST_CHRONO_LIB";
  328. AC_DEFINE(HAVE_WORKING_BOOST_SLEEP_FOR, 1, [Define this symbol if boost sleep_for works])],
  329. [boost_sleep=no])
  330. LIBS="$TEMP_LIBS"
  331. fi
  332. if test x$boost_sleep != xyes; then
  333. TEMP_LIBS="$LIBS"
  334. LIBS="$LIBS $BOOST_LIBS"
  335. AC_TRY_LINK([
  336. #include <boost/version.hpp>
  337. #include <boost/thread.hpp>
  338. #include <boost/date_time/posix_time/posix_time_types.hpp>
  339. ],[
  340. #if BOOST_VERSION <= 105600
  341. boost::this_thread::sleep(boost::posix_time::milliseconds(0));
  342. #else
  343. choke me
  344. #endif
  345. ],
  346. [boost_sleep=yes; AC_DEFINE(HAVE_WORKING_BOOST_SLEEP, 1, [Define this symbol if boost sleep works])],
  347. [boost_sleep=no])
  348. LIBS="$TEMP_LIBS"
  349. fi
  350. if test x$boost_sleep != xyes; then
  351. AC_MSG_ERROR(No working boost sleep implementation found)
  352. fi
  353. if test x$use_pkgconfig = xyes; then
  354. if test x$PKG_CONFIG == x; then
  355. AC_MSG_ERROR(pkg-config not found.)
  356. fi
  357. : #NOP
  358. m4_ifdef(
  359. [PKG_CHECK_MODULES],
  360. [
  361. PKG_CHECK_MODULES([SSL], [libssl], [INCLUDES="$INCLUDES $SSL_CFLAGS"; LIBS="$LIBS $SSL_LIBS"], [AC_MSG_ERROR(openssl not found.)])
  362. PKG_CHECK_MODULES([CRYPTO], [libcrypto], [INCLUDES="$INCLUDES $CRYPTO_CFLAGS"; LIBS="$LIBS $CRYPTO_LIBS"], [AC_MSG_ERROR(libcrypto not found.)])
  363. if test x$use_qt = xyes; then
  364. PKG_CHECK_MODULES([QT], [QtCore QtGui QtNetwork], [QT_INCLUDES="$QT_CFLAGS"; have_qt=yes], [have_qt=no])
  365. if test x$use_tests = xyes; then
  366. PKG_CHECK_MODULES([QT_TEST], [QtTest], [QT_TEST_INCLUDES="$QT_TEST_CFLAGS"; have_qt_test=yes], [have_qt_test=no])
  367. fi
  368. if test x$use_dbus != xno; then
  369. PKG_CHECK_MODULES([QT_DBUS], [QtDBus], [QT_DBUS_INCLUDES="$QT_DBUS_CFLAGS"; have_qt_dbus=yes], [have_qt_dbus=no])
  370. fi
  371. if test x$use_qr != xno; then
  372. PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])
  373. fi
  374. PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [AC_MSG_ERROR(libprotobuf not found.)])
  375. fi
  376. ]
  377. )
  378. else
  379. AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing))
  380. AC_CHECK_LIB([crypto], [main],, AC_MSG_ERROR(libcrypto missing))
  381. AC_CHECK_HEADER([openssl/ssl.h],, AC_MSG_ERROR(libssl headers missing),)
  382. AC_CHECK_LIB([ssl], [main],, AC_MSG_ERROR(libssl missing))
  383. if test x$use_qt = xyes; then
  384. TEMP_LIBS="$LIBS"
  385. LIBS=
  386. if test x$qt_lib_path != x; then
  387. QT_LIBS="$QT_LIBS -L$qt_lib_path"
  388. LIBS="$QT_LIBS"
  389. fi
  390. if test x$qt_plugin_path != x; then
  391. QT_LIBS="$QT_LIBS -L$qt_plugin_path/codecs"
  392. LIBS="$QT_LIBS"
  393. fi
  394. if test x$TARGET_OS == xwindows; then
  395. AC_CHECK_LIB([imm32], [main],, AC_MSG_ERROR(libimm32 not found. Install it or use --without-qt.))
  396. fi
  397. #TODO: These are only needed when they're linked directly to parent libs. It really has nothing to do with windows.
  398. #Instead, check for missing functions in parent libs and assume static if they're absent.
  399. if test x$TARGET_OS == xwindows; then
  400. AC_CHECK_LIB([qcncodecs], [main],, AC_MSG_ERROR(libqcncodecs not found. Install it or use --without-qt.))
  401. AC_CHECK_LIB([qjpcodecs], [main],, AC_MSG_ERROR(libqjpcodecs not found. Install it or use --without-qt.))
  402. AC_CHECK_LIB([qkrcodecs], [main],, AC_MSG_ERROR(libqkrcodecs not found. Install it or use --without-qt.))
  403. AC_CHECK_LIB([qtwcodecs], [main],, AC_MSG_ERROR(libqtwcodecs not found. Install it or use --without-qt.))
  404. fi
  405. AC_CHECK_LIB([QtCore], [main],, AC_MSG_ERROR(libQtCore not found. Install it or use --without-qt.))
  406. AC_CHECK_LIB([QtGui], [main],, AC_MSG_ERROR(libQtGui not found. Install it or use --without-qt.))
  407. AC_CHECK_LIB([QtNetwork], [main],, AC_MSG_ERROR(libQtNetwork not found. Install it or use --without-qt.))
  408. AC_CHECK_LIB([protobuf], [main],, AC_MSG_ERROR(libprotobuf not found. Install it or use --without-qt.))
  409. QT_LIBS="$LIBS"
  410. LIBS="$TEMP_LIBS"
  411. TEMP_CPPFLAGS="$CPPFLAGS"
  412. if test x$qt_include_path != x; then
  413. QT_INCLUDES="-I$qt_include_path -I$qt_include_path/QtCore -I$qt_include_path/QtGui -I$qt_include_path/QtNetwork -I$qt_include_path/QtTest -I$qt_include_path/QtDBus"
  414. CPPFLAGS="$CPPFLAGS $QT_INCLUDES"
  415. fi
  416. AC_CHECK_HEADER([QtPlugin],, AC_MSG_ERROR(QtCore headers missing. Install them or use --without-qt.),)
  417. AC_CHECK_HEADER([QApplication],, AC_MSG_ERROR(QtGUI headers missing. Install them or use --without-qt.),)
  418. AC_CHECK_HEADER([QLocalSocket],, AC_MSG_ERROR(QtNetwork headers missing. Install them or use --without-qt.),)
  419. if test x$use_tests = xyes; then
  420. TEMP_LIBS="$LIBS"
  421. LIBS=
  422. if test x$qt_lib_path != x; then
  423. LIBS="-L$qt_lib_path"
  424. fi
  425. AC_CHECK_LIB([QtTest], [main],, have_qt_test=no)
  426. AC_CHECK_HEADER([QTest],, have_qt_test=no)
  427. QT_TEST_LIBS="$LIBS"
  428. LIBS="$TEMP_LIBS"
  429. fi
  430. if test x$use_dbus != xno; then
  431. TEMP_LIBS="$LIBS"
  432. LIBS=
  433. if test x$qt_lib_path != x; then
  434. LIBS="-L$qt_lib_path"
  435. fi
  436. AC_CHECK_LIB([QtDBus], [main],, have_qt_dbus=no)
  437. AC_CHECK_HEADER([QtDBus],, have_qt_dbus=no)
  438. QT_DBUS_LIBS="$LIBS"
  439. LIBS="$TEMP_LIBS"
  440. fi
  441. CPPFLAGS="$TEMP_CPPFLAGS"
  442. if test x$use_qr != xno; then
  443. AC_CHECK_LIB([qrencode], [main],, [have_qrencode=no])
  444. AC_CHECK_HEADER([qrencode.h],, have_qrencode=no)
  445. fi
  446. fi
  447. fi
  448. if test x$use_ipv6 = xyes; then
  449. dnl Check for ipv6 build requirements
  450. AC_MSG_CHECKING(for IPV6 build support)
  451. AC_TRY_LINK([
  452. #if defined(_WINDOWS)
  453. #include <winsock2.h>
  454. #else
  455. #include <sys/types.h>
  456. #include <sys/socket.h>
  457. #include <netinet/in.h>
  458. #endif
  459. ],[
  460. #if !defined(_WINDOWS)
  461. struct in6_addr ipv6Addr;
  462. struct sockaddr_in6 addr;
  463. #endif
  464. int temp = socket(AF_INET6, SOCK_STREAM, 0);],
  465. [AC_MSG_RESULT(yes); have_ipv6=yes; AC_DEFINE(HAVE_IPV6, 1, [Define this symbol if you have ipv6 build support])],
  466. [AC_MSG_RESULT(no)]; have_ipv6=no)
  467. fi
  468. AC_LANG_POP
  469. if test "x$use_ccache" != "xno"; then
  470. AC_MSG_CHECKING(if ccache should be enabled)
  471. if test x$CCACHE = x; then
  472. if test "x$use_ccache" = "xyes"; then
  473. AC_MSG_ERROR([ccache not found.]);
  474. else
  475. AC_MSG_NOTICE([ccache not found. Falling back to default CC])
  476. use_ccache=no
  477. fi
  478. else
  479. use_ccache=yes
  480. CC="$ac_cv_path_CCACHE $CC"
  481. CXX="$ac_cv_path_CCACHE $CXX"
  482. fi
  483. AC_MSG_RESULT($use_ccache)
  484. fi
  485. dnl enable ipv6 support
  486. AC_MSG_CHECKING([if ipv6 should be enabled])
  487. if test x$have_ipv6 = xno; then
  488. if test x$use_ipv6 = xyes; then
  489. AC_MSG_ERROR("ipv6 requested but cannot be built. use --disable-ipv6")
  490. fi
  491. AC_MSG_RESULT(no)
  492. else
  493. if test x$use_ipv6 = xyes; then
  494. AC_MSG_RESULT(yes)
  495. AC_DEFINE([USE_IPV6],[1],[Define if ipv6 support should be compiled in])
  496. else
  497. AC_MSG_RESULT(no)
  498. fi
  499. fi
  500. dnl enable upnp support
  501. AC_MSG_CHECKING([if upnp should be enabled])
  502. if test x$have_miniupnpc = xno; then
  503. if test x$use_upnp = xyes; then
  504. AC_MSG_ERROR("upnp requested but cannot be built. use --without-miniupnpc")
  505. fi
  506. AC_MSG_RESULT(no)
  507. else
  508. if test x$use_upnp != xno; then
  509. AC_MSG_RESULT(yes)
  510. AC_MSG_CHECKING([if upnp should be on by default])
  511. use_upnp=yes
  512. upnp_setting=0
  513. if test x$use_upnp_default != xno; then
  514. use_upnp_default=yes
  515. upnp_setting=1
  516. fi
  517. AC_MSG_RESULT($use_upnp_default)
  518. AC_DEFINE_UNQUOTED([USE_UPNP],[$upnp_setting],[Define to 1 for upnp runtime support])
  519. if test x$TARGET_OS = xwindows; then
  520. CPPFLAGS="$CPPFLAGS -DSTATICLIB"
  521. fi
  522. else
  523. AC_MSG_RESULT(no)
  524. fi
  525. fi
  526. dnl enable qt support
  527. AC_MSG_CHECKING([if qt should be enabled])
  528. if test x$use_qt = xyes; then
  529. if test x$have_qt = xno; then
  530. AC_MSG_ERROR("qt support requested but qt could not be located. use --without-qt")
  531. fi
  532. if test x$MOC = x; then
  533. AC_MSG_ERROR("qt support requested but moc was not found. use --without-qt")
  534. fi
  535. if test x$PROTOC = x; then
  536. AC_MSG_ERROR("qt support requested but protoc was not found. use --without-qt")
  537. fi
  538. if test x$UIC = x; then
  539. AC_MSG_ERROR("qt support requested but uic was not found. use --without-qt")
  540. fi
  541. if test x$RCC = x; then
  542. AC_MSG_ERROR("qt support requested but rcc was not found. use --without-qt")
  543. fi
  544. if test x$LRELEASE = x; then
  545. AC_MSG_ERROR("qt support requested but lrelease was not found. use --without-qt")
  546. fi
  547. if test x$use_tests = xyes; then
  548. if test x$have_qt_test = xno; then
  549. AC_MSG_ERROR("libQtTest not found. Use --disable-tests or --without-qt.")
  550. fi
  551. fi
  552. if test x$have_qt_dbus = xno; then
  553. use_dbus=no
  554. if test x$use_dbus = xyes; then
  555. AC_MSG_ERROR("libQtDBus not found. Use --without-qtdbus.")
  556. fi
  557. fi
  558. if test x$XGETTEXT == x; then
  559. AC_MSG_WARN("xgettext is required to update qt translations")
  560. fi
  561. if test x$LUPDATE == x; then
  562. AC_MSG_WARN("lupdate is required to update qt translations")
  563. fi
  564. BUILD_QT=qt
  565. else
  566. use_qt=no
  567. fi
  568. AC_MSG_RESULT($use_qt)
  569. dnl these are only used when qt is enabled
  570. if test x$use_qt = xyes; then
  571. dnl enable dbus support
  572. AC_MSG_CHECKING([if dbus should be enabled])
  573. if test x$use_dbus != xno; then
  574. use_dbus=yes
  575. AC_DEFINE([USE_DBUS],[1],[Define if dbus support should be compiled in])
  576. else
  577. use_dbus=no
  578. fi
  579. AC_MSG_RESULT($use_dbus)
  580. dnl enable qr support
  581. AC_MSG_CHECKING([if qr should be enabled])
  582. if test x$have_qrencode = xno; then
  583. if test x$use_qr == xyes; then
  584. AC_MSG_ERROR("QR support requested but cannot be built. use --without-qrencode")
  585. fi
  586. AC_MSG_RESULT(no)
  587. else
  588. if test x$use_qr != xno; then
  589. AC_MSG_RESULT(yes)
  590. AC_DEFINE([USE_QRCODE],[1],[Define if QR support should be compiled in])
  591. use_qr=yes
  592. else
  593. AC_MSG_RESULT(no)
  594. fi
  595. fi
  596. if test x$use_tests = xyes; then
  597. BUILD_TEST_QT="test"
  598. fi
  599. fi
  600. if test x$use_tests = xyes; then
  601. BUILD_TEST="test"
  602. fi
  603. AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin])
  604. AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows])
  605. AM_CONDITIONAL([USE_QRCODE], [test x$use_qr = xyes])
  606. AM_CONDITIONAL([USE_LCOV],[test x$use_lcov == xyes])
  607. AM_CONDITIONAL([USE_COMPARISON_TOOL],[test x$use_comparison_tool != xno])
  608. AM_CONDITIONAL([USE_COMPARISON_TOOL_REORG_TESTS],[test x$use_comparison_tool_reorg_test != xno])
  609. AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
  610. AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])
  611. AC_DEFINE(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION, [Build revision])
  612. AC_DEFINE(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD, [Version Build])
  613. AC_DEFINE(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE, [Version is release])
  614. AC_DEFINE(COPYRIGHT_YEAR, _COPYRIGHT_YEAR, [Version is release])
  615. AC_SUBST(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR)
  616. AC_SUBST(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR)
  617. AC_SUBST(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION)
  618. AC_SUBST(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD)
  619. AC_SUBST(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE)
  620. AC_SUBST(COPYRIGHT_YEAR, _COPYRIGHT_YEAR)
  621. AC_SUBST(USE_UPNP)
  622. AC_SUBST(USE_QRCODE)
  623. AC_SUBST(USE_IPV6)
  624. AC_SUBST(INCLUDES)
  625. AC_SUBST(BOOST_LIBS)
  626. AC_SUBST(MOC_DEFS)
  627. AC_SUBST(QT_INCLUDES)
  628. AC_SUBST(QT_TEST_LIBS)
  629. AC_SUBST(QT_LIBS)
  630. AC_SUBST(QT_DBUS_LIBS)
  631. AC_SUBST(QT_DBUS_INCLUDES)
  632. AC_SUBST(QT_TEST_INCLUDES)
  633. AC_SUBST(TESTDEFS)
  634. AC_SUBST(LEVELDB_TARGET_FLAGS)
  635. AC_SUBST(BUILD_QT)
  636. AC_SUBST(BUILD_TEST)
  637. AC_SUBST(BUILD_TEST_QT)
  638. AC_CONFIG_FILES([Makefile src/Makefile src/test/Makefile src/qt/Makefile src/qt/test/Makefile share/setup.nsi share/qt/Info.plist])
  639. AC_CONFIG_FILES([qa/pull-tester/run-bitcoind-for-test.sh],[chmod +x qa/pull-tester/run-bitcoind-for-test.sh])
  640. AC_CONFIG_FILES([qa/pull-tester/build-tests.sh],[chmod +x qa/pull-tester/build-tests.sh])
  641. AC_OUTPUT