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