/ configure.ac
configure.ac
1 AC_PREREQ([2.69]) 2 define(_CLIENT_VERSION_MAJOR, 27) 3 define(_CLIENT_VERSION_MINOR, 99) 4 define(_CLIENT_VERSION_BUILD, 0) 5 define(_CLIENT_VERSION_RC, 0) 6 define(_CLIENT_VERSION_IS_RELEASE, false) 7 define(_COPYRIGHT_YEAR, 2024) 8 define(_COPYRIGHT_HOLDERS,[The %s developers]) 9 define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[Bitcoin Core]]) 10 AC_INIT([Bitcoin Core],m4_join([.], _CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MINOR, _CLIENT_VERSION_BUILD)m4_if(_CLIENT_VERSION_RC, [0], [], [rc]_CLIENT_VERSION_RC),[https://github.com/bitcoin/bitcoin/issues],[bitcoin],[https://bitcoincore.org/]) 11 AC_CONFIG_SRCDIR([src/validation.cpp]) 12 AC_CONFIG_HEADERS([src/config/bitcoin-config.h]) 13 AC_CONFIG_AUX_DIR([build-aux]) 14 AC_CONFIG_MACRO_DIR([build-aux/m4]) 15 16 m4_ifndef([PKG_PROG_PKG_CONFIG], [m4_fatal([PKG_PROG_PKG_CONFIG macro not found. Please install pkg-config and re-run autogen.sh])]) 17 PKG_PROG_PKG_CONFIG 18 if test "$PKG_CONFIG" = ""; then 19 AC_MSG_ERROR([pkg-config not found]) 20 fi 21 22 # When compiling with depends, the `PKG_CONFIG_PATH` and `PKG_CONFIG_LIBDIR` variables, 23 # being set in a `config.site` file, are not exported to let the `--config-cache` option 24 # work properly. 25 if test -n "$PKG_CONFIG_PATH"; then 26 PKG_CONFIG="env PKG_CONFIG_PATH=$PKG_CONFIG_PATH $PKG_CONFIG" 27 fi 28 if test -n "$PKG_CONFIG_LIBDIR"; then 29 PKG_CONFIG="env PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR $PKG_CONFIG" 30 fi 31 32 BITCOIN_DAEMON_NAME=bitcoind 33 BITCOIN_GUI_NAME=bitcoin-qt 34 BITCOIN_TEST_NAME=test_bitcoin 35 BITCOIN_CLI_NAME=bitcoin-cli 36 BITCOIN_TX_NAME=bitcoin-tx 37 BITCOIN_UTIL_NAME=bitcoin-util 38 BITCOIN_CHAINSTATE_NAME=bitcoin-chainstate 39 BITCOIN_WALLET_TOOL_NAME=bitcoin-wallet 40 dnl Multi Process 41 BITCOIN_MP_NODE_NAME=bitcoin-node 42 BITCOIN_MP_GUI_NAME=bitcoin-gui 43 44 dnl Unless the user specified ARFLAGS, force it to be cr 45 dnl This is also the default as-of libtool 2.4.7 46 AC_ARG_VAR([ARFLAGS], [Flags for the archiver, defaults to <cr> if not set]) 47 if test "${ARFLAGS+set}" != "set"; then 48 ARFLAGS="cr" 49 fi 50 51 AC_CANONICAL_HOST 52 53 AH_TOP([#ifndef BITCOIN_CONFIG_H]) 54 AH_TOP([#define BITCOIN_CONFIG_H]) 55 AH_BOTTOM([#endif //BITCOIN_CONFIG_H]) 56 57 dnl Automake init set-up and checks 58 AM_INIT_AUTOMAKE([1.13 no-define subdir-objects foreign]) 59 60 AM_MAINTAINER_MODE([enable]) 61 62 dnl make the compilation flags quiet unless V=1 is used 63 AM_SILENT_RULES([yes]) 64 65 dnl Compiler checks (here before libtool). 66 if test "${CXXFLAGS+set}" = "set"; then 67 CXXFLAGS_overridden=yes 68 else 69 CXXFLAGS_overridden=no 70 fi 71 AC_PROG_CXX 72 73 dnl libtool overrides 74 case $host in 75 *mingw*) 76 dnl By default, libtool for mingw refuses to link static libs into a dll for 77 dnl fear of mixing pic/non-pic objects, and import/export complications. Since 78 dnl we have those under control, re-enable that functionality. 79 lt_cv_deplibs_check_method="pass_all" 80 81 dnl Remove unwanted -DDLL_EXPORT from these variables. 82 dnl We do not use this macro, but system headers may export unwanted symbols 83 dnl if it's set. 84 lt_cv_prog_compiler_pic="-DPIC" 85 lt_cv_prog_compiler_pic_CXX="-DPIC" 86 ;; 87 *darwin*) 88 dnl Because it prints a verbose warning, lld fails the following check 89 dnl for "-Wl,-single_module" from libtool.m4: 90 dnl # If there is a non-empty error log, and "single_module" 91 dnl # appears in it, assume the flag caused a linker warning 92 dnl "-single_module" works fine on ld64 and lld, so just bypass the test. 93 dnl Failure to set this to "yes" causes libtool to use a very broken 94 dnl link-line for shared libs. 95 lt_cv_apple_cc_single_mod="yes" 96 ;; 97 esac 98 99 dnl Require C++20 compiler (no GNU extensions) 100 AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory]) 101 102 dnl Unless the user specified OBJCXX, force it to be the same as CXX. This ensures 103 dnl that we get the same -std flags for both. 104 m4_ifdef([AC_PROG_OBJCXX],[ 105 if test "${OBJCXX+set}" = ""; then 106 OBJCXX="${CXX}" 107 fi 108 AC_PROG_OBJCXX 109 ]) 110 111 dnl OpenBSD ships with 2.4.2 112 LT_PREREQ([2.4.2]) 113 dnl Libtool init checks. 114 LT_INIT([pic-only win32-dll]) 115 116 dnl Check/return PATH for base programs. 117 AC_PATH_TOOL([AR], [ar]) 118 AC_PATH_TOOL([GCOV], [gcov]) 119 AC_PATH_TOOL([LLVM_COV], [llvm-cov]) 120 AC_PATH_PROG([LCOV], [lcov]) 121 dnl The minimum supported version is specified in .python-version and should be used if available, see doc/dependencies.md 122 AC_PATH_PROGS([PYTHON], [python3.9 python3.10 python3.11 python3.12 python3 python]) 123 AC_PATH_PROG([GENHTML], [genhtml]) 124 AC_PATH_PROG([GIT], [git]) 125 AC_PATH_PROG([CCACHE], [ccache]) 126 AC_PATH_PROG([XGETTEXT], [xgettext]) 127 AC_PATH_PROG([HEXDUMP], [hexdump]) 128 AC_PATH_TOOL([OBJCOPY], [objcopy]) 129 AC_PATH_PROG([DOXYGEN], [doxygen]) 130 AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"]) 131 132 AC_ARG_ENABLE([wallet], 133 [AS_HELP_STRING([--disable-wallet], 134 [disable wallet (enabled by default)])], 135 [enable_wallet=$enableval], 136 [enable_wallet=auto]) 137 138 AC_ARG_WITH([sqlite], 139 [AS_HELP_STRING([--with-sqlite=yes|no|auto], 140 [enable sqlite wallet support (default: auto, i.e., enabled if wallet is enabled and sqlite is found)])], 141 [use_sqlite=$withval], 142 [use_sqlite=auto]) 143 144 AC_ARG_WITH([bdb], 145 [AS_HELP_STRING([--without-bdb], 146 [disable bdb wallet support (default is enabled if wallet is enabled)])], 147 [use_bdb=$withval], 148 [use_bdb=auto]) 149 150 AC_ARG_ENABLE([usdt], 151 [AS_HELP_STRING([--enable-usdt], 152 [enable tracepoints for Userspace, Statically Defined Tracing (default is yes if sys/sdt.h is found)])], 153 [use_usdt=$enableval], 154 [use_usdt=yes]) 155 156 AC_ARG_WITH([miniupnpc], 157 [AS_HELP_STRING([--with-miniupnpc], 158 [enable UPNP (default is yes if libminiupnpc is found)])], 159 [use_upnp=$withval], 160 [use_upnp=auto]) 161 162 AC_ARG_WITH([natpmp], 163 [AS_HELP_STRING([--with-natpmp], 164 [enable NAT-PMP (default is yes if libnatpmp is found)])], 165 [use_natpmp=$withval], 166 [use_natpmp=auto]) 167 168 AC_ARG_ENABLE(tests, 169 AS_HELP_STRING([--disable-tests],[do not compile tests (default is to compile)]), 170 [use_tests=$enableval], 171 [use_tests=yes]) 172 173 AC_ARG_ENABLE(gui-tests, 174 AS_HELP_STRING([--disable-gui-tests],[do not compile GUI tests (default is to compile if GUI and tests enabled)]), 175 [use_gui_tests=$enableval], 176 [use_gui_tests=$use_tests]) 177 178 AC_ARG_ENABLE(bench, 179 AS_HELP_STRING([--disable-bench],[do not compile benchmarks (default is to compile)]), 180 [use_bench=$enableval], 181 [use_bench=yes]) 182 183 AC_ARG_ENABLE([extended-functional-tests], 184 AS_HELP_STRING([--enable-extended-functional-tests],[enable expensive functional tests when using lcov (default no)]), 185 [use_extended_functional_tests=$enableval], 186 [use_extended_functional_tests=no]) 187 188 AC_ARG_ENABLE([fuzz], 189 AS_HELP_STRING([--enable-fuzz], 190 [build for fuzzing (default no). enabling this will disable all other targets and override --{enable,disable}-fuzz-binary]), 191 [enable_fuzz=$enableval], 192 [enable_fuzz=no]) 193 194 AC_ARG_ENABLE([fuzz-binary], 195 AS_HELP_STRING([--enable-fuzz-binary], 196 [enable building of fuzz binary (default yes).]), 197 [enable_fuzz_binary=$enableval], 198 [enable_fuzz_binary=yes]) 199 200 AC_ARG_WITH([qrencode], 201 [AS_HELP_STRING([--with-qrencode], 202 [enable QR code support (default is yes if qt is enabled and libqrencode is found)])], 203 [use_qr=$withval], 204 [use_qr=auto]) 205 206 AC_ARG_ENABLE([hardening], 207 [AS_HELP_STRING([--disable-hardening], 208 [do not attempt to harden the resulting executables (default is to harden when possible)])], 209 [use_hardening=$enableval], 210 [use_hardening=auto]) 211 212 AC_ARG_ENABLE([reduce-exports], 213 [AS_HELP_STRING([--enable-reduce-exports], 214 [attempt to reduce exported symbols in the resulting executables (default is no)])], 215 [use_reduce_exports=$enableval], 216 [use_reduce_exports=no]) 217 218 AC_ARG_ENABLE([ccache], 219 [AS_HELP_STRING([--disable-ccache], 220 [do not use ccache for building (default is to use if found)])], 221 [use_ccache=$enableval], 222 [use_ccache=auto]) 223 224 dnl Suppress warnings from external headers (e.g. Boost, Qt). 225 dnl May be useful if warnings from external headers clutter the build output 226 dnl too much, so that it becomes difficult to spot Bitcoin Core warnings 227 dnl or if they cause a build failure with --enable-werror. 228 AC_ARG_ENABLE([suppress-external-warnings], 229 [AS_HELP_STRING([--disable-suppress-external-warnings], 230 [Do not suppress warnings from external headers (default is to suppress)])], 231 [suppress_external_warnings=$enableval], 232 [suppress_external_warnings=yes]) 233 234 AC_ARG_ENABLE([lcov], 235 [AS_HELP_STRING([--enable-lcov], 236 [enable lcov testing (default is no)])], 237 [use_lcov=$enableval], 238 [use_lcov=no]) 239 240 AC_ARG_ENABLE([lcov-branch-coverage], 241 [AS_HELP_STRING([--enable-lcov-branch-coverage], 242 [enable lcov testing branch coverage (default is no)])], 243 [use_lcov_branch=yes], 244 [use_lcov_branch=no]) 245 246 AC_ARG_ENABLE([threadlocal], 247 [AS_HELP_STRING([--enable-threadlocal], 248 [enable features that depend on the c++ thread_local keyword (currently just thread names in debug logs). (default is to enable if there is platform support)])], 249 [use_thread_local=$enableval], 250 [use_thread_local=auto]) 251 252 AC_ARG_ENABLE([zmq], 253 [AS_HELP_STRING([--disable-zmq], 254 [disable ZMQ notifications])], 255 [use_zmq=$enableval], 256 [use_zmq=yes]) 257 258 AC_ARG_WITH([libmultiprocess], 259 [AS_HELP_STRING([--with-libmultiprocess=yes|no|auto], 260 [Build with libmultiprocess library. (default: auto, i.e. detect with pkg-config)])], 261 [with_libmultiprocess=$withval], 262 [with_libmultiprocess=auto]) 263 264 AC_ARG_WITH([mpgen], 265 [AS_HELP_STRING([--with-mpgen=yes|no|auto|PREFIX], 266 [Build with libmultiprocess codegen tool. Useful to specify different libmultiprocess host system library and build system codegen tool prefixes when cross-compiling (default is host system libmultiprocess prefix)])], 267 [with_mpgen=$withval], 268 [with_mpgen=auto]) 269 270 AC_ARG_ENABLE([multiprocess], 271 [AS_HELP_STRING([--enable-multiprocess], 272 [build multiprocess bitcoin-node, bitcoin-wallet, and bitcoin-gui executables in addition to monolithic bitcoind and bitcoin-qt executables. Requires libmultiprocess library. Experimental (default is no)])], 273 [enable_multiprocess=$enableval], 274 [enable_multiprocess=no]) 275 276 AC_ARG_ENABLE(man, 277 [AS_HELP_STRING([--disable-man], 278 [do not install man pages (default is to install)])],, 279 enable_man=yes) 280 AM_CONDITIONAL([ENABLE_MAN], [test "$enable_man" != "no"]) 281 282 dnl Enable debug 283 AC_ARG_ENABLE([debug], 284 [AS_HELP_STRING([--enable-debug], 285 [use compiler flags and macros suited for debugging (default is no)])], 286 [enable_debug=$enableval], 287 [enable_debug=no]) 288 289 dnl Enable different -fsanitize options 290 AC_ARG_WITH([sanitizers], 291 [AS_HELP_STRING([--with-sanitizers], 292 [comma separated list of extra sanitizers to build with (default is none enabled)])], 293 [use_sanitizers=$withval]) 294 295 dnl Enable gprof profiling 296 AC_ARG_ENABLE([gprof], 297 [AS_HELP_STRING([--enable-gprof], 298 [use gprof profiling compiler flags (default is no)])], 299 [enable_gprof=$enableval], 300 [enable_gprof=no]) 301 302 dnl Turn warnings into errors 303 AC_ARG_ENABLE([werror], 304 [AS_HELP_STRING([--enable-werror], 305 [Treat compiler warnings as errors (default is no)])], 306 [enable_werror=$enableval], 307 [enable_werror=no]) 308 309 AC_ARG_ENABLE([external-signer], 310 [AS_HELP_STRING([--enable-external-signer],[compile external signer support (default is auto, requires Boost::Process)])], 311 [use_external_signer=$enableval], 312 [use_external_signer=auto]) 313 314 AC_LANG_PUSH([C++]) 315 316 dnl Always set -g -O2 in our CXXFLAGS. Autoconf will try and set CXXFLAGS to "-g -O2" by default, 317 dnl so we suppress that (if CXXFLAGS hasn't been overridden by the user), given we are adding it 318 dnl ourselves. 319 CORE_CXXFLAGS="$CORE_CXXFLAGS -g -O2" 320 321 if test "$CXXFLAGS_overridden" = "no"; then 322 CXXFLAGS="" 323 fi 324 325 dnl Check for a flag to turn compiler warnings into errors. This is helpful for checks which may 326 dnl appear to succeed because by default they merely emit warnings when they fail. 327 dnl 328 dnl Note that this is not necessarily a check to see if -Werror is supported, but rather to see if 329 dnl a compile with -Werror can succeed. This is important because the compiler may already be 330 dnl warning about something unrelated, for example about some path issue. If that is the case, 331 dnl -Werror cannot be used because all of those warnings would be turned into errors. 332 AX_CHECK_COMPILE_FLAG([-Werror], [CXXFLAG_WERROR="-Werror"], [CXXFLAG_WERROR=""]) 333 334 dnl Check for a flag to turn linker warnings into errors. When flags are passed to linkers via the 335 dnl compiler driver using a -Wl,-foo flag, linker warnings may be swallowed rather than bubbling up. 336 dnl See note above, the same applies here as well. 337 dnl 338 dnl LDFLAG_WERROR Should only be used when testing -Wl,* 339 case $host in 340 *darwin*) 341 AX_CHECK_LINK_FLAG([-Wl,-fatal_warnings], [LDFLAG_WERROR="-Wl,-fatal_warnings"], [LDFLAG_WERROR=""]) 342 ;; 343 *) 344 AX_CHECK_LINK_FLAG([-Wl,--fatal-warnings], [LDFLAG_WERROR="-Wl,--fatal-warnings"], [LDFLAG_WERROR=""]) 345 ;; 346 esac 347 348 if test "$enable_debug" = "yes"; then 349 350 dnl Disable all optimizations 351 AX_CHECK_COMPILE_FLAG([-O0], [DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -O0"], [], [$CXXFLAG_WERROR]) 352 353 dnl Prefer -g3, fall back to -g if that is unavailable. 354 AX_CHECK_COMPILE_FLAG( 355 [-g3], 356 [DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -g3"], 357 [AX_CHECK_COMPILE_FLAG([-g], [DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -g"], [], [$CXXFLAG_WERROR])], 358 [$CXXFLAG_WERROR]) 359 360 AX_CHECK_PREPROC_FLAG([-DDEBUG], [DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG"], [], [$CXXFLAG_WERROR]) 361 AX_CHECK_PREPROC_FLAG([-DDEBUG_LOCKORDER], [DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG_LOCKORDER"], [], [$CXXFLAG_WERROR]) 362 AX_CHECK_PREPROC_FLAG([-DDEBUG_LOCKCONTENTION], [DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG_LOCKCONTENTION"], [], [$CXXFLAG_WERROR]) 363 AX_CHECK_PREPROC_FLAG([-DRPC_DOC_CHECK], [DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DRPC_DOC_CHECK"], [], [$CXXFLAG_WERROR]) 364 AX_CHECK_PREPROC_FLAG([-DABORT_ON_FAILED_ASSUME], [DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DABORT_ON_FAILED_ASSUME"], [], [$CXXFLAG_WERROR]) 365 AX_CHECK_COMPILE_FLAG([-ftrapv], [DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -ftrapv"], [], [$CXXFLAG_WERROR]) 366 fi 367 368 if test "$use_sanitizers" != ""; then 369 dnl First check if the compiler accepts flags. If an incompatible pair like 370 dnl -fsanitize=address,thread is used here, this check will fail. This will also 371 dnl fail if a bad argument is passed, e.g. -fsanitize=undfeined 372 AX_CHECK_COMPILE_FLAG( 373 [-fsanitize=$use_sanitizers], 374 [SANITIZER_CXXFLAGS="-fsanitize=$use_sanitizers" 375 SANITIZER_CFLAGS="-fsanitize=$use_sanitizers"], 376 [AC_MSG_ERROR([compiler did not accept requested flags])]) 377 378 dnl Some compilers (e.g. GCC) require additional libraries like libasan, 379 dnl libtsan, libubsan, etc. Make sure linking still works with the sanitize 380 dnl flag. This is a separate check so we can give a better error message when 381 dnl the sanitize flags are supported by the compiler but the actual sanitizer 382 dnl libs are missing. 383 AX_CHECK_LINK_FLAG( 384 [-fsanitize=$use_sanitizers], 385 [SANITIZER_LDFLAGS="-fsanitize=$use_sanitizers"], 386 [AC_MSG_ERROR([linker did not accept requested flags, you are missing required libraries])], 387 [], 388 [AC_LANG_PROGRAM([[ 389 #include <cstdint> 390 #include <cstddef> 391 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { return 0; } 392 __attribute__((weak)) // allow for libFuzzer linking 393 ]],[[]])]) 394 fi 395 396 ERROR_CXXFLAGS= 397 if test "$enable_werror" = "yes"; then 398 if test "$CXXFLAG_WERROR" = ""; then 399 AC_MSG_ERROR([enable-werror set but -Werror is not usable]) 400 fi 401 ERROR_CXXFLAGS=$CXXFLAG_WERROR 402 fi 403 404 if test "$CXXFLAGS_overridden" = "no"; then 405 AX_CHECK_COMPILE_FLAG([-Wall], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wall"], [], [$CXXFLAG_WERROR]) 406 AX_CHECK_COMPILE_FLAG([-Wextra], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wextra"], [], [$CXXFLAG_WERROR]) 407 AX_CHECK_COMPILE_FLAG([-Wgnu], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wgnu"], [], [$CXXFLAG_WERROR]) 408 dnl some compilers will ignore -Wformat-security without -Wformat, so just combine the two here. 409 AX_CHECK_COMPILE_FLAG([-Wformat -Wformat-security], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat -Wformat-security"], [], [$CXXFLAG_WERROR]) 410 AX_CHECK_COMPILE_FLAG([-Wvla], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wvla"], [], [$CXXFLAG_WERROR]) 411 AX_CHECK_COMPILE_FLAG([-Wshadow-field], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wshadow-field"], [], [$CXXFLAG_WERROR]) 412 AX_CHECK_COMPILE_FLAG([-Wthread-safety], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wthread-safety"], [], [$CXXFLAG_WERROR]) 413 AX_CHECK_COMPILE_FLAG([-Wloop-analysis], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wloop-analysis"], [], [$CXXFLAG_WERROR]) 414 AX_CHECK_COMPILE_FLAG([-Wredundant-decls], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wredundant-decls"], [], [$CXXFLAG_WERROR]) 415 AX_CHECK_COMPILE_FLAG([-Wunused-member-function], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunused-member-function"], [], [$CXXFLAG_WERROR]) 416 AX_CHECK_COMPILE_FLAG([-Wdate-time], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdate-time"], [], [$CXXFLAG_WERROR]) 417 AX_CHECK_COMPILE_FLAG([-Wconditional-uninitialized], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wconditional-uninitialized"], [], [$CXXFLAG_WERROR]) 418 AX_CHECK_COMPILE_FLAG([-Wduplicated-branches], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wduplicated-branches"], [], [$CXXFLAG_WERROR]) 419 AX_CHECK_COMPILE_FLAG([-Wduplicated-cond], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wduplicated-cond"], [], [$CXXFLAG_WERROR]) 420 AX_CHECK_COMPILE_FLAG([-Wlogical-op], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wlogical-op"], [], [$CXXFLAG_WERROR]) 421 AX_CHECK_COMPILE_FLAG([-Woverloaded-virtual], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Woverloaded-virtual"], [], [$CXXFLAG_WERROR]) 422 AX_CHECK_COMPILE_FLAG([-Wsuggest-override], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"], [], [$CXXFLAG_WERROR]) 423 AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wimplicit-fallthrough"], [], [$CXXFLAG_WERROR]) 424 AX_CHECK_COMPILE_FLAG([-Wunreachable-code], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunreachable-code"], [], [$CXXFLAG_WERROR]) 425 AX_CHECK_COMPILE_FLAG([-Wdocumentation], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdocumentation"], [], [$CXXFLAG_WERROR]) 426 427 dnl Some compilers (gcc) ignore unknown -Wno-* options, but warn about all 428 dnl unknown options if any other warning is produced. Test the -Wfoo case, and 429 dnl set the -Wno-foo case if it works. 430 AX_CHECK_COMPILE_FLAG([-Wunused-parameter], [NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-unused-parameter"], [], [$CXXFLAG_WERROR]) 431 AX_CHECK_COMPILE_FLAG([-Wself-assign], [NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-self-assign"], [], [$CXXFLAG_WERROR]) 432 if test "$suppress_external_warnings" != "yes" ; then 433 AX_CHECK_COMPILE_FLAG([-Wdeprecated-copy], [NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-deprecated-copy"], [], [$CXXFLAG_WERROR]) 434 fi 435 fi 436 437 dnl Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review. 438 AX_CHECK_COMPILE_FLAG([-fno-extended-identifiers], [CORE_CXXFLAGS="$CORE_CXXFLAGS -fno-extended-identifiers"], [], [$CXXFLAG_WERROR]) 439 440 dnl Currently all versions of gcc are subject to a class of bugs, see the 441 dnl gccbug_90348 test case (only reproduces on GCC 11 and earlier) and 442 dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111843. To work around that, set 443 dnl -fstack-reuse=none for all gcc builds. (Only gcc understands this flag) 444 AX_CHECK_COMPILE_FLAG([-fstack-reuse=none], [CORE_CXXFLAGS="$CORE_CXXFLAGS -fstack-reuse=none"]) 445 446 enable_arm_crc=no 447 enable_arm_shani=no 448 enable_sse42=no 449 enable_sse41=no 450 enable_avx2=no 451 enable_x86_shani=no 452 453 dnl Check for optional instruction set support. Enabling these does _not_ imply that all code will 454 dnl be compiled with them, rather that specific objects/libs may use them after checking for runtime 455 dnl compatibility. 456 457 dnl x86 458 AX_CHECK_COMPILE_FLAG([-msse4.2], [SSE42_CXXFLAGS="-msse4.2"], [], [$CXXFLAG_WERROR]) 459 AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_CXXFLAGS="-msse4.1"], [], [$CXXFLAG_WERROR]) 460 AX_CHECK_COMPILE_FLAG([-mavx -mavx2], [AVX2_CXXFLAGS="-mavx -mavx2"], [], [$CXXFLAG_WERROR]) 461 AX_CHECK_COMPILE_FLAG([-msse4 -msha], [X86_SHANI_CXXFLAGS="-msse4 -msha"], [], [$CXXFLAG_WERROR]) 462 463 enable_clmul= 464 AX_CHECK_COMPILE_FLAG([-mpclmul], [enable_clmul=yes], [], [$CXXFLAG_WERROR], [AC_LANG_PROGRAM([ 465 #include <stdint.h> 466 #include <x86intrin.h> 467 ], [ 468 __m128i a = _mm_cvtsi64_si128((uint64_t)7); 469 __m128i b = _mm_clmulepi64_si128(a, a, 37); 470 __m128i c = _mm_srli_epi64(b, 41); 471 __m128i d = _mm_xor_si128(b, c); 472 uint64_t e = _mm_cvtsi128_si64(d); 473 return e == 0; 474 ])]) 475 476 if test "$enable_clmul" = "yes"; then 477 CLMUL_CXXFLAGS="-mpclmul" 478 AC_DEFINE([HAVE_CLMUL], [1], [Define this symbol if clmul instructions can be used]) 479 fi 480 481 TEMP_CXXFLAGS="$CXXFLAGS" 482 CXXFLAGS="$SSE42_CXXFLAGS $CXXFLAGS" 483 AC_MSG_CHECKING([for SSE4.2 intrinsics]) 484 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 485 #include <stdint.h> 486 #if defined(_MSC_VER) 487 #include <intrin.h> 488 #elif defined(__GNUC__) && defined(__SSE4_2__) 489 #include <nmmintrin.h> 490 #endif 491 ]],[[ 492 uint64_t l = 0; 493 l = _mm_crc32_u8(l, 0); 494 l = _mm_crc32_u32(l, 0); 495 l = _mm_crc32_u64(l, 0); 496 return l; 497 ]])], 498 [ AC_MSG_RESULT([yes]); enable_sse42=yes], 499 [ AC_MSG_RESULT([no])] 500 ) 501 CXXFLAGS="$TEMP_CXXFLAGS" 502 503 TEMP_CXXFLAGS="$CXXFLAGS" 504 CXXFLAGS="$SSE41_CXXFLAGS $CXXFLAGS" 505 AC_MSG_CHECKING([for SSE4.1 intrinsics]) 506 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 507 #include <stdint.h> 508 #include <immintrin.h> 509 ]],[[ 510 __m128i l = _mm_set1_epi32(0); 511 return _mm_extract_epi32(l, 3); 512 ]])], 513 [ AC_MSG_RESULT([yes]); enable_sse41=yes; AC_DEFINE([ENABLE_SSE41], [1], [Define this symbol to build code that uses SSE4.1 intrinsics]) ], 514 [ AC_MSG_RESULT([no])] 515 ) 516 CXXFLAGS="$TEMP_CXXFLAGS" 517 518 TEMP_CXXFLAGS="$CXXFLAGS" 519 CXXFLAGS="$AVX2_CXXFLAGS $CXXFLAGS" 520 AC_MSG_CHECKING([for AVX2 intrinsics]) 521 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 522 #include <stdint.h> 523 #include <immintrin.h> 524 ]],[[ 525 __m256i l = _mm256_set1_epi32(0); 526 return _mm256_extract_epi32(l, 7); 527 ]])], 528 [ AC_MSG_RESULT([yes]); enable_avx2=yes; AC_DEFINE([ENABLE_AVX2], [1], [Define this symbol to build code that uses AVX2 intrinsics]) ], 529 [ AC_MSG_RESULT([no])] 530 ) 531 CXXFLAGS="$TEMP_CXXFLAGS" 532 533 TEMP_CXXFLAGS="$CXXFLAGS" 534 CXXFLAGS="$X86_SHANI_CXXFLAGS $CXXFLAGS" 535 AC_MSG_CHECKING([for x86 SHA-NI intrinsics]) 536 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 537 #include <stdint.h> 538 #include <immintrin.h> 539 ]],[[ 540 __m128i i = _mm_set1_epi32(0); 541 __m128i j = _mm_set1_epi32(1); 542 __m128i k = _mm_set1_epi32(2); 543 return _mm_extract_epi32(_mm_sha256rnds2_epu32(i, i, k), 0); 544 ]])], 545 [ AC_MSG_RESULT([yes]); enable_x86_shani=yes; AC_DEFINE([ENABLE_X86_SHANI], [1], [Define this symbol to build code that uses x86 SHA-NI intrinsics]) ], 546 [ AC_MSG_RESULT([no])] 547 ) 548 CXXFLAGS="$TEMP_CXXFLAGS" 549 550 # ARM 551 AX_CHECK_COMPILE_FLAG([-march=armv8-a+crc+crypto], [ARM_CRC_CXXFLAGS="-march=armv8-a+crc+crypto"], [], [$CXXFLAG_WERROR]) 552 AX_CHECK_COMPILE_FLAG([-march=armv8-a+crypto], [ARM_SHANI_CXXFLAGS="-march=armv8-a+crypto"], [], [$CXXFLAG_WERROR]) 553 554 TEMP_CXXFLAGS="$CXXFLAGS" 555 CXXFLAGS="$ARM_CRC_CXXFLAGS $CXXFLAGS" 556 AC_MSG_CHECKING([for ARMv8 CRC32 intrinsics]) 557 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 558 #include <arm_acle.h> 559 #include <arm_neon.h> 560 ]],[[ 561 #ifdef __aarch64__ 562 __crc32cb(0, 0); __crc32ch(0, 0); __crc32cw(0, 0); __crc32cd(0, 0); 563 vmull_p64(0, 0); 564 #else 565 #error "crc32c library does not support hardware acceleration on 32-bit ARM" 566 #endif 567 ]])], 568 [ AC_MSG_RESULT([yes]); enable_arm_crc=yes; ], 569 [ AC_MSG_RESULT([no])] 570 ) 571 CXXFLAGS="$TEMP_CXXFLAGS" 572 573 TEMP_CXXFLAGS="$CXXFLAGS" 574 CXXFLAGS="$ARM_SHANI_CXXFLAGS $CXXFLAGS" 575 AC_MSG_CHECKING([for ARMv8 SHA-NI intrinsics]) 576 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 577 #include <arm_acle.h> 578 #include <arm_neon.h> 579 ]],[[ 580 uint32x4_t a, b, c; 581 vsha256h2q_u32(a, b, c); 582 vsha256hq_u32(a, b, c); 583 vsha256su0q_u32(a, b); 584 vsha256su1q_u32(a, b, c); 585 ]])], 586 [ AC_MSG_RESULT([yes]); enable_arm_shani=yes; AC_DEFINE([ENABLE_ARM_SHANI], [1], [Define this symbol to build code that uses ARMv8 SHA-NI intrinsics]) ], 587 [ AC_MSG_RESULT([no])] 588 ) 589 CXXFLAGS="$TEMP_CXXFLAGS" 590 591 CORE_CPPFLAGS="$CORE_CPPFLAGS -DHAVE_BUILD_INFO" 592 593 AC_ARG_WITH([utils], 594 [AS_HELP_STRING([--with-utils], 595 [build bitcoin-cli bitcoin-tx bitcoin-util bitcoin-wallet (default=yes)])], 596 [build_bitcoin_utils=$withval], 597 [build_bitcoin_utils=yes]) 598 599 AC_ARG_ENABLE([util-cli], 600 [AS_HELP_STRING([--enable-util-cli], 601 [build bitcoin-cli])], 602 [build_bitcoin_cli=$enableval], 603 [build_bitcoin_cli=$build_bitcoin_utils]) 604 605 AC_ARG_ENABLE([util-tx], 606 [AS_HELP_STRING([--enable-util-tx], 607 [build bitcoin-tx])], 608 [build_bitcoin_tx=$enableval], 609 [build_bitcoin_tx=$build_bitcoin_utils]) 610 611 AC_ARG_ENABLE([util-wallet], 612 [AS_HELP_STRING([--enable-util-wallet], 613 [build bitcoin-wallet])], 614 [build_bitcoin_wallet=$enableval], 615 [build_bitcoin_wallet=$build_bitcoin_utils]) 616 617 AC_ARG_ENABLE([util-util], 618 [AS_HELP_STRING([--enable-util-util], 619 [build bitcoin-util])], 620 [build_bitcoin_util=$enableval], 621 [build_bitcoin_util=$build_bitcoin_utils]) 622 623 AC_ARG_ENABLE([experimental-util-chainstate], 624 [AS_HELP_STRING([--enable-experimental-util-chainstate], 625 [build experimental bitcoin-chainstate executable (default=no)])], 626 [build_bitcoin_chainstate=$enableval], 627 [build_bitcoin_chainstate=no]) 628 629 AC_ARG_WITH([libs], 630 [AS_HELP_STRING([--with-libs], 631 [build libraries (default=yes)])], 632 [build_bitcoin_libs=$withval], 633 [build_bitcoin_libs=yes]) 634 635 AC_ARG_WITH([experimental-kernel-lib], 636 [AS_HELP_STRING([--with-experimental-kernel-lib], 637 [build experimental bitcoinkernel library (default is to build if we're building libraries and the experimental build-chainstate executable)])], 638 [build_experimental_kernel_lib=$withval], 639 [build_experimental_kernel_lib=auto]) 640 641 AC_ARG_WITH([daemon], 642 [AS_HELP_STRING([--with-daemon], 643 [build bitcoind daemon (default=yes)])], 644 [build_bitcoind=$withval], 645 [build_bitcoind=yes]) 646 647 case $host in 648 *mingw*) 649 TARGET_OS=windows 650 AC_CHECK_LIB([kernel32], [GetModuleFileNameA], [], [AC_MSG_ERROR([libkernel32 missing])]) 651 AC_CHECK_LIB([user32], [main], [], [AC_MSG_ERROR([libuser32 missing])]) 652 AC_CHECK_LIB([gdi32], [main], [], [AC_MSG_ERROR([libgdi32 missing])]) 653 AC_CHECK_LIB([comdlg32], [main], [], [AC_MSG_ERROR([libcomdlg32 missing])]) 654 AC_CHECK_LIB([winmm], [main], [], [AC_MSG_ERROR([libwinmm missing])]) 655 AC_CHECK_LIB([shell32], [SHGetSpecialFolderPathW], [], [AC_MSG_ERROR([libshell32 missing])]) 656 AC_CHECK_LIB([comctl32], [main], [], [AC_MSG_ERROR([libcomctl32 missing])]) 657 AC_CHECK_LIB([ole32], [CoCreateInstance], [], [AC_MSG_ERROR([libole32 missing])]) 658 AC_CHECK_LIB([oleaut32], [main], [], [AC_MSG_ERROR([liboleaut32 missing])]) 659 AC_CHECK_LIB([uuid], [main], [], [AC_MSG_ERROR([libuuid missing])]) 660 AC_CHECK_LIB([advapi32], [CryptAcquireContextW], [], [AC_MSG_ERROR([libadvapi32 missing])]) 661 AC_CHECK_LIB([ws2_32], [WSAStartup], [], [AC_MSG_ERROR([libws2_32 missing])]) 662 AC_CHECK_LIB([shlwapi], [PathRemoveFileSpecW], [], [AC_MSG_ERROR([libshlwapi missing])]) 663 AC_CHECK_LIB([iphlpapi], [GetAdaptersAddresses], [], [AC_MSG_ERROR([libiphlpapi missing])]) 664 665 dnl -static is interpreted by libtool, where it has a different meaning. 666 dnl In libtool-speak, it's -all-static. 667 AX_CHECK_LINK_FLAG([-static], [LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static"]) 668 669 AC_PATH_PROG([MAKENSIS], [makensis], [none]) 670 if test "$MAKENSIS" = "none"; then 671 AC_MSG_WARN([makensis not found. Cannot create installer.]) 672 fi 673 674 AC_PATH_TOOL([WINDRES], [windres], [none]) 675 if test "$WINDRES" = "none"; then 676 AC_MSG_ERROR([windres not found]) 677 fi 678 679 CORE_CPPFLAGS="$CORE_CPPFLAGS -DSECP256K1_STATIC" 680 681 CORE_CPPFLAGS="$CORE_CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN" 682 dnl Prevent the definition of min/max macros. 683 dnl We always want to use the standard library. 684 CORE_CPPFLAGS="$CORE_CPPFLAGS -DNOMINMAX" 685 686 dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against. 687 dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override 688 dnl its command here, with the predeps/postdeps removed, and -static inserted. Postdeps are 689 dnl also overridden to prevent their insertion later. 690 dnl This should only affect dll's. 691 archive_cmds_CXX="\$CC -shared \$libobjs \$deplibs \$compiler_flags -static -o \$output_objdir/\$soname \${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib" 692 postdeps_CXX= 693 694 dnl We require Windows 7 (NT 6.1) or later 695 AX_CHECK_LINK_FLAG([-Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1"], [], [$LDFLAG_WERROR]) 696 697 dnl Avoid the use of aligned vector instructions when building for Windows. 698 dnl See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412. 699 AX_CHECK_COMPILE_FLAG([-Wa,-muse-unaligned-vector-move], [CORE_CXXFLAGS="$CORE_CXXFLAGS -Wa,-muse-unaligned-vector-move"], [], [$CXXFLAG_WERROR]) 700 ;; 701 *darwin*) 702 TARGET_OS=darwin 703 if test $cross_compiling != "yes"; then 704 BUILD_OS=darwin 705 AC_CHECK_PROG([BREW], [brew], [brew]) 706 if test "$BREW" = "brew"; then 707 dnl These Homebrew packages may be keg-only, meaning that they won't be found 708 dnl in expected paths because they may conflict with system files. Ask 709 dnl Homebrew where each one is located, then adjust paths accordingly. 710 dnl It's safe to add these paths even if the functionality is disabled by 711 dnl the user (--without-wallet or --without-gui for example). 712 713 dnl Homebrew may create symlinks in /usr/local/include for some packages. 714 dnl Because MacOS's clang internally adds "-I /usr/local/include" to its search 715 dnl paths, this will negate efforts to use -isystem for those packages, as they 716 dnl will be found first in /usr/local. Use the internal "-internal-isystem" 717 dnl option to system-ify all /usr/local/include paths without adding it to the list 718 dnl of search paths in case it's not already there. 719 if test "$suppress_external_warnings" != "no"; then 720 AX_CHECK_PREPROC_FLAG([-Xclang -internal-isystem -Xclang /usr/local/include/], [CORE_CPPFLAGS="$CORE_CPPFLAGS -Xclang -internal-isystem -Xclang /usr/local/include/"], [], [$CXXFLAG_WERROR]) 721 fi 722 723 if test "$use_bdb" != "no" && $BREW list --versions berkeley-db@4 >/dev/null && test "$BDB_CFLAGS" = "" && test "$BDB_LIBS" = ""; then 724 bdb_prefix=$($BREW --prefix berkeley-db@4 2>/dev/null) 725 dnl This must precede the call to BITCOIN_FIND_BDB48 below. 726 BDB_CFLAGS="-I$bdb_prefix/include" 727 BDB_LIBS="-L$bdb_prefix/lib -ldb_cxx-4.8" 728 fi 729 730 if $BREW list --versions qt@5 >/dev/null; then 731 export PKG_CONFIG_PATH="$($BREW --prefix qt@5 2>/dev/null)/lib/pkgconfig:$PKG_CONFIG_PATH" 732 fi 733 734 case $host in 735 *aarch64*) 736 dnl The preferred Homebrew prefix for Apple Silicon is /opt/homebrew. 737 dnl Therefore, as we do not use pkg-config to detect miniupnpc and libnatpmp 738 dnl packages, we should set the CPPFLAGS and LDFLAGS variables for them 739 dnl explicitly. 740 if test "$use_upnp" != "no" && $BREW list --versions miniupnpc >/dev/null; then 741 miniupnpc_prefix=$($BREW --prefix miniupnpc 2>/dev/null) 742 if test "$suppress_external_warnings" != "no"; then 743 MINIUPNPC_CPPFLAGS="-isystem $miniupnpc_prefix/include" 744 else 745 MINIUPNPC_CPPFLAGS="-I$miniupnpc_prefix/include" 746 fi 747 MINIUPNPC_LIBS="-L$miniupnpc_prefix/lib" 748 fi 749 if test "$use_natpmp" != "no" && $BREW list --versions libnatpmp >/dev/null; then 750 libnatpmp_prefix=$($BREW --prefix libnatpmp 2>/dev/null) 751 if test "$suppress_external_warnings" != "no"; then 752 NATPMP_CPPFLAGS="-isystem $libnatpmp_prefix/include" 753 else 754 NATPMP_CPPFLAGS="-I$libnatpmp_prefix/include" 755 fi 756 NATPMP_LIBS="-L$libnatpmp_prefix/lib" 757 fi 758 ;; 759 esac 760 fi 761 else 762 case $build_os in 763 *darwin*) 764 BUILD_OS=darwin 765 ;; 766 *) 767 AC_PATH_TOOL([DSYMUTIL], [dsymutil], [dsymutil]) 768 AC_PATH_TOOL([INSTALL_NAME_TOOL], [install_name_tool], [install_name_tool]) 769 AC_PATH_TOOL([OTOOL], [otool], [otool]) 770 AC_PATH_PROG([ZIP], [zip], [zip]) 771 772 dnl libtool will try to strip the static lib, which is a problem for 773 dnl cross-builds because strip attempts to call a hard-coded ld, 774 dnl which may not exist in the path. Stripping the .a is not 775 dnl necessary, so just disable it. 776 old_striplib= 777 ;; 778 esac 779 fi 780 781 AX_CHECK_LINK_FLAG([-Wl,-headerpad_max_install_names], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-headerpad_max_install_names"], [], [$LDFLAG_WERROR]) 782 CORE_CPPFLAGS="$CORE_CPPFLAGS -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0" 783 784 dnl ignore deprecated-declarations warnings coming from objcxx code 785 dnl "'NSUserNotificationCenter' is deprecated: first deprecated in macOS 11.0". 786 OBJCXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations" 787 ;; 788 *android*) 789 dnl make sure android stays above linux for hosts like *linux-android* 790 TARGET_OS=android 791 case $host in 792 *x86_64*) 793 ANDROID_ARCH=x86_64 794 ;; 795 *aarch64*) 796 ANDROID_ARCH=arm64-v8a 797 ;; 798 *armv7a*) 799 ANDROID_ARCH=armeabi-v7a 800 ;; 801 *) AC_MSG_ERROR([Could not determine Android arch, or it is unsupported]) ;; 802 esac 803 ;; 804 *linux*) 805 TARGET_OS=linux 806 ;; 807 esac 808 809 if test "$use_extended_functional_tests" != "no"; then 810 AC_SUBST(EXTENDED_FUNCTIONAL_TESTS, --extended) 811 fi 812 813 if test "$use_lcov" = "yes"; then 814 if test "$LCOV" = ""; then 815 AC_MSG_ERROR([lcov testing requested but lcov not found]) 816 fi 817 if test "$PYTHON" = ""; then 818 AC_MSG_ERROR([lcov testing requested but python not found]) 819 fi 820 if test "$GENHTML" = ""; then 821 AC_MSG_ERROR([lcov testing requested but genhtml not found]) 822 fi 823 824 AC_MSG_CHECKING([whether compiler is Clang]) 825 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ 826 #if defined(__clang__) && defined(__llvm__) 827 // Compiler is Clang 828 #else 829 # error Compiler is not Clang 830 #endif 831 ]])],[ 832 AC_MSG_RESULT([yes]) 833 if test "$LLVM_COV" = ""; then 834 AC_MSG_ERROR([lcov testing requested but llvm-cov not found]) 835 fi 836 COV_TOOL="$LLVM_COV gcov" 837 ],[ 838 AC_MSG_RESULT([no]) 839 if test "$GCOV" = "x"; then 840 AC_MSG_ERROR([lcov testing requested but gcov not found]) 841 fi 842 COV_TOOL="$GCOV" 843 ]) 844 AC_SUBST(COV_TOOL) 845 AC_SUBST(COV_TOOL_WRAPPER, "cov_tool_wrapper.sh") 846 LCOV="$LCOV --gcov-tool $(pwd)/$COV_TOOL_WRAPPER" 847 848 AX_CHECK_LINK_FLAG([--coverage], [CORE_LDFLAGS="$CORE_LDFLAGS --coverage"], 849 [AC_MSG_ERROR([lcov testing requested but --coverage linker flag does not work])]) 850 AX_CHECK_COMPILE_FLAG([--coverage],[CORE_CXXFLAGS="$CORE_CXXFLAGS --coverage"], 851 [AC_MSG_ERROR([lcov testing requested but --coverage flag does not work])]) 852 CORE_CXXFLAGS="$CORE_CXXFLAGS -Og" 853 fi 854 855 if test "$use_lcov_branch" != "no"; then 856 AC_SUBST(LCOV_OPTS, "$LCOV_OPTS --rc lcov_branch_coverage=1") 857 fi 858 859 dnl Check for endianness 860 AC_C_BIGENDIAN 861 862 dnl Check for pthread compile/link requirements 863 AX_PTHREAD 864 865 dnl Check if -latomic is required for <std::atomic> 866 CHECK_ATOMIC 867 868 dnl The following macro will add the necessary defines to bitcoin-config.h, but 869 dnl they also need to be passed down to any subprojects. Pull the results out of 870 dnl the cache and add them to CPPFLAGS. 871 AC_SYS_LARGEFILE 872 dnl detect POSIX or GNU variant of strerror_r 873 AC_FUNC_STRERROR_R 874 875 if test "$ac_cv_sys_file_offset_bits" != "" && 876 test "$ac_cv_sys_file_offset_bits" != "no" && 877 test "$ac_cv_sys_file_offset_bits" != "unknown"; then 878 CORE_CPPFLAGS="$CORE_CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits" 879 fi 880 881 if test "$ac_cv_sys_large_files" != "" && 882 test "$ac_cv_sys_large_files" != "no" && 883 test "$ac_cv_sys_large_files" != "unknown"; then 884 CORE_CPPFLAGS="$CORE_CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files" 885 fi 886 887 if test "$enable_gprof" = "yes"; then 888 dnl -pg is incompatible with -pie. Since hardening and profiling together doesn't make sense, 889 dnl we simply make them mutually exclusive here. Additionally, hardened toolchains may force 890 dnl -pie by default, in which case it needs to be turned off with -no-pie. 891 892 if test "$use_hardening" = "yes"; then 893 AC_MSG_ERROR([gprof profiling is not compatible with hardening. Reconfigure with --disable-hardening or --disable-gprof]) 894 fi 895 use_hardening=no 896 AX_CHECK_COMPILE_FLAG([-pg],[GPROF_CXXFLAGS="-pg"], 897 [AC_MSG_ERROR([gprof profiling requested but not available])], [$CXXFLAG_WERROR]) 898 899 AX_CHECK_LINK_FLAG([-no-pie], [GPROF_LDFLAGS="-no-pie"]) 900 AX_CHECK_LINK_FLAG([-pg], [GPROF_LDFLAGS="$GPROF_LDFLAGS -pg"], 901 [AC_MSG_ERROR([gprof profiling requested but not available])], [$GPROF_LDFLAGS]) 902 fi 903 904 if test "$TARGET_OS" != "windows"; then 905 dnl All windows code is PIC, forcing it on just adds useless compile warnings 906 AX_CHECK_COMPILE_FLAG([-fPIC], [PIC_FLAGS="-fPIC"]) 907 fi 908 909 if test "$use_hardening" != "no"; then 910 use_hardening=yes 911 AX_CHECK_COMPILE_FLAG([-Wstack-protector], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"]) 912 AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"]) 913 914 AX_CHECK_COMPILE_FLAG([-fcf-protection=full], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fcf-protection=full"]) 915 916 case $host in 917 *mingw*) 918 dnl stack-clash-protection doesn't compile with GCC 10 and earlier. 919 dnl In any case, it is a no-op for Windows. 920 dnl See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458 for more details. 921 ;; 922 *) 923 AX_CHECK_COMPILE_FLAG([-fstack-clash-protection], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-clash-protection"], [], [$CXXFLAG_WERROR]) 924 ;; 925 esac 926 927 case $host in 928 *aarch64*) 929 AX_CHECK_COMPILE_FLAG([-mbranch-protection=bti], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -mbranch-protection=bti"]) 930 ;; 931 esac 932 933 dnl When enable_debug is yes, all optimizations are disabled. 934 dnl However, FORTIFY_SOURCE requires that there is some level of optimization, otherwise it does nothing and just creates a compiler warning. 935 dnl Since FORTIFY_SOURCE is a no-op without optimizations, do not enable it when enable_debug is yes. 936 if test "$enable_debug" != "yes"; then 937 AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=3],[ 938 AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[ 939 HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE" 940 ]) 941 HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=3" 942 ]) 943 fi 944 945 AX_CHECK_LINK_FLAG([-Wl,--enable-reloc-section], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--enable-reloc-section"], [], [$LDFLAG_WERROR]) 946 AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"], [], [$LDFLAG_WERROR]) 947 AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"], [], [$LDFLAG_WERROR]) 948 AX_CHECK_LINK_FLAG([-Wl,--high-entropy-va], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--high-entropy-va"], [], [$LDFLAG_WERROR]) 949 AX_CHECK_LINK_FLAG([-Wl,-z,relro], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"], [], [$LDFLAG_WERROR]) 950 AX_CHECK_LINK_FLAG([-Wl,-z,now], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"], [], [$LDFLAG_WERROR]) 951 AX_CHECK_LINK_FLAG([-Wl,-z,separate-code], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,separate-code"], [], [$LDFLAG_WERROR]) 952 AX_CHECK_LINK_FLAG([-fPIE -pie], [PIE_FLAGS="-fPIE"; HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"], [], [$CXXFLAG_WERROR]) 953 fi 954 955 dnl These flags are specific to ld64, and may cause issues with other linkers. 956 dnl For example: GNU ld will interpret -dead_strip as -de and then try and use 957 dnl "ad_strip" as the symbol for the entry point. 958 if test "$TARGET_OS" = "darwin"; then 959 AX_CHECK_LINK_FLAG([-Wl,-dead_strip], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-dead_strip"], [], [$LDFLAG_WERROR]) 960 AX_CHECK_LINK_FLAG([-Wl,-dead_strip_dylibs], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-dead_strip_dylibs"], [], [$LDFLAG_WERROR]) 961 AX_CHECK_LINK_FLAG([-Wl,-fixup_chains], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-fixup_chains"], [], [$LDFLAG_WERROR]) 962 fi 963 964 AC_CHECK_HEADERS([sys/select.h sys/prctl.h sys/sysctl.h vm/vm_param.h sys/vmmeter.h sys/resources.h]) 965 966 AC_CHECK_DECLS([getifaddrs, freeifaddrs],[CHECK_SOCKET],, 967 [#include <sys/types.h> 968 #include <ifaddrs.h>] 969 ) 970 971 dnl These are used for daemonization in bitcoind 972 AC_CHECK_DECLS([fork]) 973 AC_CHECK_DECLS([setsid]) 974 975 AC_CHECK_DECLS([pipe2]) 976 977 AC_CHECK_FUNCS([timingsafe_bcmp]) 978 979 AC_MSG_CHECKING([for __builtin_clzl]) 980 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ 981 (void) __builtin_clzl(0); 982 ]])], 983 [ AC_MSG_RESULT([yes]); have_clzl=yes; AC_DEFINE([HAVE_BUILTIN_CLZL], [1], [Define this symbol if you have __builtin_clzl])], 984 [ AC_MSG_RESULT([no]); have_clzl=no;] 985 ) 986 987 AC_MSG_CHECKING([for __builtin_clzll]) 988 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ 989 (void) __builtin_clzll(0); 990 ]])], 991 [ AC_MSG_RESULT([yes]); have_clzll=yes; AC_DEFINE([HAVE_BUILTIN_CLZLL], [1], [Define this symbol if you have __builtin_clzll])], 992 [ AC_MSG_RESULT([no]); have_clzll=no;] 993 ) 994 995 dnl Check for malloc_info (for memory statistics information in getmemoryinfo) 996 AC_MSG_CHECKING([for getmemoryinfo]) 997 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]], 998 [[ int f = malloc_info(0, NULL); ]])], 999 [ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_MALLOC_INFO], [1], [Define this symbol if you have malloc_info]) ], 1000 [ AC_MSG_RESULT([no])] 1001 ) 1002 1003 dnl Check for mallopt(M_ARENA_MAX) (to set glibc arenas) 1004 AC_MSG_CHECKING([for mallopt M_ARENA_MAX]) 1005 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]], 1006 [[ mallopt(M_ARENA_MAX, 1); ]])], 1007 [ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_MALLOPT_ARENA_MAX], [1], [Define this symbol if you have mallopt with M_ARENA_MAX]) ], 1008 [ AC_MSG_RESULT([no])] 1009 ) 1010 1011 dnl Check for posix_fallocate 1012 AC_MSG_CHECKING([for posix_fallocate]) 1013 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1014 // same as in src/util/fs_helpers.cpp 1015 #ifdef __linux__ 1016 #ifdef _POSIX_C_SOURCE 1017 #undef _POSIX_C_SOURCE 1018 #endif 1019 #define _POSIX_C_SOURCE 200112L 1020 #endif // __linux__ 1021 #include <fcntl.h>]], 1022 [[ int f = posix_fallocate(0, 0, 0); ]])], 1023 [ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_POSIX_FALLOCATE], [1], [Define this symbol if you have posix_fallocate]) ], 1024 [ AC_MSG_RESULT([no])] 1025 ) 1026 1027 AC_MSG_CHECKING([for default visibility attribute]) 1028 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 1029 int foo(void) __attribute__((visibility("default"))); 1030 int main(){} 1031 ])], 1032 [ 1033 AC_DEFINE([HAVE_DEFAULT_VISIBILITY_ATTRIBUTE], [1], [Define if the visibility attribute is supported.]) 1034 AC_MSG_RESULT([yes]) 1035 ], 1036 [ 1037 AC_MSG_RESULT([no]) 1038 if test "$use_reduce_exports" = "yes"; then 1039 AC_MSG_ERROR([Cannot find a working visibility attribute. Use --disable-reduce-exports.]) 1040 fi 1041 ] 1042 ) 1043 1044 AC_MSG_CHECKING([for dllexport attribute]) 1045 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 1046 __declspec(dllexport) int foo(void); 1047 int main(){} 1048 ])], 1049 [ 1050 AC_DEFINE([HAVE_DLLEXPORT_ATTRIBUTE], [1], [Define if the dllexport attribute is supported.]) 1051 AC_MSG_RESULT([yes]) 1052 ], 1053 [AC_MSG_RESULT([no])] 1054 ) 1055 1056 if test "$use_thread_local" = "yes" || test "$use_thread_local" = "auto"; then 1057 TEMP_LDFLAGS="$LDFLAGS" 1058 LDFLAGS="$TEMP_LDFLAGS $PTHREAD_CFLAGS" 1059 AC_MSG_CHECKING([for thread_local support]) 1060 AC_LINK_IFELSE([AC_LANG_SOURCE([ 1061 #include <thread> 1062 static thread_local int foo = 0; 1063 static void run_thread() { foo++;} 1064 int main(){ 1065 for(int i = 0; i < 10; i++) { std::thread(run_thread).detach();} 1066 return foo; 1067 } 1068 ])], 1069 [ 1070 case $host in 1071 *mingw*) 1072 dnl mingw32's implementation of thread_local has also been shown to behave 1073 dnl erroneously under concurrent usage; see: 1074 dnl https://gist.github.com/jamesob/fe9a872051a88b2025b1aa37bfa98605 1075 AC_MSG_RESULT([no]) 1076 ;; 1077 *freebsd*) 1078 dnl FreeBSD's implementation of thread_local is also buggy (per 1079 dnl https://groups.google.com/d/msg/bsdmailinglist/22ncTZAbDp4/Dii_pII5AwAJ) 1080 AC_MSG_RESULT([no]) 1081 ;; 1082 *) 1083 AC_DEFINE([HAVE_THREAD_LOCAL], [1], [Define if thread_local is supported.]) 1084 AC_MSG_RESULT([yes]) 1085 ;; 1086 esac 1087 ], 1088 [ 1089 AC_MSG_RESULT([no]) 1090 ] 1091 ) 1092 LDFLAGS="$TEMP_LDFLAGS" 1093 fi 1094 1095 dnl check for gmtime_r(), fallback to gmtime_s() if that is unavailable 1096 dnl fail if neither are available. 1097 AC_MSG_CHECKING([for gmtime_r]) 1098 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <ctime>]], 1099 [[ gmtime_r((const time_t *) nullptr, (struct tm *) nullptr); ]])], 1100 [ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_GMTIME_R], [1], [Define this symbol if gmtime_r is available]) ], 1101 [ AC_MSG_RESULT([no]); 1102 AC_MSG_CHECKING([for gmtime_s]); 1103 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <ctime>]], 1104 [[ gmtime_s((struct tm *) nullptr, (const time_t *) nullptr); ]])], 1105 [ AC_MSG_RESULT([yes])], 1106 [ AC_MSG_RESULT([no]); AC_MSG_ERROR([Both gmtime_r and gmtime_s are unavailable]) ] 1107 ) 1108 ] 1109 ) 1110 1111 dnl Check for different ways of gathering OS randomness 1112 AC_MSG_CHECKING([for Linux getrandom function]) 1113 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1114 #include <sys/random.h>]], 1115 [[ getrandom(nullptr, 32, 0); ]])], 1116 [ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_GETRANDOM], [1], [Define this symbol if the Linux getrandom function call is available]) ], 1117 [ AC_MSG_RESULT([no])] 1118 ) 1119 1120 AC_MSG_CHECKING([for getentropy via sys/random.h]) 1121 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1122 #include <sys/random.h>]], 1123 [[ getentropy(nullptr, 32) ]])], 1124 [ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_GETENTROPY_RAND], [1], [Define this symbol if the BSD getentropy system call is available with sys/random.h]) ], 1125 [ AC_MSG_RESULT([no])] 1126 ) 1127 1128 AC_MSG_CHECKING([for sysctl]) 1129 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 1130 #include <sys/sysctl.h>]], 1131 [[ #ifdef __linux__ 1132 #error "Don't use sysctl on Linux, it's deprecated even when it works" 1133 #endif 1134 sysctl(nullptr, 2, nullptr, nullptr, nullptr, 0); ]])], 1135 [ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_SYSCTL], [1], [Define this symbol if the BSD sysctl() is available]) ], 1136 [ AC_MSG_RESULT([no])] 1137 ) 1138 1139 AC_MSG_CHECKING([for sysctl KERN_ARND]) 1140 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 1141 #include <sys/sysctl.h>]], 1142 [[ #ifdef __linux__ 1143 #error "Don't use sysctl on Linux, it's deprecated even when it works" 1144 #endif 1145 static int name[2] = {CTL_KERN, KERN_ARND}; 1146 sysctl(name, 2, nullptr, nullptr, nullptr, 0); ]])], 1147 [ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_SYSCTL_ARND], [1], [Define this symbol if the BSD sysctl(KERN_ARND) is available]) ], 1148 [ AC_MSG_RESULT([no])] 1149 ) 1150 1151 AC_MSG_CHECKING([for fdatasync]) 1152 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], 1153 [[ fdatasync(0); ]])], 1154 [ AC_MSG_RESULT([yes]); HAVE_FDATASYNC=1 ], 1155 [ AC_MSG_RESULT([no]); HAVE_FDATASYNC=0 ] 1156 ) 1157 AC_DEFINE_UNQUOTED([HAVE_FDATASYNC], [$HAVE_FDATASYNC], [Define to 1 if fdatasync is available.]) 1158 1159 AC_MSG_CHECKING([for F_FULLFSYNC]) 1160 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <fcntl.h>]], 1161 [[ fcntl(0, F_FULLFSYNC, 0); ]])], 1162 [ AC_MSG_RESULT([yes]); HAVE_FULLFSYNC=1 ], 1163 [ AC_MSG_RESULT([no]); HAVE_FULLFSYNC=0 ] 1164 ) 1165 1166 AC_MSG_CHECKING([for O_CLOEXEC]) 1167 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <fcntl.h>]], 1168 [[ open("", O_CLOEXEC); ]])], 1169 [ AC_MSG_RESULT([yes]); HAVE_O_CLOEXEC=1 ], 1170 [ AC_MSG_RESULT([no]); HAVE_O_CLOEXEC=0 ] 1171 ) 1172 AC_DEFINE_UNQUOTED([HAVE_O_CLOEXEC], [$HAVE_O_CLOEXEC], [Define to 1 if O_CLOEXEC flag is available.]) 1173 1174 dnl crc32c platform checks 1175 AC_MSG_CHECKING([for __builtin_prefetch]) 1176 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ 1177 char data = 0; 1178 const char* address = &data; 1179 __builtin_prefetch(address, 0, 0); 1180 ]])], 1181 [ AC_MSG_RESULT([yes]); HAVE_BUILTIN_PREFETCH=1 ], 1182 [ AC_MSG_RESULT([no]); HAVE_BUILTIN_PREFETCH=0 ] 1183 ) 1184 1185 AC_MSG_CHECKING([for _mm_prefetch]) 1186 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xmmintrin.h>]], [[ 1187 char data = 0; 1188 const char* address = &data; 1189 _mm_prefetch(address, _MM_HINT_NTA); 1190 ]])], 1191 [ AC_MSG_RESULT([yes]); HAVE_MM_PREFETCH=1 ], 1192 [ AC_MSG_RESULT([no]); HAVE_MM_PREFETCH=0 ] 1193 ) 1194 1195 AC_MSG_CHECKING([for strong getauxval support in the system headers]) 1196 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1197 #include <sys/auxv.h> 1198 ]], [[ 1199 getauxval(AT_HWCAP); 1200 ]])], 1201 [ AC_MSG_RESULT([yes]); HAVE_STRONG_GETAUXVAL=1; AC_DEFINE([HAVE_STRONG_GETAUXVAL], [1], [Define this symbol to build code that uses getauxval]) ], 1202 [ AC_MSG_RESULT([no]); HAVE_STRONG_GETAUXVAL=0 ] 1203 ) 1204 1205 # Check for UNIX sockets 1206 AC_MSG_CHECKING(for sockaddr_un) 1207 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1208 #include <sys/socket.h> 1209 #include <sys/un.h> 1210 ]], [[ 1211 struct sockaddr_un addr; 1212 addr.sun_family = AF_UNIX; 1213 ]])], 1214 [ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_SOCKADDR_UN], [1], [Define this symbol if platform supports unix domain sockets]) ], 1215 [ AC_MSG_RESULT([no]); ] 1216 ) 1217 1218 have_any_system=no 1219 AC_MSG_CHECKING([for std::system]) 1220 AC_LINK_IFELSE( 1221 [ AC_LANG_PROGRAM( 1222 [[ #include <cstdlib> ]], 1223 [[ int nErr = std::system(""); ]] 1224 )], 1225 [ AC_MSG_RESULT([yes]); have_any_system=yes], 1226 [ AC_MSG_RESULT([no]) ] 1227 ) 1228 1229 AC_MSG_CHECKING([for ::_wsystem]) 1230 AC_LINK_IFELSE( 1231 [ AC_LANG_PROGRAM( 1232 [[ #include <stdlib.h> ]], 1233 [[ int nErr = ::_wsystem(NULL); ]] 1234 )], 1235 [ AC_MSG_RESULT([yes]); have_any_system=yes], 1236 [ AC_MSG_RESULT([no]) ] 1237 ) 1238 1239 if test "$have_any_system" != "no"; then 1240 AC_DEFINE([HAVE_SYSTEM], [1], [Define to 1 if std::system or ::wsystem is available.]) 1241 fi 1242 1243 dnl SUPPRESSED_CPPFLAGS=SUPPRESS_WARNINGS([$SOME_CPPFLAGS]) 1244 dnl Replace -I with -isystem in $SOME_CPPFLAGS to suppress warnings from 1245 dnl headers from its include directories and return the result. 1246 dnl See -isystem documentation: 1247 dnl https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html 1248 dnl https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-isystem-directory 1249 dnl Do not change "-I/usr/include" to "-isystem /usr/include" because that 1250 dnl is not necessary (/usr/include is already a system directory) and because 1251 dnl it would break GCC's #include_next. 1252 AC_DEFUN([SUPPRESS_WARNINGS], 1253 [[$(echo $1 |${SED} -E -e 's/(^| )-I/\1-isystem /g' -e 's;-isystem /usr/include/*( |$);-I/usr/include\1;g')]]) 1254 1255 dnl enable-fuzz should disable all other targets 1256 if test "$enable_fuzz" = "yes"; then 1257 AC_MSG_WARN([enable-fuzz will disable all other targets and force --enable-fuzz-binary=yes]) 1258 build_bitcoin_utils=no 1259 build_bitcoin_cli=no 1260 build_bitcoin_tx=no 1261 build_bitcoin_util=no 1262 build_bitcoin_chainstate=no 1263 build_bitcoin_wallet=no 1264 build_bitcoind=no 1265 build_bitcoin_libs=no 1266 bitcoin_enable_qt=no 1267 bitcoin_enable_qt_test=no 1268 bitcoin_enable_qt_dbus=no 1269 use_bench=no 1270 use_tests=no 1271 use_external_signer=no 1272 use_upnp=no 1273 use_natpmp=no 1274 use_zmq=no 1275 enable_fuzz_binary=yes 1276 1277 AX_CHECK_PREPROC_FLAG([-DABORT_ON_FAILED_ASSUME], [DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DABORT_ON_FAILED_ASSUME"], [], [$CXXFLAG_WERROR]) 1278 else 1279 BITCOIN_QT_INIT 1280 1281 dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus 1282 BITCOIN_QT_CONFIGURE([5.11.3]) 1283 1284 dnl Keep a copy of the original $QT_INCLUDES and use it when invoking qt's moc 1285 QT_INCLUDES_UNSUPPRESSED=$QT_INCLUDES 1286 if test "$suppress_external_warnings" != "no" ; then 1287 QT_INCLUDES=SUPPRESS_WARNINGS($QT_INCLUDES) 1288 QT_DBUS_INCLUDES=SUPPRESS_WARNINGS($QT_DBUS_INCLUDES) 1289 QT_TEST_INCLUDES=SUPPRESS_WARNINGS($QT_TEST_INCLUDES) 1290 fi 1291 fi 1292 1293 if test "$enable_fuzz_binary" = "yes"; then 1294 AC_MSG_CHECKING([whether main function is needed for fuzz binary]) 1295 AX_CHECK_LINK_FLAG( 1296 [], 1297 [AC_MSG_RESULT([no])], 1298 [AC_MSG_RESULT([yes]); CORE_CPPFLAGS="$CORE_CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION"], 1299 [$SANITIZER_LDFLAGS], 1300 [AC_LANG_PROGRAM([[ 1301 #include <cstdint> 1302 #include <cstddef> 1303 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { return 0; } 1304 /* comment to remove the main function ... 1305 ]],[[ 1306 */ int not_main() { 1307 ]])]) 1308 fi 1309 1310 if test "$enable_wallet" != "no"; then 1311 dnl Check for libdb_cxx only if wallet enabled 1312 if test "$use_bdb" != "no"; then 1313 BITCOIN_FIND_BDB48 1314 if test "$suppress_external_warnings" != "no" ; then 1315 BDB_CPPFLAGS=SUPPRESS_WARNINGS($BDB_CPPFLAGS) 1316 fi 1317 fi 1318 1319 dnl Check for sqlite3 1320 if test "$use_sqlite" != "no"; then 1321 PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.7.17], [have_sqlite=yes], [have_sqlite=no]) 1322 fi 1323 AC_MSG_CHECKING([whether to build wallet with support for sqlite]) 1324 if test "$use_sqlite" = "no"; then 1325 use_sqlite=no 1326 elif test "$have_sqlite" = "no"; then 1327 if test "$use_sqlite" = "yes"; then 1328 AC_MSG_ERROR([sqlite support requested but cannot be built. Use --without-sqlite]) 1329 fi 1330 use_sqlite=no 1331 else 1332 if test "$use_sqlite" != "no"; then 1333 AC_DEFINE([USE_SQLITE],[1],[Define if sqlite support should be compiled in]) 1334 use_sqlite=yes 1335 fi 1336 fi 1337 AC_MSG_RESULT([$use_sqlite]) 1338 1339 dnl Disable wallet if both --without-bdb and --without-sqlite 1340 if test "$use_bdb$use_sqlite" = "nono"; then 1341 if test "$enable_wallet" = "yes"; then 1342 AC_MSG_ERROR([wallet functionality requested but no BDB or SQLite support available.]) 1343 fi 1344 enable_wallet=no 1345 fi 1346 fi 1347 1348 if test "$use_usdt" != "no"; then 1349 AC_MSG_CHECKING([whether Userspace, Statically Defined Tracing tracepoints are supported]) 1350 AC_COMPILE_IFELSE([ 1351 AC_LANG_PROGRAM( 1352 [#include <sys/sdt.h>], 1353 [DTRACE_PROBE(context, event); 1354 int a, b, c, d, e, f, g; 1355 DTRACE_PROBE7(context, event, a, b, c, d, e, f, g);] 1356 )], 1357 [AC_MSG_RESULT([yes]); AC_DEFINE([ENABLE_TRACING], [1], [Define to 1 to enable tracepoints for Userspace, Statically Defined Tracing])], 1358 [AC_MSG_RESULT([no]); use_usdt=no;] 1359 ) 1360 fi 1361 AM_CONDITIONAL([ENABLE_USDT_TRACEPOINTS], [test "$use_usdt" = "yes"]) 1362 1363 if test "$build_bitcoind$bitcoin_enable_qt$use_bench$use_tests" = "nononono"; then 1364 use_upnp=no 1365 use_natpmp=no 1366 use_zmq=no 1367 fi 1368 1369 dnl Check for libminiupnpc (optional) 1370 if test "$use_upnp" != "no"; then 1371 TEMP_CPPFLAGS="$CPPFLAGS" 1372 CPPFLAGS="$CPPFLAGS $MINIUPNPC_CPPFLAGS" 1373 AC_CHECK_HEADERS([miniupnpc/miniupnpc.h miniupnpc/upnpcommands.h miniupnpc/upnperrors.h], [], [have_miniupnpc=no]) 1374 1375 if test "$have_miniupnpc" != "no"; then 1376 AC_CHECK_LIB([miniupnpc], [upnpDiscover], [MINIUPNPC_LIBS="$MINIUPNPC_LIBS -lminiupnpc"], [have_miniupnpc=no], [$MINIUPNPC_LIBS]) 1377 1378 dnl The minimum supported miniUPnPc API version is set to 17. This excludes 1379 dnl versions with known vulnerabilities. 1380 AC_MSG_CHECKING([whether miniUPnPc API version is supported]) 1381 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[ 1382 @%:@include <miniupnpc/miniupnpc.h> 1383 ]], [[ 1384 #if MINIUPNPC_API_VERSION >= 17 1385 // Everything is okay 1386 #else 1387 # error miniUPnPc API version is too old 1388 #endif 1389 ]])],[ 1390 AC_MSG_RESULT([yes]) 1391 ],[ 1392 AC_MSG_RESULT([no]) 1393 AC_MSG_WARN([miniUPnPc API version < 17 is unsupported, disabling UPnP support.]) 1394 have_miniupnpc=no 1395 ]) 1396 fi 1397 CPPFLAGS="$TEMP_CPPFLAGS" 1398 fi 1399 1400 dnl Check for libnatpmp (optional). 1401 if test "$use_natpmp" != "no"; then 1402 TEMP_CPPFLAGS="$CPPFLAGS" 1403 CPPFLAGS="$CPPFLAGS $NATPMP_CPPFLAGS" 1404 AC_CHECK_HEADERS([natpmp.h], [], [have_natpmp=no]) 1405 1406 if test "$have_natpmp" != "no"; then 1407 AC_CHECK_LIB([natpmp], [initnatpmp], [NATPMP_LIBS="$NATPMP_LIBS -lnatpmp"], [have_natpmp=no], [$NATPMP_LIBS]) 1408 fi 1409 1410 CPPFLAGS="$TEMP_CPPFLAGS" 1411 fi 1412 1413 if test "$build_bitcoin_wallet$build_bitcoin_cli$build_bitcoin_tx$build_bitcoin_util$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench$enable_fuzz_binary" = "nonononononononono"; then 1414 use_boost=no 1415 else 1416 use_boost=yes 1417 fi 1418 1419 if test "$use_boost" = "yes"; then 1420 1421 dnl Check for Boost headers 1422 AX_BOOST_BASE([1.73.0],[],[AC_MSG_ERROR([Boost is not available!])]) 1423 if test "$want_boost" = "no"; then 1424 AC_MSG_ERROR([only libbitcoinconsensus can be built without Boost]) 1425 fi 1426 1427 dnl we don't use multi_index serialization 1428 BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION" 1429 1430 dnl Prevent use of std::unary_function, which was removed in C++17, 1431 dnl and will generate warnings with newer compilers for Boost 1432 dnl older than 1.80. 1433 dnl See: https://github.com/boostorg/config/pull/430. 1434 AX_CHECK_PREPROC_FLAG([-DBOOST_NO_CXX98_FUNCTION_BASE], [BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_NO_CXX98_FUNCTION_BASE"], [], [$CXXFLAG_WERROR], 1435 [AC_LANG_PROGRAM([[#include <boost/config.hpp>]])]) 1436 1437 if test "$suppress_external_warnings" != "no"; then 1438 BOOST_CPPFLAGS=SUPPRESS_WARNINGS($BOOST_CPPFLAGS) 1439 fi 1440 fi 1441 1442 if test "$use_external_signer" != "no"; then 1443 AC_MSG_CHECKING([whether Boost.Process can be used]) 1444 TEMP_CXXFLAGS="$CXXFLAGS" 1445 dnl Boost 1.78 requires the following workaround. 1446 dnl See: https://github.com/boostorg/process/issues/235 1447 CXXFLAGS="$CXXFLAGS -Wno-error=narrowing" 1448 TEMP_CPPFLAGS="$CPPFLAGS" 1449 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" 1450 TEMP_LDFLAGS="$LDFLAGS" 1451 dnl Boost 1.73 and older require the following workaround. 1452 LDFLAGS="$LDFLAGS $PTHREAD_CFLAGS" 1453 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 1454 #define BOOST_PROCESS_USE_STD_FS 1455 #include <boost/process.hpp> 1456 ]],[[ 1457 namespace bp = boost::process; 1458 bp::opstream stdin_stream; 1459 bp::ipstream stdout_stream; 1460 bp::child c("dummy", bp::std_out > stdout_stream, bp::std_err > stdout_stream, bp::std_in < stdin_stream); 1461 stdin_stream << std::string{"test"} << std::endl; 1462 if (c.running()) c.terminate(); 1463 c.wait(); 1464 c.exit_code(); 1465 ]])], 1466 [have_boost_process="yes"], 1467 [have_boost_process="no"]) 1468 LDFLAGS="$TEMP_LDFLAGS" 1469 CPPFLAGS="$TEMP_CPPFLAGS" 1470 CXXFLAGS="$TEMP_CXXFLAGS" 1471 AC_MSG_RESULT([$have_boost_process]) 1472 if test "$have_boost_process" = "yes"; then 1473 case $host in 1474 dnl Boost Process for Windows uses Boost ASIO. Boost ASIO performs 1475 dnl pre-main init of Windows networking libraries, which we do not 1476 dnl want. 1477 *mingw*) 1478 use_external_signer="no" 1479 ;; 1480 *) 1481 use_external_signer="yes" 1482 AC_DEFINE([ENABLE_EXTERNAL_SIGNER], [1], [Define if external signer support is enabled]) 1483 AC_DEFINE([BOOST_PROCESS_USE_STD_FS], [1], [Defined to avoid Boost::Process trying to use Boost Filesystem]) 1484 ;; 1485 esac 1486 else 1487 if test "$use_external_signer" = "yes"; then 1488 AC_MSG_ERROR([External signing is not supported for this Boost version]) 1489 fi 1490 use_external_signer="no"; 1491 fi 1492 fi 1493 AM_CONDITIONAL([ENABLE_EXTERNAL_SIGNER], [test "$use_external_signer" = "yes"]) 1494 1495 dnl Check for reduced exports 1496 if test "$use_reduce_exports" = "yes"; then 1497 AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], [CORE_CXXFLAGS="$CORE_CXXFLAGS -fvisibility=hidden"], 1498 [AC_MSG_ERROR([Cannot set hidden symbol visibility. Use --disable-reduce-exports.])], [$CXXFLAG_WERROR]) 1499 AX_CHECK_LINK_FLAG([-Wl,--exclude-libs,ALL], [RELDFLAGS="-Wl,--exclude-libs,ALL"], [], [$LDFLAG_WERROR]) 1500 fi 1501 1502 if test "$use_tests" = "yes"; then 1503 1504 if test "$HEXDUMP" = ""; then 1505 AC_MSG_ERROR([hexdump is required for tests]) 1506 fi 1507 fi 1508 1509 dnl libevent check 1510 1511 use_libevent=no 1512 if test "$build_bitcoin_cli$build_bitcoind$bitcoin_enable_qt$enable_fuzz_binary$use_tests$use_bench" != "nononononono"; then 1513 PKG_CHECK_MODULES([EVENT], [libevent >= 2.1.8], [use_libevent=yes], [AC_MSG_ERROR([libevent version 2.1.8 or greater not found.])]) 1514 if test "$TARGET_OS" != "windows"; then 1515 PKG_CHECK_MODULES([EVENT_PTHREADS], [libevent_pthreads >= 2.1.8], [], [AC_MSG_ERROR([libevent_pthreads version 2.1.8 or greater not found.])]) 1516 fi 1517 1518 if test "$suppress_external_warnings" != "no"; then 1519 EVENT_CFLAGS=SUPPRESS_WARNINGS($EVENT_CFLAGS) 1520 fi 1521 fi 1522 1523 if test x$use_libevent = xyes; then 1524 TEMP_CXXFLAGS="$CXXFLAGS" 1525 CXXFLAGS="$CXXFLAGS $EVENT_CFLAGS" 1526 AC_MSG_CHECKING([if evhttp_connection_get_peer expects const char**]) 1527 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1528 #include <cstdint> 1529 #include <event2/http.h> 1530 ]], [[ 1531 evhttp_connection *conn = (evhttp_connection *)1; 1532 const char *host; 1533 uint16_t port; 1534 1535 evhttp_connection_get_peer(conn, &host, &port); 1536 ]])], 1537 [ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR], [1], [Define this symbol if evhttp_connection_get_peer expects const char**]) ], 1538 [ AC_MSG_RESULT([no]) ] 1539 ) 1540 CXXFLAGS="$TEMP_CXXFLAGS" 1541 fi 1542 1543 dnl QR Code encoding library check 1544 1545 if test "$use_qr" != "no"; then 1546 BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])]) 1547 fi 1548 1549 dnl ZMQ check 1550 1551 if test "$use_zmq" = "yes"; then 1552 PKG_CHECK_MODULES([ZMQ], [libzmq >= 4], 1553 AC_DEFINE([ENABLE_ZMQ], [1], [Define this symbol to enable ZMQ functions]), 1554 [AC_MSG_WARN([libzmq version 4.x or greater not found, disabling]) 1555 use_zmq=no]) 1556 fi 1557 1558 if test "$use_zmq" = "yes"; then 1559 dnl Assume libzmq was built for static linking 1560 case $host in 1561 *mingw*) 1562 ZMQ_CFLAGS="$ZMQ_CFLAGS -DZMQ_STATIC" 1563 ;; 1564 esac 1565 fi 1566 1567 AM_CONDITIONAL([ENABLE_ZMQ], [test "$use_zmq" = "yes"]) 1568 1569 dnl libmultiprocess library check 1570 1571 libmultiprocess_found=no 1572 if test "$with_libmultiprocess" = "yes" || test "$with_libmultiprocess" = "auto"; then 1573 PKG_CHECK_MODULES([LIBMULTIPROCESS], [libmultiprocess], [ 1574 libmultiprocess_found=yes; 1575 libmultiprocess_prefix=`$PKG_CONFIG --variable=prefix libmultiprocess`; 1576 ], [true]) 1577 elif test "$with_libmultiprocess" != "no"; then 1578 AC_MSG_ERROR([--with-libmultiprocess=$with_libmultiprocess value is not yes, auto, or no]) 1579 fi 1580 1581 dnl Enable multiprocess check 1582 1583 if test "$enable_multiprocess" = "yes"; then 1584 if test "$libmultiprocess_found" != "yes"; then 1585 AC_MSG_ERROR([--enable-multiprocess=yes option specified but libmultiprocess library was not found. May need to install libmultiprocess library, or specify install path with PKG_CONFIG_PATH environment variable. Running 'pkg-config --debug libmultiprocess' may be helpful for debugging.]) 1586 fi 1587 build_multiprocess=yes 1588 elif test "$enable_multiprocess" = "auto"; then 1589 build_multiprocess=$libmultiprocess_found 1590 else 1591 build_multiprocess=no 1592 fi 1593 1594 AM_CONDITIONAL([BUILD_MULTIPROCESS], [test "$build_multiprocess" = "yes"]) 1595 AM_CONDITIONAL([BUILD_BITCOIN_NODE], [test "$build_multiprocess" = "yes"]) 1596 AM_CONDITIONAL([BUILD_BITCOIN_GUI], [test "$build_multiprocess" = "yes"]) 1597 1598 dnl codegen tools check 1599 1600 if test "$build_multiprocess" != "no"; then 1601 if test "$with_mpgen" = "yes" || test "$with_mpgen" = "auto"; then 1602 MPGEN_PREFIX="$libmultiprocess_prefix" 1603 elif test "$with_mpgen" != "no"; then 1604 MPGEN_PREFIX="$with_mpgen"; 1605 fi 1606 AC_SUBST(MPGEN_PREFIX) 1607 fi 1608 1609 AC_MSG_CHECKING([whether to build bitcoind]) 1610 AM_CONDITIONAL([BUILD_BITCOIND], [test $build_bitcoind = "yes"]) 1611 AC_MSG_RESULT($build_bitcoind) 1612 1613 AC_MSG_CHECKING([whether to build bitcoin-cli]) 1614 AM_CONDITIONAL([BUILD_BITCOIN_CLI], [test $build_bitcoin_cli = "yes"]) 1615 AC_MSG_RESULT($build_bitcoin_cli) 1616 1617 AC_MSG_CHECKING([whether to build bitcoin-tx]) 1618 AM_CONDITIONAL([BUILD_BITCOIN_TX], [test $build_bitcoin_tx = "yes"]) 1619 AC_MSG_RESULT($build_bitcoin_tx) 1620 1621 AC_MSG_CHECKING([whether to build bitcoin-wallet]) 1622 AM_CONDITIONAL([BUILD_BITCOIN_WALLET], [test $build_bitcoin_wallet = "yes"]) 1623 AC_MSG_RESULT($build_bitcoin_wallet) 1624 1625 AC_MSG_CHECKING([whether to build bitcoin-util]) 1626 AM_CONDITIONAL([BUILD_BITCOIN_UTIL], [test $build_bitcoin_util = "yes"]) 1627 AC_MSG_RESULT($build_bitcoin_util) 1628 1629 AC_MSG_CHECKING([whether to build experimental bitcoin-chainstate]) 1630 if test "$build_bitcoin_chainstate" = "yes"; then 1631 if test "$build_experimental_kernel_lib" = "no"; then 1632 AC_MSG_ERROR([experimental bitcoin-chainstate cannot be built without the experimental bitcoinkernel library. Use --with-experimental-kernel-lib]); 1633 fi 1634 fi 1635 AM_CONDITIONAL([BUILD_BITCOIN_CHAINSTATE], [test $build_bitcoin_chainstate = "yes"]) 1636 AC_MSG_RESULT($build_bitcoin_chainstate) 1637 1638 AC_MSG_CHECKING([whether to build libraries]) 1639 AM_CONDITIONAL([BUILD_BITCOIN_LIBS], [test $build_bitcoin_libs = "yes"]) 1640 1641 if test "$build_bitcoin_libs" = "yes"; then 1642 AC_DEFINE([HAVE_CONSENSUS_LIB], [1], [Define this symbol if the consensus lib has been built]) 1643 AC_CONFIG_FILES([libbitcoinconsensus.pc:libbitcoinconsensus.pc.in]) 1644 fi 1645 1646 AM_CONDITIONAL([BUILD_BITCOIN_KERNEL_LIB], [test "$build_experimental_kernel_lib" != "no" && ( test "$build_experimental_kernel_lib" = "yes" || test "$build_bitcoin_chainstate" = "yes" )]) 1647 1648 AC_MSG_RESULT($build_bitcoin_libs) 1649 1650 AC_LANG_POP 1651 1652 if test "$use_ccache" != "no"; then 1653 AC_MSG_CHECKING([if ccache should be used]) 1654 if test "$CCACHE" = ""; then 1655 if test "$use_ccache" = "yes"; then 1656 AC_MSG_ERROR([ccache not found.]); 1657 else 1658 use_ccache=no 1659 fi 1660 else 1661 use_ccache=yes 1662 CC="$ac_cv_path_CCACHE $CC" 1663 CXX="$ac_cv_path_CCACHE $CXX" 1664 fi 1665 AC_MSG_RESULT($use_ccache) 1666 if test "$use_ccache" = "yes"; then 1667 AX_CHECK_COMPILE_FLAG([-fdebug-prefix-map=A=B], [DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -fdebug-prefix-map=\$(abs_top_srcdir)=."], [], [$CXXFLAG_WERROR]) 1668 AX_CHECK_PREPROC_FLAG([-fmacro-prefix-map=A=B], [DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -fmacro-prefix-map=\$(abs_top_srcdir)=."], [], [$CXXFLAG_WERROR]) 1669 fi 1670 fi 1671 1672 dnl enable wallet 1673 AC_MSG_CHECKING([if wallet should be enabled]) 1674 if test "$enable_wallet" != "no"; then 1675 AC_MSG_RESULT([yes]) 1676 AC_DEFINE_UNQUOTED([ENABLE_WALLET],[1],[Define to 1 to enable wallet functions]) 1677 enable_wallet=yes 1678 1679 else 1680 AC_MSG_RESULT([no]) 1681 fi 1682 1683 dnl enable upnp support 1684 AC_MSG_CHECKING([whether to build with support for UPnP]) 1685 if test "$have_miniupnpc" = "no"; then 1686 if test "$use_upnp" = "yes"; then 1687 AC_MSG_ERROR([UPnP requested but cannot be built. Use --without-miniupnpc]) 1688 fi 1689 AC_MSG_RESULT([no]) 1690 use_upnp=no 1691 else 1692 if test "$use_upnp" != "no"; then 1693 AC_MSG_RESULT([yes]) 1694 use_upnp=yes 1695 AC_DEFINE([USE_UPNP], [1], [Define to 1 if UPnP support should be compiled in.]) 1696 if test "$TARGET_OS" = "windows"; then 1697 MINIUPNPC_CPPFLAGS="$MINIUPNPC_CPPFLAGS -DMINIUPNP_STATICLIB" 1698 fi 1699 else 1700 AC_MSG_RESULT([no]) 1701 fi 1702 fi 1703 1704 dnl Enable NAT-PMP support. 1705 AC_MSG_CHECKING([whether to build with support for NAT-PMP]) 1706 if test "$have_natpmp" = "no"; then 1707 if test "$use_natpmp" = "yes"; then 1708 AC_MSG_ERROR([NAT-PMP requested but cannot be built. Use --without-natpmp]) 1709 fi 1710 AC_MSG_RESULT([no]) 1711 use_natpmp=no 1712 else 1713 if test "$use_natpmp" != "no"; then 1714 AC_MSG_RESULT([yes]) 1715 use_natpmp=yes 1716 AC_DEFINE([USE_NATPMP], [1], [Define to 1 if UPnP support should be compiled in.]) 1717 if test "$TARGET_OS" = "windows"; then 1718 NATPMP_CPPFLAGS="$NATPMP_CPPFLAGS -DSTATICLIB -DNATPMP_STATICLIB" 1719 fi 1720 else 1721 AC_MSG_RESULT([no]) 1722 fi 1723 fi 1724 1725 dnl these are only used when qt is enabled 1726 BUILD_TEST_QT="" 1727 if test "$bitcoin_enable_qt" != "no"; then 1728 dnl enable dbus support 1729 AC_MSG_CHECKING([whether to build GUI with support for D-Bus]) 1730 if test "$bitcoin_enable_qt_dbus" != "no"; then 1731 AC_DEFINE([USE_DBUS], [1], [Define if dbus support should be compiled in]) 1732 fi 1733 AC_MSG_RESULT([$bitcoin_enable_qt_dbus]) 1734 1735 dnl enable qr support 1736 AC_MSG_CHECKING([whether to build GUI with support for QR codes]) 1737 if test "$have_qrencode" = "no"; then 1738 if test "$use_qr" = "yes"; then 1739 AC_MSG_ERROR([QR support requested but cannot be built. Use --without-qrencode]) 1740 fi 1741 use_qr=no 1742 else 1743 if test "$use_qr" != "no"; then 1744 AC_DEFINE([USE_QRCODE], [1], [Define if QR support should be compiled in]) 1745 use_qr=yes 1746 fi 1747 fi 1748 AC_MSG_RESULT([$use_qr]) 1749 1750 if test "$XGETTEXT" = ""; then 1751 AC_MSG_WARN([xgettext is required to update qt translations]) 1752 fi 1753 1754 AC_MSG_CHECKING([whether to build test_bitcoin-qt]) 1755 if test "$use_gui_tests$bitcoin_enable_qt_test" = "yesyes"; then 1756 AC_MSG_RESULT([yes]) 1757 BUILD_TEST_QT="yes" 1758 else 1759 AC_MSG_RESULT([no]) 1760 fi 1761 fi 1762 1763 AC_MSG_CHECKING([whether to build test_bitcoin]) 1764 if test "$use_tests" = "yes"; then 1765 if test "$enable_fuzz" = "yes"; then 1766 AC_MSG_RESULT([no, because fuzzing is enabled]) 1767 else 1768 AC_MSG_RESULT([yes]) 1769 fi 1770 BUILD_TEST="yes" 1771 else 1772 AC_MSG_RESULT([no]) 1773 BUILD_TEST="" 1774 fi 1775 1776 AC_MSG_CHECKING([whether to reduce exports]) 1777 if test "$use_reduce_exports" = "yes"; then 1778 AC_MSG_RESULT([yes]) 1779 else 1780 AC_MSG_RESULT([no]) 1781 fi 1782 1783 if test "$build_bitcoin_wallet$build_bitcoin_cli$build_bitcoin_tx$build_bitcoin_util$build_bitcoin_libs$build_bitcoind$bitcoin_enable_qt$enable_fuzz_binary$use_bench$use_tests" = "nononononononononono"; then 1784 AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-libs --with-daemon --with-gui --enable-fuzz(-binary) --enable-bench or --enable-tests]) 1785 fi 1786 1787 AM_CONDITIONAL([TARGET_DARWIN], [test "$TARGET_OS" = "darwin"]) 1788 AM_CONDITIONAL([BUILD_DARWIN], [test "$BUILD_OS" = "darwin"]) 1789 AM_CONDITIONAL([TARGET_LINUX], [test "$TARGET_OS" = "linux"]) 1790 AM_CONDITIONAL([TARGET_WINDOWS], [test "$TARGET_OS" = "windows"]) 1791 AM_CONDITIONAL([ENABLE_WALLET], [test "$enable_wallet" = "yes"]) 1792 AM_CONDITIONAL([USE_SQLITE], [test "$use_sqlite" = "yes"]) 1793 AM_CONDITIONAL([USE_BDB], [test "$use_bdb" = "yes"]) 1794 AM_CONDITIONAL([ENABLE_TESTS], [test "$BUILD_TEST" = "yes"]) 1795 AM_CONDITIONAL([ENABLE_FUZZ], [test "$enable_fuzz" = "yes"]) 1796 AM_CONDITIONAL([ENABLE_FUZZ_BINARY], [test "$enable_fuzz_binary" = "yes"]) 1797 AM_CONDITIONAL([ENABLE_QT], [test "$bitcoin_enable_qt" = "yes"]) 1798 AM_CONDITIONAL([ENABLE_QT_TESTS], [test "$BUILD_TEST_QT" = "yes"]) 1799 AM_CONDITIONAL([ENABLE_BENCH], [test "$use_bench" = "yes"]) 1800 AM_CONDITIONAL([USE_QRCODE], [test "$use_qr" = "yes"]) 1801 AM_CONDITIONAL([USE_LCOV], [test "$use_lcov" = "yes"]) 1802 AM_CONDITIONAL([USE_LIBEVENT], [test "$use_libevent" = "yes"]) 1803 AM_CONDITIONAL([HARDEN], [test "$use_hardening" = "yes"]) 1804 AM_CONDITIONAL([ENABLE_SSE42], [test "$enable_sse42" = "yes"]) 1805 AM_CONDITIONAL([ENABLE_SSE41], [test "$enable_sse41" = "yes"]) 1806 AM_CONDITIONAL([ENABLE_AVX2], [test "$enable_avx2" = "yes"]) 1807 AM_CONDITIONAL([ENABLE_X86_SHANI], [test "$enable_x86_shani" = "yes"]) 1808 AM_CONDITIONAL([ENABLE_ARM_CRC], [test "$enable_arm_crc" = "yes"]) 1809 AM_CONDITIONAL([ENABLE_ARM_SHANI], [test "$enable_arm_shani" = "yes"]) 1810 AM_CONDITIONAL([WORDS_BIGENDIAN], [test "$ac_cv_c_bigendian" = "yes"]) 1811 AM_CONDITIONAL([USE_NATPMP], [test "$use_natpmp" = "yes"]) 1812 AM_CONDITIONAL([USE_UPNP], [test "$use_upnp" = "yes"]) 1813 1814 dnl for minisketch 1815 AM_CONDITIONAL([ENABLE_CLMUL], [test "$enable_clmul" = "yes"]) 1816 AM_CONDITIONAL([HAVE_CLZ], [test "$have_clzl$have_clzll" = "yesyes"]) 1817 1818 AC_DEFINE([CLIENT_VERSION_MAJOR], [_CLIENT_VERSION_MAJOR], [Major version]) 1819 AC_DEFINE([CLIENT_VERSION_MINOR], [_CLIENT_VERSION_MINOR], [Minor version]) 1820 AC_DEFINE([CLIENT_VERSION_BUILD], [_CLIENT_VERSION_BUILD], [Version Build]) 1821 AC_DEFINE([CLIENT_VERSION_IS_RELEASE], [_CLIENT_VERSION_IS_RELEASE], [Version is release]) 1822 AC_DEFINE([COPYRIGHT_YEAR], [_COPYRIGHT_YEAR], [Copyright year]) 1823 AC_DEFINE([COPYRIGHT_HOLDERS], ["_COPYRIGHT_HOLDERS"], [Copyright holder(s) before %s replacement]) 1824 AC_DEFINE([COPYRIGHT_HOLDERS_SUBSTITUTION], ["_COPYRIGHT_HOLDERS_SUBSTITUTION"], [Replacement for %s in copyright holders string]) 1825 define(_COPYRIGHT_HOLDERS_FINAL, [patsubst(_COPYRIGHT_HOLDERS, [%s], [_COPYRIGHT_HOLDERS_SUBSTITUTION])]) 1826 AC_DEFINE([COPYRIGHT_HOLDERS_FINAL], ["_COPYRIGHT_HOLDERS_FINAL"], [Copyright holder(s)]) 1827 AC_SUBST(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR) 1828 AC_SUBST(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR) 1829 AC_SUBST(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD) 1830 AC_SUBST(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE) 1831 AC_SUBST(COPYRIGHT_YEAR, _COPYRIGHT_YEAR) 1832 AC_SUBST(COPYRIGHT_HOLDERS, "_COPYRIGHT_HOLDERS") 1833 AC_SUBST(COPYRIGHT_HOLDERS_SUBSTITUTION, "_COPYRIGHT_HOLDERS_SUBSTITUTION") 1834 AC_SUBST(COPYRIGHT_HOLDERS_FINAL, "_COPYRIGHT_HOLDERS_FINAL") 1835 AC_SUBST(BITCOIN_DAEMON_NAME) 1836 AC_SUBST(BITCOIN_GUI_NAME) 1837 AC_SUBST(BITCOIN_TEST_NAME) 1838 AC_SUBST(BITCOIN_CLI_NAME) 1839 AC_SUBST(BITCOIN_TX_NAME) 1840 AC_SUBST(BITCOIN_UTIL_NAME) 1841 AC_SUBST(BITCOIN_CHAINSTATE_NAME) 1842 AC_SUBST(BITCOIN_WALLET_TOOL_NAME) 1843 AC_SUBST(BITCOIN_MP_NODE_NAME) 1844 AC_SUBST(BITCOIN_MP_GUI_NAME) 1845 1846 AC_SUBST(RELDFLAGS) 1847 AC_SUBST(CORE_LDFLAGS) 1848 AC_SUBST(CORE_CPPFLAGS) 1849 AC_SUBST(CORE_CXXFLAGS) 1850 AC_SUBST(DEBUG_CPPFLAGS) 1851 AC_SUBST(WARN_CXXFLAGS) 1852 AC_SUBST(NOWARN_CXXFLAGS) 1853 AC_SUBST(DEBUG_CXXFLAGS) 1854 AC_SUBST(ERROR_CXXFLAGS) 1855 AC_SUBST(GPROF_CXXFLAGS) 1856 AC_SUBST(GPROF_LDFLAGS) 1857 AC_SUBST(HARDENED_CXXFLAGS) 1858 AC_SUBST(HARDENED_CPPFLAGS) 1859 AC_SUBST(HARDENED_LDFLAGS) 1860 AC_SUBST(PIC_FLAGS) 1861 AC_SUBST(PIE_FLAGS) 1862 AC_SUBST(SANITIZER_CXXFLAGS) 1863 AC_SUBST(SANITIZER_LDFLAGS) 1864 AC_SUBST(SSE42_CXXFLAGS) 1865 AC_SUBST(SSE41_CXXFLAGS) 1866 AC_SUBST(CLMUL_CXXFLAGS) 1867 AC_SUBST(AVX2_CXXFLAGS) 1868 AC_SUBST(X86_SHANI_CXXFLAGS) 1869 AC_SUBST(ARM_CRC_CXXFLAGS) 1870 AC_SUBST(ARM_SHANI_CXXFLAGS) 1871 AC_SUBST(LIBTOOL_APP_LDFLAGS) 1872 AC_SUBST(USE_SQLITE) 1873 AC_SUBST(USE_BDB) 1874 AC_SUBST(ENABLE_EXTERNAL_SIGNER) 1875 AC_SUBST(USE_UPNP) 1876 AC_SUBST(USE_QRCODE) 1877 AC_SUBST(TESTDEFS) 1878 AC_SUBST(MINIUPNPC_CPPFLAGS) 1879 AC_SUBST(MINIUPNPC_LIBS) 1880 AC_SUBST(NATPMP_CPPFLAGS) 1881 AC_SUBST(NATPMP_LIBS) 1882 AC_SUBST(HAVE_GMTIME_R) 1883 AC_SUBST(HAVE_FDATASYNC) 1884 AC_SUBST(HAVE_FULLFSYNC) 1885 AC_SUBST(HAVE_O_CLOEXEC) 1886 AC_SUBST(HAVE_BUILTIN_PREFETCH) 1887 AC_SUBST(HAVE_MM_PREFETCH) 1888 AC_SUBST(HAVE_STRONG_GETAUXVAL) 1889 AC_SUBST(ANDROID_ARCH) 1890 AC_SUBST(HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR) 1891 AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/config.ini]) 1892 AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh]) 1893 AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])]) 1894 AC_CONFIG_LINKS([contrib/devtools/iwyu/bitcoin.core.imp:contrib/devtools/iwyu/bitcoin.core.imp]) 1895 AC_CONFIG_LINKS([contrib/filter-lcov.py:contrib/filter-lcov.py]) 1896 AC_CONFIG_LINKS([src/.bear-tidy-config:src/.bear-tidy-config]) 1897 AC_CONFIG_LINKS([src/.clang-tidy:src/.clang-tidy]) 1898 AC_CONFIG_LINKS([test/functional/test_runner.py:test/functional/test_runner.py]) 1899 AC_CONFIG_LINKS([test/fuzz/test_runner.py:test/fuzz/test_runner.py]) 1900 AC_CONFIG_LINKS([test/util/test_runner.py:test/util/test_runner.py]) 1901 AC_CONFIG_LINKS([test/util/rpcauth-test.py:test/util/rpcauth-test.py]) 1902 AC_CONFIG_LINKS([src/qt/Makefile:src/qt/Makefile]) 1903 AC_CONFIG_LINKS([src/qt/test/Makefile:src/qt/test/Makefile]) 1904 AC_CONFIG_LINKS([src/test/Makefile:src/test/Makefile]) 1905 1906 dnl boost's m4 checks do something really nasty: they export these vars. As a 1907 dnl result, they leak into secp256k1's configure and crazy things happen. 1908 dnl Until this is fixed upstream and we've synced, we'll just un-export them. 1909 CPPFLAGS_TEMP="$CPPFLAGS" 1910 unset CPPFLAGS 1911 CPPFLAGS="$CPPFLAGS_TEMP" 1912 1913 if test -n "$use_sanitizers"; then 1914 export SECP_CFLAGS="$SECP_CFLAGS $SANITIZER_CFLAGS" 1915 fi 1916 ac_configure_args="${ac_configure_args} --disable-shared --with-pic --enable-benchmark=no --enable-module-recovery --disable-module-ecdh" 1917 AC_CONFIG_SUBDIRS([src/secp256k1]) 1918 1919 AC_OUTPUT 1920 1921 dnl Replace the BUILDDIR path with the correct Windows path if compiling on Native Windows 1922 case ${OS} in 1923 *Windows*) 1924 sed 's/BUILDDIR="\/\([[a-z]]\)/BUILDDIR="\1:/' test/config.ini > test/config-2.ini 1925 mv test/config-2.ini test/config.ini 1926 ;; 1927 esac 1928 1929 dnl An old hack similar to a98356fee to remove hard-coded 1930 dnl bind_at_load flag from libtool 1931 case $host in 1932 *darwin*) 1933 AC_MSG_RESULT([Removing -Wl,bind_at_load from libtool.]) 1934 sed < libtool > libtool-2 '/bind_at_load/d' 1935 mv libtool-2 libtool 1936 chmod 755 libtool 1937 ;; 1938 esac 1939 1940 echo 1941 echo "Options used to compile and link:" 1942 echo " external signer = $use_external_signer" 1943 echo " multiprocess = $build_multiprocess" 1944 echo " with libs = $build_bitcoin_libs" 1945 echo " with wallet = $enable_wallet" 1946 if test "$enable_wallet" != "no"; then 1947 echo " with sqlite = $use_sqlite" 1948 echo " with bdb = $use_bdb" 1949 fi 1950 echo " with gui / qt = $bitcoin_enable_qt" 1951 if test $bitcoin_enable_qt != "no"; then 1952 echo " with qr = $use_qr" 1953 fi 1954 echo " with zmq = $use_zmq" 1955 if test $enable_fuzz = "no"; then 1956 echo " with test = $use_tests" 1957 else 1958 echo " with test = not building test_bitcoin because fuzzing is enabled" 1959 fi 1960 echo " with fuzz binary = $enable_fuzz_binary" 1961 echo " with bench = $use_bench" 1962 echo " with upnp = $use_upnp" 1963 echo " with natpmp = $use_natpmp" 1964 echo " USDT tracing = $use_usdt" 1965 echo " sanitizers = $use_sanitizers" 1966 echo " debug enabled = $enable_debug" 1967 echo " gprof enabled = $enable_gprof" 1968 echo " werror = $enable_werror" 1969 echo 1970 echo " target os = $host_os" 1971 echo " build os = $build_os" 1972 echo 1973 echo " CC = $CC" 1974 echo " CFLAGS = $PTHREAD_CFLAGS $SANITIZER_CFLAGS $CFLAGS" 1975 echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CORE_CPPFLAGS $CPPFLAGS" 1976 echo " CXX = $CXX" 1977 echo " CXXFLAGS = $CORE_CXXFLAGS $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $SANITIZER_CXXFLAGS $CXXFLAGS" 1978 echo " LDFLAGS = $PTHREAD_LIBS $HARDENED_LDFLAGS $GPROF_LDFLAGS $SANITIZER_LDFLAGS $CORE_LDFLAGS $LDFLAGS" 1979 echo " AR = $AR" 1980 echo " ARFLAGS = $ARFLAGS" 1981 echo