]>
Commit | Line | Data |
---|---|---|
35b8af92 CF |
1 | dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) |
2 | AC_PREREQ([2.60]) | |
f6908714 A |
3 | define(_CLIENT_VERSION_MAJOR, 2) |
4 | define(_CLIENT_VERSION_MINOR, 0) | |
eb4370fc A |
5 | define(_CLIENT_VERSION_REVISION, 7) |
6 | define(_CLIENT_VERSION_BUILD, 53) | |
6fe11af7 JG |
7 | define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50))) |
8 | define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1))) | |
998202ba | 9 | define(_CLIENT_VERSION_IS_RELEASE, true) |
167adf70 | 10 | define(_COPYRIGHT_YEAR, 2019) |
058156b8 | 11 | AC_INIT([Verus-CLI],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_SUFFIX(_ZC_BUILD_VAL)],[https://github.com/VerusCoin/VerusCoin/issues],[verus-cli]) |
e5438111 | 12 | AC_CONFIG_SRCDIR([src/main.cpp]) |
13 | AC_CONFIG_HEADERS([src/config/bitcoin-config.h]) | |
52a5f903 | 14 | AC_CONFIG_AUX_DIR([build-aux]) |
15 | AC_CONFIG_MACRO_DIR([build-aux/m4]) | |
1723862e | 16 | |
5915430d AD |
17 | BITCOIN_DAEMON_NAME=verusd |
18 | BITCOIN_CLI_NAME=verus | |
19 | BITCOIN_TX_NAME=verus-tx | |
c5d645e2 | 20 | |
bc9fff11 RN |
21 | dnl Unless the user specified ARFLAGS, force it to be cr |
22 | AC_ARG_VAR(ARFLAGS, [Flags for the archiver, defaults to <cr> if not set]) | |
23 | if test "x${ARFLAGS+set}" != "xset"; then | |
24 | ARFLAGS="cr" | |
25 | fi | |
26 | ||
35b8af92 | 27 | AC_CANONICAL_HOST |
1723862e | 28 | |
35b8af92 CF |
29 | AH_TOP([#ifndef BITCOIN_CONFIG_H]) |
30 | AH_TOP([#define BITCOIN_CONFIG_H]) | |
31 | AH_BOTTOM([#endif //BITCOIN_CONFIG_H]) | |
32 | ||
35b8af92 CF |
33 | dnl faketime breaks configure and is only needed for make. Disable it here. |
34 | unset FAKETIME | |
35 | ||
eefb766c | 36 | dnl Automake init set-up and checks |
051698a0 | 37 | AM_INIT_AUTOMAKE([no-define subdir-objects foreign tar-pax]) |
35b8af92 CF |
38 | |
39 | dnl faketime messes with timestamps and causes configure to be re-run. | |
40 | dnl --disable-maintainer-mode can be used to bypass this. | |
41 | AM_MAINTAINER_MODE([enable]) | |
42 | ||
43 | dnl make the compilation flags quiet unless V=1 is used | |
44 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) | |
45 | ||
eefb766c | 46 | dnl Compiler checks (here before libtool). |
47 | if test "x${CXXFLAGS+set}" = "xset"; then | |
48 | CXXFLAGS_overridden=yes | |
49 | else | |
50 | CXXFLAGS_overridden=no | |
51 | fi | |
c4da0970 | 52 | |
52a5f903 | 53 | AC_PROG_CXX |
52a5f903 | 54 | m4_ifdef([AC_PROG_OBJCXX],[AC_PROG_OBJCXX]) |
eefb766c | 55 | |
56 | dnl By default, libtool for mingw refuses to link static libs into a dll for | |
57 | dnl fear of mixing pic/non-pic objects, and import/export complications. Since | |
58 | dnl we have those under control, re-enable that functionality. | |
59 | case $host in | |
60 | *mingw*) | |
61 | lt_cv_deplibs_check_method="pass_all" | |
62 | ;; | |
63 | esac | |
4ba17236 | 64 | dnl Require C++11 compiler (no GNU extensions) |
943f19fe | 65 | AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory], [nodefault]) |
d812d95a AT |
66 | dnl Check if -latomic is required for <std::atomic> |
67 | CHECK_ATOMIC | |
68 | ||
eefb766c | 69 | dnl Libtool init checks. |
19df238a | 70 | LT_INIT([pic-only]) |
eefb766c | 71 | |
72 | dnl Check/return PATH for base programs. | |
52a5f903 | 73 | AC_PATH_TOOL(AR, ar) |
74 | AC_PATH_TOOL(RANLIB, ranlib) | |
75 | AC_PATH_TOOL(STRIP, strip) | |
76 | AC_PATH_TOOL(GCOV, gcov) | |
77 | AC_PATH_PROG(LCOV, lcov) | |
52a5f903 | 78 | AC_PATH_PROG(GENHTML, genhtml) |
79 | AC_PATH_PROG([GIT], [git]) | |
80 | AC_PATH_PROG(CCACHE,ccache) | |
81 | AC_PATH_PROG(XGETTEXT,xgettext) | |
82 | AC_PATH_PROG(HEXDUMP,hexdump) | |
56734f4b TH |
83 | AC_PATH_TOOL(READELF,readelf) |
84 | AC_PATH_TOOL(CPPFILT,c++filt) | |
eefb766c | 85 | |
4f9e993b WL |
86 | # Enable wallet |
87 | AC_ARG_ENABLE([wallet], | |
88 | [AS_HELP_STRING([--enable-wallet], | |
89 | [enable wallet (default is yes)])], | |
90 | [enable_wallet=$enableval], | |
91 | [enable_wallet=yes]) | |
92 | ||
2cc0a252 JG |
93 | AC_ARG_ENABLE([mining], |
94 | [AS_HELP_STRING([--enable-mining], | |
95 | [enable mining (default is yes)])], | |
96 | [enable_mining=$enableval], | |
97 | [enable_mining=yes]) | |
98 | ||
99eb947a S |
99 | AC_ARG_ENABLE([proton], |
100 | [AS_HELP_STRING([--disable-proton], | |
101 | [disable Proton (AMQP messaging)])], | |
102 | [use_proton=$enableval], | |
103 | [use_proton=yes]) | |
35b8af92 | 104 | |
35b8af92 CF |
105 | AC_ARG_ENABLE(tests, |
106 | AS_HELP_STRING([--enable-tests],[compile tests (default is yes)]), | |
107 | [use_tests=$enableval], | |
108 | [use_tests=yes]) | |
109 | ||
c4379e3a JG |
110 | AC_ARG_ENABLE([asan], |
111 | [AS_HELP_STRING([--enable-asan], | |
112 | [instrument the executables with asan (default is no)])], | |
113 | [use_asan=$enableval], | |
114 | [use_asan=no]) | |
35b8af92 | 115 | |
c4379e3a JG |
116 | AC_ARG_ENABLE([tsan], |
117 | [AS_HELP_STRING([--enable-tsan], | |
118 | [instrument the executables with tsan (default is no)])], | |
119 | [use_tsan=$enableval], | |
120 | [use_tsan=no]) | |
47b9374e | 121 | |
9d365796 | 122 | if test x$TARGET_OS = xdarwin; then |
35b8af92 CF |
123 | AC_ARG_ENABLE([hardening], |
124 | [AS_HELP_STRING([--enable-hardening], | |
125 | [attempt to harden the resulting executables (default is yes)])], | |
126 | [use_hardening=$enableval], | |
e891d64b | 127 | [use_hardening=no]) |
9d365796 | 128 | else |
129 | AC_ARG_ENABLE([hardening], | |
130 | [AS_HELP_STRING([--enable-hardening], | |
131 | [attempt to harden the resulting executables (default is yes)])], | |
132 | [use_hardening=$enableval], | |
133 | [use_hardening=yes]) | |
134 | fi | |
135 | ||
e432a5f0 CF |
136 | AC_ARG_ENABLE([reduce-exports], |
137 | [AS_HELP_STRING([--enable-reduce-exports], | |
3ee028f1 | 138 | [attempt to reduce exported symbols in the resulting executables (default is no)])], |
e432a5f0 | 139 | [use_reduce_exports=$enableval], |
3ee028f1 | 140 | [use_reduce_exports=no]) |
e432a5f0 | 141 | |
35b8af92 CF |
142 | AC_ARG_ENABLE([ccache], |
143 | [AS_HELP_STRING([--enable-ccache], | |
e18e1001 | 144 | [use ccache for building (default is yes if ccache is found)])], |
35b8af92 CF |
145 | [use_ccache=$enableval], |
146 | [use_ccache=auto]) | |
147 | ||
148 | AC_ARG_ENABLE([lcov], | |
149 | [AS_HELP_STRING([--enable-lcov], | |
150 | [enable lcov testing (default is no)])], | |
151 | [use_lcov=yes], | |
152 | [use_lcov=no]) | |
153 | ||
d5aab704 CF |
154 | AC_ARG_ENABLE([glibc-back-compat], |
155 | [AS_HELP_STRING([--enable-glibc-back-compat], | |
aa367306 | 156 | [enable backwards compatibility with glibc])], |
d5aab704 CF |
157 | [use_glibc_compat=$enableval], |
158 | [use_glibc_compat=no]) | |
159 | ||
f200002c | 160 | AC_ARG_ENABLE([zmq], |
1afb8431 | 161 | [AS_HELP_STRING([--disable-zmq], |
162 | [disable ZMQ notifications])], | |
f200002c JG |
163 | [use_zmq=$enableval], |
164 | [use_zmq=yes]) | |
165 | ||
35b8af92 CF |
166 | AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], []) |
167 | ||
abfcaefe | 168 | AC_ARG_ENABLE(man, |
1b5e712c | 169 | [AS_HELP_STRING([--disable-man], |
170 | [do not install man pages (default is to install)])],, | |
abfcaefe | 171 | enable_man=yes) |
172 | AM_CONDITIONAL(ENABLE_MAN, test "$enable_man" != no) | |
173 | ||
b197605e | 174 | # Enable debug |
f5f157b8 | 175 | AC_ARG_ENABLE([debug], |
176 | [AS_HELP_STRING([--enable-debug], | |
177 | [use debug compiler flags and macros (default is no)])], | |
178 | [enable_debug=$enableval], | |
179 | [enable_debug=no]) | |
180 | ||
5dd887fd CF |
181 | # Turn warnings into errors |
182 | AC_ARG_ENABLE([werror], | |
183 | [AS_HELP_STRING([--enable-werror], | |
c1fcdd01 | 184 | [Treat all compiler warnings as errors (default is no)])], |
5dd887fd CF |
185 | [enable_werror=$enableval], |
186 | [enable_werror=no]) | |
187 | ||
341ab745 CF |
188 | AC_LANG_PUSH([C++]) |
189 | AX_CHECK_COMPILE_FLAG([-Werror],[CXXFLAG_WERROR="-Werror"],[CXXFLAG_WERROR=""]) | |
190 | ||
f5f157b8 | 191 | if test "x$enable_debug" = xyes; then |
ae1565b5 | 192 | CPPFLAGS="$CPPFLAGS -DDEBUG -DDEBUG_LOCKORDER" |
f5f157b8 | 193 | if test "x$GCC" = xyes; then |
ae1565b5 | 194 | CFLAGS="$CFLAGS -g3 -O0" |
f5f157b8 | 195 | fi |
b197605e | 196 | |
f5f157b8 | 197 | if test "x$GXX" = xyes; then |
ae1565b5 | 198 | CXXFLAGS="$CXXFLAGS -g3 -O0" |
f5f157b8 | 199 | fi |
b197605e | 200 | fi |
f5f157b8 | 201 | |
5dd887fd CF |
202 | ERROR_CXXFLAGS= |
203 | if test "x$enable_werror" = "xyes"; then | |
204 | if test "x$CXXFLAG_WERROR" = "x"; then | |
205 | AC_MSG_ERROR("enable-werror set but -Werror is not usable") | |
206 | fi | |
c1fcdd01 | 207 | ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror" |
5dd887fd CF |
208 | fi |
209 | ||
123e4f87 | 210 | if test "x$CXXFLAGS_overridden" = "xno"; then |
341ab745 CF |
211 | AX_CHECK_COMPILE_FLAG([-Wall],[CXXFLAGS="$CXXFLAGS -Wall"],,[[$CXXFLAG_WERROR]]) |
212 | AX_CHECK_COMPILE_FLAG([-Wextra],[CXXFLAGS="$CXXFLAGS -Wextra"],,[[$CXXFLAG_WERROR]]) | |
213 | AX_CHECK_COMPILE_FLAG([-Wformat],[CXXFLAGS="$CXXFLAGS -Wformat"],,[[$CXXFLAG_WERROR]]) | |
d35ebc7b | 214 | AX_CHECK_COMPILE_FLAG([-Wvla],[CXXFLAGS="$CXXFLAGS -Wvla"],,[[$CXXFLAG_WERROR]]) |
341ab745 CF |
215 | AX_CHECK_COMPILE_FLAG([-Wformat-security],[CXXFLAGS="$CXXFLAGS -Wformat-security"],,[[$CXXFLAG_WERROR]]) |
216 | ||
217 | ## Some compilers (gcc) ignore unknown -Wno-* options, but warn about all | |
218 | ## unknown options if any other warning is produced. Test the -Wfoo case, and | |
219 | ## set the -Wno-foo case if it works. | |
220 | AX_CHECK_COMPILE_FLAG([-Wunused-parameter],[CXXFLAGS="$CXXFLAGS -Wno-unused-parameter"],,[[$CXXFLAG_WERROR]]) | |
221 | AX_CHECK_COMPILE_FLAG([-Wself-assign],[CXXFLAGS="$CXXFLAGS -Wno-self-assign"],,[[$CXXFLAG_WERROR]]) | |
222 | AX_CHECK_COMPILE_FLAG([-Wunused-local-typedef],[CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"],,[[$CXXFLAG_WERROR]]) | |
223 | AX_CHECK_COMPILE_FLAG([-Wdeprecated-register],[CXXFLAGS="$CXXFLAGS -Wno-deprecated-register"],,[[$CXXFLAG_WERROR]]) | |
123e4f87 | 224 | fi |
55fca515 | 225 | CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS" |
35b8af92 | 226 | |
b7a4ecc1 LD |
227 | AC_ARG_WITH([utils], |
228 | [AS_HELP_STRING([--with-utils], | |
5915430d | 229 | [build verus verus-tx wallet-utility (default=yes)])], |
b7a4ecc1 LD |
230 | [build_bitcoin_utils=$withval], |
231 | [build_bitcoin_utils=yes]) | |
232 | ||
233 | AC_ARG_WITH([libs], | |
234 | [AS_HELP_STRING([--with-libs], | |
47fe5f72 | 235 | [build libraries (default=no)])], |
b7a4ecc1 | 236 | [build_bitcoin_libs=$withval], |
47fe5f72 | 237 | [build_bitcoin_libs=no]) |
b7a4ecc1 LD |
238 | |
239 | AC_ARG_WITH([daemon], | |
240 | [AS_HELP_STRING([--with-daemon], | |
241 | [build bitcoind daemon (default=yes)])], | |
242 | [build_bitcoind=$withval], | |
243 | [build_bitcoind=yes]) | |
244 | ||
2d338362 C |
245 | GCC_TARGET=`$CC -dumpmachine 2>&1` |
246 | case $GCC_TARGET in | |
247 | arm*-*-*) | |
248 | have_arm=true | |
249 | ;; | |
250 | aarch64*-*-*) | |
251 | have_arm=true | |
252 | ;; | |
253 | esac | |
254 | ||
35b8af92 CF |
255 | use_pkgconfig=yes |
256 | case $host in | |
257 | *mingw*) | |
258 | ||
96b9603c | 259 | #pkgconfig does more harm than good with MinGW |
35b8af92 CF |
260 | use_pkgconfig=no |
261 | ||
262 | TARGET_OS=windows | |
263 | AC_CHECK_LIB([mingwthrd], [main],, AC_MSG_ERROR(lib missing)) | |
264 | AC_CHECK_LIB([kernel32], [main],, AC_MSG_ERROR(lib missing)) | |
265 | AC_CHECK_LIB([user32], [main],, AC_MSG_ERROR(lib missing)) | |
266 | AC_CHECK_LIB([gdi32], [main],, AC_MSG_ERROR(lib missing)) | |
267 | AC_CHECK_LIB([comdlg32], [main],, AC_MSG_ERROR(lib missing)) | |
268 | AC_CHECK_LIB([winspool], [main],, AC_MSG_ERROR(lib missing)) | |
269 | AC_CHECK_LIB([winmm], [main],, AC_MSG_ERROR(lib missing)) | |
270 | AC_CHECK_LIB([shell32], [main],, AC_MSG_ERROR(lib missing)) | |
271 | AC_CHECK_LIB([comctl32], [main],, AC_MSG_ERROR(lib missing)) | |
272 | AC_CHECK_LIB([ole32], [main],, AC_MSG_ERROR(lib missing)) | |
273 | AC_CHECK_LIB([oleaut32], [main],, AC_MSG_ERROR(lib missing)) | |
274 | AC_CHECK_LIB([uuid], [main],, AC_MSG_ERROR(lib missing)) | |
275 | AC_CHECK_LIB([rpcrt4], [main],, AC_MSG_ERROR(lib missing)) | |
276 | AC_CHECK_LIB([advapi32], [main],, AC_MSG_ERROR(lib missing)) | |
277 | AC_CHECK_LIB([ws2_32], [main],, AC_MSG_ERROR(lib missing)) | |
278 | AC_CHECK_LIB([mswsock], [main],, AC_MSG_ERROR(lib missing)) | |
279 | AC_CHECK_LIB([shlwapi], [main],, AC_MSG_ERROR(lib missing)) | |
280 | AC_CHECK_LIB([iphlpapi], [main],, AC_MSG_ERROR(lib missing)) | |
c589f5f2 CF |
281 | AC_CHECK_LIB([crypt32], [main],, AC_MSG_ERROR(lib missing)) |
282 | ||
575e70c0 CF |
283 | # -static is interpreted by libtool, where it has a different meaning. |
284 | # In libtool-speak, it's -all-static. | |
e0077de5 | 285 | AX_CHECK_LINK_FLAG([[-static]],[LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static"]) |
575e70c0 | 286 | |
35b8af92 CF |
287 | AC_PATH_PROG([MAKENSIS], [makensis], none) |
288 | if test x$MAKENSIS = xnone; then | |
289 | AC_MSG_WARN("makensis not found. Cannot create installer.") | |
290 | fi | |
291 | ||
5ceb9c96 CF |
292 | AC_PATH_TOOL(WINDRES, windres, none) |
293 | if test x$WINDRES = xnone; then | |
294 | AC_MSG_ERROR("windres not found") | |
295 | fi | |
296 | ||
b77dfdc9 | 297 | CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB" |
35b8af92 | 298 | LEVELDB_TARGET_FLAGS="TARGET_OS=OS_WINDOWS_CROSSCOMPILE" |
123e4f87 LD |
299 | if test "x$CXXFLAGS_overridden" = "xno"; then |
300 | CXXFLAGS="$CXXFLAGS -w" | |
301 | fi | |
2f87b38e WL |
302 | case $host in |
303 | i?86-*) WINDOWS_BITS=32 ;; | |
304 | x86_64-*) WINDOWS_BITS=64 ;; | |
305 | *) AC_MSG_ERROR("Could not determine win32/win64 for installer") ;; | |
306 | esac | |
307 | AC_SUBST(WINDOWS_BITS) | |
9ed8979e CF |
308 | |
309 | dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against. | |
310 | dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override | |
311 | dnl its command here, with the predeps/postdeps removed, and -static inserted. Postdeps are | |
312 | dnl also overridden to prevent their insertion later. | |
313 | dnl This should only affect dll's. | |
314 | archive_cmds_CXX="\$CC -shared \$libobjs \$deplibs \$compiler_flags -static -o \$output_objdir/\$soname \${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib" | |
315 | postdeps_CXX= | |
316 | ||
35b8af92 CF |
317 | ;; |
318 | *darwin*) | |
319 | TARGET_OS=darwin | |
320 | LEVELDB_TARGET_FLAGS="TARGET_OS=Darwin" | |
321 | if test x$cross_compiling != xyes; then | |
b62bbb1f | 322 | BUILD_OS=darwin |
35b8af92 CF |
323 | AC_CHECK_PROG([PORT],port, port) |
324 | if test x$PORT = xport; then | |
325 | dnl add default macports paths | |
4c69ebed PJ |
326 | CPPFLAGS="$CPPFLAGS -isystem /opt/local/include" |
327 | LIBS="$LIBS -L/opt/local/lib" | |
9cb7abaf DH |
328 | if test -d /opt/local/include/db62; then |
329 | CPPFLAGS="$CPPFLAGS -I/opt/local/include/db62" | |
330 | LIBS="$LIBS -L/opt/local/lib/db62" | |
4c69ebed | 331 | fi |
35b8af92 CF |
332 | fi |
333 | ||
e891d64b JB |
334 | dnl AC_CHECK_PROG([BREW],brew, brew) |
335 | dnl if test x$BREW = xbrew; then | |
9d365796 | 336 | dnl These Homebrew packages may be keg-only, meaning that they won't be found |
337 | dnl in expected paths because they may conflict with system files. Ask | |
338 | dnl Homebrew where each one is located, then adjust paths accordingly. | |
339 | dnl It's safe to add these paths even if the functionality is disabled by | |
340 | dnl the user (--without-wallet for example). | |
9fedafba | 341 | |
e891d64b JB |
342 | dnl openssl_prefix=`$BREW --prefix openssl 2>/dev/null` |
343 | dnl bdb_prefix=`$BREW --prefix berkeley-db4 2>/dev/null` | |
344 | dnl qt5_prefix=`$BREW --prefix qt5 2>/dev/null` | |
345 | dnl if test x$openssl_prefix != x; then | |
346 | dnl PKG_CONFIG_PATH="$PKG_CONFIG_PATH" | |
347 | dnl export PKG_CONFIG_PATH | |
348 | dnl fi | |
349 | dnl if test x$bdb_prefix != x; then | |
350 | dnl CPPFLAGS="$CPPFLAGS -I$bdb_prefix/include" | |
351 | dnl LIBS="$LIBS -L$bdb_prefix/lib" | |
352 | dnl fi | |
353 | dnl if test x$qt5_prefix != x; then | |
354 | dnl PKG_CONFIG_PATH="$qt5_prefix/lib/pkgconfig:$PKG_CONFIG_PATH" | |
355 | dnl export PKG_CONFIG_PATH | |
356 | dnl fi | |
357 | dnl fi | |
b62bbb1f CF |
358 | else |
359 | case $build_os in | |
360 | *darwin*) | |
361 | BUILD_OS=darwin | |
362 | ;; | |
363 | *) | |
364 | AC_PATH_TOOL([INSTALLNAMETOOL], [install_name_tool], install_name_tool) | |
365 | AC_PATH_TOOL([OTOOL], [otool], otool) | |
366 | AC_PATH_PROGS([GENISOIMAGE], [genisoimage mkisofs],genisoimage) | |
b7f2cdc8 CF |
367 | |
368 | dnl libtool will try to strip the static lib, which is a problem for | |
369 | dnl cross-builds because strip attempts to call a hard-coded ld, | |
370 | dnl which may not exist in the path. Stripping the .a is not | |
371 | dnl necessary, so just disable it. | |
372 | old_striplib= | |
b62bbb1f CF |
373 | ;; |
374 | esac | |
35b8af92 CF |
375 | fi |
376 | ||
9eb5a5fb | 377 | AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"]) |
35b8af92 | 378 | CPPFLAGS="$CPPFLAGS -DMAC_OSX" |
c459de2f | 379 | OBJCXXFLAGS="$CXXFLAGS" |
35b8af92 | 380 | ;; |
ab123ad4 CF |
381 | *linux*) |
382 | TARGET_OS=linux | |
383 | ;; | |
35b8af92 | 384 | *) |
35b8af92 CF |
385 | ;; |
386 | esac | |
387 | ||
d7002714 CF |
388 | if test x$use_pkgconfig = xyes; then |
389 | m4_ifndef([PKG_PROG_PKG_CONFIG], [AC_MSG_ERROR(PKG_PROG_PKG_CONFIG macro not found. Please install pkg-config and re-run autogen.sh.)]) | |
390 | m4_ifdef([PKG_PROG_PKG_CONFIG], [ | |
391 | PKG_PROG_PKG_CONFIG | |
392 | if test x"$PKG_CONFIG" = "x"; then | |
393 | AC_MSG_ERROR(pkg-config not found.) | |
47b9374e | 394 | fi |
d7002714 | 395 | ]) |
47b9374e MC |
396 | fi |
397 | ||
b77b4eda LD |
398 | if test x$use_lcov = xyes; then |
399 | if test x$LCOV = x; then | |
35b8af92 CF |
400 | AC_MSG_ERROR("lcov testing requested but lcov not found") |
401 | fi | |
b77b4eda | 402 | if test x$GCOV = x; then |
35b8af92 CF |
403 | AC_MSG_ERROR("lcov testing requested but gcov not found") |
404 | fi | |
b77b4eda | 405 | if test x$GENHTML = x; then |
35b8af92 CF |
406 | AC_MSG_ERROR("lcov testing requested but genhtml not found") |
407 | fi | |
6ecb05dd JG |
408 | LCOV="$LCOV --gcov-tool=$GCOV --rc lcov_branch_coverage=1" |
409 | GENHTML="$GENHTML --branch-coverage" | |
35b8af92 CF |
410 | AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"], |
411 | [AC_MSG_ERROR("lcov testing requested but --coverage flag does not work")]) | |
412 | fi | |
413 | ||
4414f5ff WL |
414 | dnl Check for endianness |
415 | AC_C_BIGENDIAN | |
35b8af92 CF |
416 | |
417 | dnl Check for pthread compile/link requirements | |
418 | AX_PTHREAD | |
35b8af92 CF |
419 | |
420 | # The following macro will add the necessary defines to bitcoin-config.h, but | |
421 | # they also need to be passed down to any subprojects. Pull the results out of | |
422 | # the cache and add them to CPPFLAGS. | |
423 | AC_SYS_LARGEFILE | |
a60838d0 WL |
424 | # detect POSIX or GNU variant of strerror_r |
425 | AC_FUNC_STRERROR_R | |
35b8af92 CF |
426 | |
427 | if test x$ac_cv_sys_file_offset_bits != x && | |
428 | test x$ac_cv_sys_file_offset_bits != xno && | |
429 | test x$ac_cv_sys_file_offset_bits != xunknown; then | |
430 | CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits" | |
431 | fi | |
432 | ||
433 | if test x$ac_cv_sys_large_files != x && | |
434 | test x$ac_cv_sys_large_files != xno && | |
435 | test x$ac_cv_sys_large_files != xunknown; then | |
436 | CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files" | |
437 | fi | |
438 | ||
439 | AX_CHECK_LINK_FLAG([[-Wl,--large-address-aware]], [LDFLAGS="$LDFLAGS -Wl,--large-address-aware"]) | |
440 | ||
f36a40f7 CF |
441 | AX_GCC_FUNC_ATTRIBUTE([visibility]) |
442 | AX_GCC_FUNC_ATTRIBUTE([dllexport]) | |
443 | AX_GCC_FUNC_ATTRIBUTE([dllimport]) | |
444 | ||
d5aab704 CF |
445 | if test x$use_glibc_compat != xno; then |
446 | ||
d68e2111 CF |
447 | #glibc absorbed clock_gettime in 2.17. librt (its previous location) is safe to link |
448 | #in anyway for back-compat. | |
449 | AC_CHECK_LIB([rt],[clock_gettime],, AC_MSG_ERROR(lib missing)) | |
450 | ||
d5aab704 CF |
451 | #__fdelt_chk's params and return type have changed from long unsigned int to long int. |
452 | # See which one is present here. | |
453 | AC_MSG_CHECKING(__fdelt_chk type) | |
e2a98d27 | 454 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef _FORTIFY_SOURCE |
8021cf8d CF |
455 | #undef _FORTIFY_SOURCE |
456 | #endif | |
457 | #define _FORTIFY_SOURCE 2 | |
d5aab704 | 458 | #include <sys/select.h> |
e2a98d27 | 459 | extern "C" long unsigned int __fdelt_warn(long unsigned int);]],[[]])], |
d5aab704 CF |
460 | [ fdelt_type="long unsigned int"], |
461 | [ fdelt_type="long int"]) | |
462 | AC_MSG_RESULT($fdelt_type) | |
463 | AC_DEFINE_UNQUOTED(FDELT_TYPE, $fdelt_type,[parameter and return value type for __fdelt_chk]) | |
d68e2111 CF |
464 | else |
465 | AC_SEARCH_LIBS([clock_gettime],[rt]) | |
d5aab704 CF |
466 | fi |
467 | ||
c459de2f CF |
468 | if test x$TARGET_OS != xwindows; then |
469 | # All windows code is PIC, forcing it on just adds useless compile warnings | |
470 | AX_CHECK_COMPILE_FLAG([-fPIC],[PIC_FLAGS="-fPIC"]) | |
471 | fi | |
472 | ||
c4379e3a JG |
473 | #asan and tsan cannot be used together |
474 | if test x$use_asan$use_tsan == xyesyes; then | |
475 | AC_MSG_ERROR(asan and tsan cannot be simultaneously enabled) | |
476 | fi | |
477 | ||
478 | # using asan flag to enable address sanitizer and undefined behavior sanitizer | |
479 | if test x$use_asan == xyes; then | |
480 | AX_CHECK_LINK_FLAG([-static-libstdc++],[SAN_LDFLAGS="$SAN_LDFLAGS -static-libstdc++"],[AC_MSG_ERROR(Cannot statically link -static-libstdc++)]) | |
481 | AX_CHECK_LINK_FLAG([-static-libasan],[SAN_LDFLAGS="$SAN_LDFLAGS -static-libasan"],[AC_MSG_ERROR(Cannot statically link -static-libasan)]) | |
482 | AX_CHECK_COMPILE_FLAG([-fsanitize=address],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fsanitize=address"],[AC_MSG_ERROR(Cannot enable -fsanitize=address)]) | |
483 | AX_CHECK_COMPILE_FLAG([-fsanitize=undefined],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fsanitize=undefined"],[AC_MSG_ERROR(Cannot enable -fsanitize=undefined)]) | |
484 | AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fno-omit-frame-pointer"],[AC_MSG_ERROR(Cannot enable -fno-omit-frame-pointer)]) | |
485 | fi | |
486 | ||
487 | # using tsan flag to enable address thread sanitizer | |
488 | # TSAN is supported on Linux x84_64 and tested on Ubuntu 12.04 | |
489 | # Non-position-independent executables are not supported. Use with -fPIE and -pie flags | |
490 | # libc/libstdc++ static linking is not supported | |
491 | if test x$use_tsan == xyes; then | |
492 | AX_CHECK_COMPILE_FLAG([-fsanitize=thread],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fsanitize=thread"],[AC_MSG_ERROR(Cannot enable -fsanitize=thread)]) | |
493 | AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fno-omit-frame-pointer"],[AC_MSG_ERROR(Cannot enable -fno-omit-frame-pointer)]) | |
494 | fi | |
495 | ||
35b8af92 | 496 | if test x$use_hardening != xno; then |
5d37904b | 497 | AX_CHECK_COMPILE_FLAG([-Wformat],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wformat"],[AC_MSG_ERROR(Cannot enable -Wformat)]) |
6dcb7067 | 498 | AX_CHECK_COMPILE_FLAG([-Wformat-security],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wformat-security"],[AC_MSG_ERROR(Cannot enable -Wformat-security)],[-Wformat]) |
b00b98ae TH |
499 | AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"],[AC_MSG_ERROR(Cannot enable -Wstack-protector)]) |
500 | AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"],[AC_MSG_ERROR(Cannot enable -fstack-protector-all)]) | |
35b8af92 | 501 | |
9b4e03b2 LD |
502 | AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[ |
503 | AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[ | |
504 | HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE" | |
b00b98ae | 505 | ],[AC_MSG_ERROR(Cannot enable -U_FORTIFY_SOURCE)]) |
9b4e03b2 | 506 | HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2" |
b00b98ae | 507 | ],[AC_MSG_ERROR(Cannot enable -D_FORTIFY_SOURCE=2)]) |
35b8af92 | 508 | |
01ea54be | 509 | #AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_ERROR(Cannot enable RELRO)]) |
510 | #AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_ERROR(Cannot enable BIND_NOW)]) | |
35b8af92 CF |
511 | |
512 | if test x$TARGET_OS != xwindows; then | |
eccd5856 | 513 | # All windows code is PIC, forcing it on just adds useless compile warnings |
9d365796 | 514 | AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_ERROR(Cannot enable RELRO)]) |
515 | AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_ERROR(Cannot enable BIND_NOW)]) | |
b00b98ae TH |
516 | AX_CHECK_COMPILE_FLAG([-fPIE],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fPIE"],[AC_MSG_ERROR(Cannot enable -fPIE)]) |
517 | AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"],[AC_MSG_ERROR(Cannot enable -pie)]) | |
518 | else | |
519 | # These are only available on Windows. | |
520 | AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"],[AC_MSG_ERROR(Cannot enable --dynamicbase)]) | |
521 | AX_CHECK_LINK_FLAG([[-Wl,--nxcompat]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"],[AC_MSG_ERROR(Cannot enable --nxcompat)]) | |
8a932154 | 522 | AX_CHECK_LINK_FLAG([[-Wl,--high-entropy-va]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--high-entropy-va"],[AC_MSG_ERROR(Cannot enable ASLR)]) |
35b8af92 CF |
523 | fi |
524 | ||
811a765b CF |
525 | case $host in |
526 | *mingw*) | |
527 | AC_CHECK_LIB([ssp], [main],, AC_MSG_ERROR(lib missing)) | |
528 | ;; | |
529 | esac | |
35b8af92 CF |
530 | fi |
531 | ||
532 | dnl this flag screws up non-darwin gcc even when the check fails. special-case it. | |
533 | if test x$TARGET_OS = xdarwin; then | |
534 | AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"]) | |
535 | fi | |
536 | ||
8ea6d37a | 537 | AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h]) |
caf6150e HL |
538 | AC_SEARCH_LIBS([getaddrinfo_a], [anl], [AC_DEFINE(HAVE_GETADDRINFO_A, 1, [Define this symbol if you have getaddrinfo_a])]) |
539 | AC_SEARCH_LIBS([inet_pton], [nsl resolv], [AC_DEFINE(HAVE_INET_PTON, 1, [Define this symbol if you have inet_pton])]) | |
f2647cc0 | 540 | |
494f6e7d PJ |
541 | AC_CHECK_DECLS([strnlen]) |
542 | ||
4414f5ff | 543 | AC_CHECK_DECLS([le16toh, le32toh, le64toh, htole16, htole32, htole64, be16toh, be32toh, be64toh, htobe16, htobe32, htobe64],,, |
f2647cc0 CF |
544 | [#if HAVE_ENDIAN_H |
545 | #include <endian.h> | |
8ea6d37a AV |
546 | #elif HAVE_SYS_ENDIAN_H |
547 | #include <sys/endian.h> | |
f2647cc0 | 548 | #endif]) |
35b8af92 | 549 | |
4414f5ff WL |
550 | AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64],,, |
551 | [#if HAVE_BYTESWAP_H | |
552 | #include <byteswap.h> | |
553 | #endif]) | |
554 | ||
35b8af92 CF |
555 | dnl Check for MSG_NOSIGNAL |
556 | AC_MSG_CHECKING(for MSG_NOSIGNAL) | |
e2a98d27 | 557 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]], |
558 | [[ int f = MSG_NOSIGNAL; ]])], | |
35b8af92 CF |
559 | [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MSG_NOSIGNAL, 1,[Define this symbol if you have MSG_NOSIGNAL]) ], |
560 | [ AC_MSG_RESULT(no)] | |
561 | ) | |
562 | ||
e432a5f0 CF |
563 | AC_MSG_CHECKING([for visibility attribute]) |
564 | AC_LINK_IFELSE([AC_LANG_SOURCE([ | |
565 | int foo_def( void ) __attribute__((visibility("default"))); | |
566 | int main(){} | |
567 | ])], | |
568 | [ | |
569 | AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE,1,[Define if the visibility attribute is supported.]) | |
570 | AC_MSG_RESULT(yes) | |
571 | ], | |
572 | [ | |
573 | AC_MSG_RESULT(no) | |
574 | if test x$use_reduce_exports = xyes; then | |
3448b132 | 575 | AC_MSG_ERROR([Cannot find a working visibility attribute. Use --disable-reduce-exports.]) |
e432a5f0 | 576 | fi |
e432a5f0 CF |
577 | ] |
578 | ) | |
579 | ||
3ee028f1 | 580 | if test x$use_reduce_exports = xyes; then |
e432a5f0 | 581 | AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[RE_CXXFLAGS="-fvisibility=hidden"], |
3448b132 | 582 | [AC_MSG_ERROR([Cannot set default symbol visibility. Use --disable-reduce-exports.])]) |
e432a5f0 CF |
583 | fi |
584 | ||
4a290b52 LD |
585 | LEVELDB_CPPFLAGS= |
586 | LIBLEVELDB= | |
587 | LIBMEMENV= | |
588 | AM_CONDITIONAL([EMBEDDED_LEVELDB],[true]) | |
589 | AC_SUBST(LEVELDB_CPPFLAGS) | |
590 | AC_SUBST(LIBLEVELDB) | |
591 | AC_SUBST(LIBMEMENV) | |
592 | ||
4f9e993b WL |
593 | if test x$enable_wallet != xno; then |
594 | dnl Check for libdb_cxx only if wallet enabled | |
9cb7abaf | 595 | BITCOIN_FIND_BDB62 |
4f9e993b | 596 | fi |
35b8af92 | 597 | |
99eb947a S |
598 | dnl Check Qpid Proton headers and library exist |
599 | if test x$use_proton = xyes; then | |
600 | AC_CHECK_HEADERS([proton/connection.hpp], | |
601 | [], | |
602 | [AC_MSG_WARN([Proton headers not found, disabling Proton support]) | |
603 | use_proton=no]) | |
80884769 TH |
604 | AC_CHECK_LIB([qpid-proton-cpp-static], [main], |
605 | [PROTON_LIBS="-lqpid-proton-cpp-static"], | |
606 | [AC_MSG_WARN([Proton qpid-proton-cpp-static library not found, disabling Proton support]) | |
607 | use_proton=no]) | |
608 | AC_CHECK_LIB([qpid-proton-core-static], [main], | |
609 | [PROTON_LIBS+=" -lqpid-proton-core-static"], | |
610 | [AC_MSG_WARN([Proton qpid-proton-core-static library not found, disabling Proton support]) | |
611 | use_proton=no]) | |
612 | AC_CHECK_LIB([qpid-proton-static], [main], | |
613 | [PROTON_LIBS+=" -lqpid-proton-static"], | |
614 | [AC_MSG_WARN([Proton qpid-proton-static library not found, disabling Proton support]) | |
99eb947a S |
615 | use_proton=no]) |
616 | fi | |
617 | if test x$use_proton = xyes; then | |
618 | AC_DEFINE(ENABLE_PROTON, 1, [Define to 1 to enable Proton functions]) | |
619 | else | |
620 | AC_DEFINE(ENABLE_PROTON, 0, [Define to 1 to enable Proton functions]) | |
35b8af92 CF |
621 | fi |
622 | ||
38ba3c66 | 623 | if test x$build_bitcoin_utils$build_bitcoind$use_tests = xnonono; then |
b7a4ecc1 LD |
624 | use_boost=no |
625 | else | |
626 | use_boost=yes | |
627 | fi | |
628 | ||
629 | if test x$use_boost = xyes; then | |
630 | ||
35b8af92 | 631 | dnl Check for boost libs |
6df5f51b | 632 | dnl We need Boost >= 1.62 to fix a potential security bug (https://github.com/zcash/zcash/issues/1241) |
633 | AX_BOOST_BASE([1.62]) | |
35b8af92 CF |
634 | AX_BOOST_SYSTEM |
635 | AX_BOOST_FILESYSTEM | |
636 | AX_BOOST_PROGRAM_OPTIONS | |
637 | AX_BOOST_THREAD | |
638 | AX_BOOST_CHRONO | |
639 | ||
b7a4ecc1 LD |
640 | fi |
641 | ||
3ee028f1 | 642 | if test x$use_reduce_exports = xyes; then |
e432a5f0 CF |
643 | CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS" |
644 | AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]], [RELDFLAGS="-Wl,--exclude-libs,ALL"]) | |
645 | fi | |
646 | ||
35b8af92 | 647 | if test x$use_tests = xyes; then |
152e51c7 CF |
648 | |
649 | if test x$HEXDUMP = x; then | |
650 | AC_MSG_ERROR(hexdump is required for tests) | |
651 | fi | |
652 | ||
653 | ||
b7a4ecc1 LD |
654 | if test x$use_boost = xyes; then |
655 | ||
35b8af92 | 656 | AX_BOOST_UNIT_TEST_FRAMEWORK |
e4b991e5 WL |
657 | |
658 | dnl Determine if -DBOOST_TEST_DYN_LINK is needed | |
659 | AC_MSG_CHECKING([for dynamic linked boost test]) | |
660 | TEMP_LIBS="$LIBS" | |
a7d1f035 | 661 | LIBS="$LIBS $BOOST_LDFLAGS $BOOST_UNIT_TEST_FRAMEWORK_LIB" |
e4b991e5 WL |
662 | TEMP_CPPFLAGS="$CPPFLAGS" |
663 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" | |
664 | AC_LINK_IFELSE([AC_LANG_SOURCE([ | |
665 | #define BOOST_TEST_DYN_LINK | |
666 | #define BOOST_TEST_MAIN | |
667 | #include <boost/test/unit_test.hpp> | |
668 | ||
669 | ])], | |
670 | [AC_MSG_RESULT(yes)] | |
671 | [TESTDEFS="$TESTDEFS -DBOOST_TEST_DYN_LINK"], | |
672 | [AC_MSG_RESULT(no)]) | |
673 | LIBS="$TEMP_LIBS" | |
674 | CPPFLAGS="$TEMP_CPPFLAGS" | |
b7a4ecc1 LD |
675 | |
676 | fi | |
35b8af92 CF |
677 | fi |
678 | ||
b7a4ecc1 | 679 | if test x$use_boost = xyes; then |
ca66717d | 680 | BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB $BOOST_CHRONO_LIB" |
b7a4ecc1 | 681 | fi |
c8ba8ef6 | 682 | |
35b8af92 | 683 | if test x$use_pkgconfig = xyes; then |
d7002714 | 684 | : dnl |
35b8af92 CF |
685 | m4_ifdef( |
686 | [PKG_CHECK_MODULES], | |
687 | [ | |
6b099402 CF |
688 | PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)]) |
689 | PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)]) | |
df377ca8 WL |
690 | if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests != xnononono; then |
691 | PKG_CHECK_MODULES([EVENT], [libevent],, [AC_MSG_ERROR(libevent not found.)]) | |
692 | if test x$TARGET_OS != xwindows; then | |
693 | PKG_CHECK_MODULES([EVENT_PTHREADS], [libevent_pthreads],, [AC_MSG_ERROR(libevent_pthreads not found.)]) | |
694 | fi | |
695 | fi | |
effe8a5f JC |
696 | |
697 | if test "x$use_zmq" = "xyes"; then | |
698 | PKG_CHECK_MODULES([ZMQ],[libzmq >= 4], | |
699 | [AC_DEFINE([ENABLE_ZMQ],[1],[Define to 1 to enable ZMQ functions])], | |
700 | [AC_DEFINE([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions]) | |
701 | AC_MSG_WARN([libzmq version 4.x or greater not found, disabling]) | |
702 | use_zmq=no]) | |
703 | else | |
704 | AC_DEFINE_UNQUOTED([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions]) | |
c8ba8ef6 | 705 | fi |
35b8af92 CF |
706 | ] |
707 | ) | |
708 | else | |
c4da0970 NW |
709 | # BUG: Fix this: |
710 | echo 'BUG: configure does not yet check for the following dependencies if pkg-config is not on the system: libcrypto++, libgmp' | |
711 | ||
35b8af92 | 712 | AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing)) |
6b099402 | 713 | AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing)) |
35b8af92 CF |
714 | |
715 | AC_CHECK_HEADER([openssl/ssl.h],, AC_MSG_ERROR(libssl headers missing),) | |
6b099402 | 716 | AC_CHECK_LIB([ssl], [main],SSL_LIBS=-lssl, AC_MSG_ERROR(libssl missing)) |
35b8af92 | 717 | |
df377ca8 WL |
718 | if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests != xnononono; then |
719 | AC_CHECK_HEADER([event2/event.h],, AC_MSG_ERROR(libevent headers missing),) | |
720 | AC_CHECK_LIB([event],[main],EVENT_LIBS=-levent,AC_MSG_ERROR(libevent missing)) | |
721 | if test x$TARGET_OS != xwindows; then | |
722 | AC_CHECK_LIB([event_pthreads],[main],EVENT_PTHREADS_LIBS=-levent_pthreads,AC_MSG_ERROR(libevent_pthreads missing)) | |
723 | fi | |
724 | fi | |
725 | ||
effe8a5f JC |
726 | if test "x$use_zmq" = "xyes"; then |
727 | AC_CHECK_HEADER([zmq.h], | |
728 | [AC_DEFINE([ENABLE_ZMQ],[1],[Define to 1 to enable ZMQ functions])], | |
729 | [AC_MSG_WARN([zmq.h not found, disabling zmq support]) | |
730 | use_zmq=no | |
731 | AC_DEFINE([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])]) | |
732 | AC_CHECK_LIB([zmq],[zmq_ctx_shutdown],ZMQ_LIBS=-lzmq, | |
733 | [AC_MSG_WARN([libzmq >= 4.0 not found, disabling zmq support]) | |
734 | use_zmq=no | |
735 | AC_DEFINE([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])]) | |
736 | else | |
737 | AC_DEFINE_UNQUOTED([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions]) | |
738 | fi | |
739 | ||
00bcf223 | 740 | if test "x$use_zmq" = "xyes"; then |
741 | dnl Assume libzmq was built for static linking | |
742 | case $host in | |
743 | *mingw*) | |
744 | ZMQ_CFLAGS="$ZMQ_CFLAGS -DZMQ_STATIC" | |
745 | ;; | |
746 | esac | |
c8ba8ef6 CF |
747 | fi |
748 | fi | |
35b8af92 | 749 | |
c4da0970 NW |
750 | # These packages don't provide pkgconfig config files across all |
751 | # platforms, so we use older autoconf detection mechanisms: | |
9d365796 | 752 | if test x$TARGET_OS = xdarwin; then |
c4da0970 NW |
753 | AC_CHECK_HEADER([gmp.h],,AC_MSG_ERROR(libgmp headers missing)) |
754 | AC_CHECK_LIB([gmp],[[__gmpn_sub_n]],GMP_LIBS=-lgmp, [AC_MSG_ERROR(libgmp missing)]) | |
755 | ||
756 | AC_CHECK_HEADER([gmpxx.h],,AC_MSG_ERROR(libgmpxx headers missing)) | |
757 | AC_CHECK_LIB([gmpxx],[main],GMPXX_LIBS=-lgmpxx, [AC_MSG_ERROR(libgmpxx missing)]) | |
9d365796 | 758 | fi |
759 | ||
760 | #AC_CHECK_HEADER([gmp.h],,AC_MSG_ERROR(libgmp headers missing)) | |
761 | #AC_CHECK_LIB([gmp],[[__gmpn_sub_n]],GMP_LIBS=-lgmp, [AC_MSG_ERROR(libgmp missing)]) | |
762 | ||
763 | #AC_CHECK_HEADER([gmpxx.h],,AC_MSG_ERROR(libgmpxx headers missing)) | |
764 | #AC_CHECK_LIB([gmpxx],[main],GMPXX_LIBS=-lgmpxx, [AC_MSG_ERROR(libgmpxx missing)]) | |
c4da0970 | 765 | |
bce69239 JG |
766 | RUST_LIBS="-lrustzcash" |
767 | case $host in | |
768 | *mingw*) | |
769 | ;; | |
770 | *) | |
771 | RUST_LIBS="$RUST_LIBS -ldl" | |
772 | ;; | |
773 | esac | |
802ea76b | 774 | |
daad2c27 JG |
775 | dnl Check for OpenMP support |
776 | AX_OPENMP( | |
777 | [AC_DEFINE(HAVE_OPENMP, 1, [Define if OpenMP is enabled]) | |
778 | AM_CONDITIONAL([HAVE_OPENMP], [true]) | |
7346f090 | 779 | CPPFLAGS="$CPPFLAGS -DMULTICORE" |
daad2c27 JG |
780 | CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"], |
781 | [AC_MSG_WARN([OpenMP not supported, disabling multithreading]) | |
782 | AC_DEFINE(HAVE_OPENMP, 0, [Define if OpenMP is enabled]) | |
783 | AM_CONDITIONAL([HAVE_OPENMP], [false])]) | |
c4da0970 | 784 | |
8f23c734 JG |
785 | # Gitian uses a config.site that sets depends_prefix, and then sets --prefix=/ |
786 | # build.sh just uses --prefix | |
787 | if test x$depends_prefix != x; then | |
788 | LIBSNARK_DEPINST="$depends_prefix" | |
789 | else | |
790 | LIBSNARK_DEPINST="$prefix" | |
791 | fi | |
792 | ||
fb7b9e3f | 793 | # Set optimization flags for libsnark |
8d640081 | 794 | AX_GCC_ARCHFLAG([no], [LIBSNARK_OPTFLAGS="-O2 $ax_cv_gcc_archflag"], [LIBSNARK_OPTFLAGS="-O2"]) |
fb7b9e3f | 795 | |
704337b2 JG |
796 | # Additional Zcash flags |
797 | AX_CHECK_COMPILE_FLAG([-fwrapv],[CXXFLAGS="$CXXFLAGS -fwrapv"]) | |
798 | AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing],[CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"]) | |
799 | AX_CHECK_COMPILE_FLAG([-Wno-builtin-declaration-mismatch],[CXXFLAGS="$CXXFLAGS -Wno-builtin-declaration-mismatch"],,[[$CXXFLAG_WERROR]]) | |
e6e4b619 | 800 | LIBZCASH_LIBS="-lgmp -lgmpxx $BOOST_SYSTEM_LIB -lcrypto -lsodium $RUST_LIBS" |
a19eeace | 801 | |
e18e1001 | 802 | AC_MSG_CHECKING([whether to build bitcoind]) |
f930341d LD |
803 | AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes]) |
804 | AC_MSG_RESULT($build_bitcoind) | |
805 | ||
5915430d | 806 | AC_MSG_CHECKING([whether to build utils (verus verus-tx wallet-utility)]) |
c101c769 | 807 | AM_CONDITIONAL([BUILD_BITCOIN_UTILS], [test x$build_bitcoin_utils = xyes]) |
808 | AC_MSG_RESULT($build_bitcoin_utils) | |
f930341d | 809 | |
cdd36c6c CF |
810 | AC_MSG_CHECKING([whether to build libraries]) |
811 | AM_CONDITIONAL([BUILD_BITCOIN_LIBS], [test x$build_bitcoin_libs = xyes]) | |
812 | if test x$build_bitcoin_libs = xyes; then | |
813 | AC_DEFINE(HAVE_CONSENSUS_LIB, 1, [Define this symbol if the consensus lib has been built]) | |
08d6b02d | 814 | AC_CONFIG_FILES([libzcashconsensus.pc:libzcashconsensus.pc.in]) |
cdd36c6c | 815 | fi |
e463edc1 | 816 | |
cdd36c6c CF |
817 | AC_MSG_RESULT($build_bitcoin_libs) |
818 | ||
35b8af92 CF |
819 | AC_LANG_POP |
820 | ||
821 | if test "x$use_ccache" != "xno"; then | |
e18e1001 | 822 | AC_MSG_CHECKING(if ccache should be used) |
35b8af92 CF |
823 | if test x$CCACHE = x; then |
824 | if test "x$use_ccache" = "xyes"; then | |
825 | AC_MSG_ERROR([ccache not found.]); | |
826 | else | |
35b8af92 CF |
827 | use_ccache=no |
828 | fi | |
829 | else | |
830 | use_ccache=yes | |
831 | CC="$ac_cv_path_CCACHE $CC" | |
832 | CXX="$ac_cv_path_CCACHE $CXX" | |
833 | fi | |
834 | AC_MSG_RESULT($use_ccache) | |
835 | fi | |
386efb76 CF |
836 | if test "x$use_ccache" = "xyes"; then |
837 | AX_CHECK_PREPROC_FLAG([-Qunused-arguments],[CPPFLAGS="-Qunused-arguments $CPPFLAGS"]) | |
838 | fi | |
35b8af92 | 839 | |
4f9e993b WL |
840 | dnl enable wallet |
841 | AC_MSG_CHECKING([if wallet should be enabled]) | |
842 | if test x$enable_wallet != xno; then | |
843 | AC_MSG_RESULT(yes) | |
844 | AC_DEFINE_UNQUOTED([ENABLE_WALLET],[1],[Define to 1 to enable wallet functions]) | |
845 | ||
846 | else | |
847 | AC_MSG_RESULT(no) | |
4f9e993b WL |
848 | fi |
849 | ||
2cc0a252 JG |
850 | dnl enable mining |
851 | AC_MSG_CHECKING([if mining should be enabled]) | |
852 | if test x$enable_mining != xno; then | |
853 | AC_MSG_RESULT(yes) | |
854 | AC_DEFINE(ENABLE_MINING, 1, [Define to 1 to enable mining functions]) | |
855 | ||
856 | else | |
857 | AC_MSG_RESULT(no) | |
858 | fi | |
859 | ||
f200002c | 860 | AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"]) |
35b8af92 | 861 | |
99eb947a S |
862 | AM_CONDITIONAL([ENABLE_PROTON], [test "x$use_proton" = "xyes"]) |
863 | ||
e18e1001 | 864 | AC_MSG_CHECKING([whether to build test_bitcoin]) |
35b8af92 | 865 | if test x$use_tests = xyes; then |
e18e1001 | 866 | AC_MSG_RESULT([yes]) |
2762638a | 867 | BUILD_TEST="yes" |
e18e1001 LD |
868 | else |
869 | AC_MSG_RESULT([no]) | |
2762638a | 870 | BUILD_TEST="" |
35b8af92 CF |
871 | fi |
872 | ||
e432a5f0 | 873 | AC_MSG_CHECKING([whether to reduce exports]) |
3ee028f1 | 874 | if test x$use_reduce_exports = xyes; then |
e432a5f0 CF |
875 | AC_MSG_RESULT([yes]) |
876 | else | |
877 | AC_MSG_RESULT([no]) | |
878 | fi | |
879 | ||
38ba3c66 | 880 | if test x$build_bitcoin_utils$build_bitcoin_libs$build_bitcoind$use_tests = xnononono; then |
abecfc42 | 881 | AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-libs --with-daemon or --enable-tests]) |
a9dbcf03 LD |
882 | fi |
883 | ||
35b8af92 | 884 | AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin]) |
b62bbb1f | 885 | AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin]) |
35b8af92 | 886 | AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows]) |
b77b4eda | 887 | AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes]) |
2cc0a252 | 888 | AM_CONDITIONAL([ENABLE_MINING],[test x$enable_mining = xyes]) |
2762638a | 889 | AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes]) |
2d338362 | 890 | AM_CONDITIONAL([ARCH_ARM], [test x$have_arm = xtrue]) |
b77b4eda | 891 | AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes]) |
d5aab704 | 892 | AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes]) |
56734f4b | 893 | AM_CONDITIONAL([HARDEN],[test x$use_hardening = xyes]) |
c4379e3a JG |
894 | AM_CONDITIONAL([ASAN],[test x$use_asan = xyes]) |
895 | AM_CONDITIONAL([TSAN],[test x$use_tsan = xyes]) | |
35b8af92 CF |
896 | |
897 | AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version]) | |
898 | AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version]) | |
899 | AC_DEFINE(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION, [Build revision]) | |
900 | AC_DEFINE(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD, [Version Build]) | |
901 | AC_DEFINE(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE, [Version is release]) | |
902 | AC_DEFINE(COPYRIGHT_YEAR, _COPYRIGHT_YEAR, [Version is release]) | |
903 | AC_SUBST(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR) | |
904 | AC_SUBST(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR) | |
905 | AC_SUBST(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION) | |
906 | AC_SUBST(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD) | |
907 | AC_SUBST(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE) | |
908 | AC_SUBST(COPYRIGHT_YEAR, _COPYRIGHT_YEAR) | |
c5d645e2 CF |
909 | AC_SUBST(BITCOIN_DAEMON_NAME) |
910 | AC_SUBST(BITCOIN_CLI_NAME) | |
911 | AC_SUBST(BITCOIN_TX_NAME) | |
35b8af92 | 912 | |
e432a5f0 | 913 | AC_SUBST(RELDFLAGS) |
5dd887fd | 914 | AC_SUBST(ERROR_CXXFLAGS) |
c4379e3a JG |
915 | AC_SUBST(SAN_CXXFLAGS) |
916 | AC_SUBST(SAN_LDFLAGS) | |
c459de2f CF |
917 | AC_SUBST(HARDENED_CXXFLAGS) |
918 | AC_SUBST(HARDENED_CPPFLAGS) | |
919 | AC_SUBST(HARDENED_LDFLAGS) | |
920 | AC_SUBST(PIC_FLAGS) | |
921 | AC_SUBST(PIE_FLAGS) | |
e0077de5 | 922 | AC_SUBST(LIBTOOL_APP_LDFLAGS) |
35b8af92 | 923 | AC_SUBST(BOOST_LIBS) |
35b8af92 CF |
924 | AC_SUBST(TESTDEFS) |
925 | AC_SUBST(LEVELDB_TARGET_FLAGS) | |
d7002714 CF |
926 | AC_SUBST(CRYPTO_LIBS) |
927 | AC_SUBST(SSL_LIBS) | |
928 | AC_SUBST(EVENT_LIBS) | |
929 | AC_SUBST(EVENT_PTHREADS_LIBS) | |
930 | AC_SUBST(ZMQ_LIBS) | |
c4da0970 NW |
931 | AC_SUBST(GMP_LIBS) |
932 | AC_SUBST(GMPXX_LIBS) | |
8f23c734 | 933 | AC_SUBST(LIBSNARK_DEPINST) |
fb7b9e3f | 934 | AC_SUBST(LIBSNARK_OPTFLAGS) |
1785bdb9 | 935 | AC_SUBST(LIBZCASH_LIBS) |
99eb947a | 936 | AC_SUBST(PROTON_LIBS) |
b6a990de | 937 | AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile src/test/buildenv.py]) |
35b8af92 | 938 | AC_CONFIG_FILES([qa/pull-tester/run-bitcoind-for-test.sh],[chmod +x qa/pull-tester/run-bitcoind-for-test.sh]) |
7667850d | 939 | AC_CONFIG_FILES([qa/pull-tester/tests-config.sh],[chmod +x qa/pull-tester/tests-config.sh]) |
07a99017 PW |
940 | |
941 | dnl boost's m4 checks do something really nasty: they export these vars. As a | |
942 | dnl result, they leak into secp256k1's configure and crazy things happen. | |
943 | dnl Until this is fixed upstream and we've synced, we'll just un-export them. | |
0dc86138 | 944 | CPPFLAGS_TEMP="$CPPFLAGS" |
cf61b544 | 945 | unset CPPFLAGS |
0dc86138 CF |
946 | CPPFLAGS="$CPPFLAGS_TEMP" |
947 | ||
948 | LDFLAGS_TEMP="$LDFLAGS" | |
cf61b544 | 949 | unset LDFLAGS |
0dc86138 CF |
950 | LDFLAGS="$LDFLAGS_TEMP" |
951 | ||
952 | LIBS_TEMP="$LIBS" | |
953 | unset LIBS | |
954 | LIBS="$LIBS_TEMP" | |
955 | ||
956 | PKGCONFIG_PATH_TEMP="$PKG_CONFIG_PATH" | |
957 | unset PKG_CONFIG_PATH | |
958 | PKG_CONFIG_PATH="$PKGCONFIG_PATH_TEMP" | |
959 | ||
960 | PKGCONFIG_LIBDIR_TEMP="$PKG_CONFIG_LIBDIR" | |
961 | unset PKG_CONFIG_LIBDIR | |
962 | PKG_CONFIG_LIBDIR="$PKGCONFIG_LIBDIR_TEMP" | |
963 | ||
c1afe40a | 964 | ac_configure_args="${ac_configure_args} --disable-shared --with-pic --with-bignum=no --enable-module-recovery" |
9e74de25 | 965 | AC_CONFIG_SUBDIRS([src/secp256k1 src/snark src/univalue src/cryptoconditions]) |
07a99017 | 966 | |
35b8af92 | 967 | AC_OUTPUT |
a98356fe CF |
968 | |
969 | dnl Taken from https://wiki.debian.org/RpathIssue | |
970 | case $host in | |
971 | *-*-linux-gnu) | |
972 | AC_MSG_RESULT([Fixing libtool for -rpath problems.]) | |
973 | sed < libtool > libtool-2 \ | |
974 | 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_IS_A_FOOL__ "/' | |
975 | mv libtool-2 libtool | |
976 | chmod 755 libtool | |
977 | ;; | |
978 | esac | |
0bcd85be JS |
979 | |
980 | echo | |
981 | echo "Options used to compile and link:" | |
982 | echo " with wallet = $enable_wallet" | |
0100c794 | 983 | echo " with proton = $use_proton" |
0bcd85be JS |
984 | echo " with zmq = $use_zmq" |
985 | echo " with test = $use_tests" | |
986 | echo " debug enabled = $enable_debug" | |
5dd887fd | 987 | echo " werror = $enable_werror" |
0bcd85be JS |
988 | echo |
989 | echo " target os = $TARGET_OS" | |
990 | echo " build os = $BUILD_OS" | |
991 | echo | |
992 | echo " CC = $CC" | |
993 | echo " CFLAGS = $CFLAGS" | |
994 | echo " CPPFLAGS = $CPPFLAGS" | |
995 | echo " CXX = $CXX" | |
996 | echo " CXXFLAGS = $CXXFLAGS" | |
997 | echo " LDFLAGS = $LDFLAGS" | |
bc9fff11 | 998 | echo " ARFLAGS = $ARFLAGS" |
0bcd85be | 999 | echo |