Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1AC_PREREQ([2.60])3# The package (a.k.a. release) version is based on semantic versioning 2.0.0 of4# the API. All changes in experimental modules are treated as5# backwards-compatible and therefore at most increase the minor version.6define(_PKG_VERSION_MAJOR, 0)7define(_PKG_VERSION_MINOR, 8)8define(_PKG_VERSION_PATCH, 1)9define(_PKG_VERSION_IS_RELEASE, false)11# The library version is based on libtool versioning of the ABI. The set of12# rules for updating the version can be found here:13# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html14# All changes in experimental modules are treated as if they don't affect the15# interface and therefore only increase the revision.16define(_LIB_VERSION_CURRENT, 7)17define(_LIB_VERSION_REVISION, 1)18define(_LIB_VERSION_AGE, 0)20AC_INIT([libsecp256k1],m4_join([.], _PKG_VERSION_MAJOR, _PKG_VERSION_MINOR, _PKG_VERSION_PATCH)m4_if(_PKG_VERSION_IS_RELEASE, [true], [], [-dev]),[https://github.com/bitcoin-core/secp256k1/issues],[libsecp256k1],[https://github.com/bitcoin-core/secp256k1])22AC_CONFIG_AUX_DIR([autotools-aux])23AC_CONFIG_MACRO_DIR([autotools-aux/m4])24AC_CANONICAL_HOST26# Require Automake 1.11.2 for AM_PROG_AR27AM_INIT_AUTOMAKE([1.11.2 foreign subdir-objects])29# Make the compilation flags quiet unless V=1 is used.30m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])32if test "${CFLAGS+set}" = "set"; then33CFLAGS_overridden=yes34else35CFLAGS_overridden=no36fi37AC_PROG_CC38AM_PROG_AS39AM_PROG_AR41# Clear some cache variables as a workaround for a bug that appears due to a bad42# interaction between AM_PROG_AR and LT_INIT when combining MSVC's archiver lib.exe.43# https://debbugs.gnu.org/cgi/bugreport.cgi?bug=5442144AS_UNSET(ac_cv_prog_AR)45AS_UNSET(ac_cv_prog_ac_ct_AR)46LT_INIT([win32-dll])48build_windows=no50case $host_os in51*darwin*)52if test x$cross_compiling != xyes; then53AC_CHECK_PROG([BREW], brew, brew)54if test x$BREW = xbrew; then55# These Homebrew packages may be keg-only, meaning that they won't be found56# in expected paths because they may conflict with system files. Ask57# Homebrew where each one is located, then adjust paths accordingly.58if $BREW list --versions valgrind >/dev/null; then59valgrind_prefix=$($BREW --prefix valgrind 2>/dev/null)60VALGRIND_CPPFLAGS="-I$valgrind_prefix/include"61fi62else63AC_CHECK_PROG([PORT], port, port)64# If homebrew isn't installed and macports is, add the macports default paths65# as a last resort.66if test x$PORT = xport; then67CPPFLAGS="$CPPFLAGS -isystem /opt/local/include"68LDFLAGS="$LDFLAGS -L/opt/local/lib"69fi70fi71fi72;;73cygwin*|mingw*)74build_windows=yes75;;76esac78# Try if some desirable compiler flags are supported and append them to SECP_CFLAGS.79#80# These are our own flags, so we append them to our own SECP_CFLAGS variable (instead of CFLAGS) as81# recommended in the automake manual (Section "Flag Variables Ordering"). CFLAGS belongs to the user82# and we are not supposed to touch it. In the Makefile, we will need to ensure that SECP_CFLAGS83# is prepended to CFLAGS when invoking the compiler so that the user always has the last word (flag).84#85# Another advantage of not touching CFLAGS is that the contents of CFLAGS will be picked up by86# libtool for compiling helper executables. For example, when compiling for Windows, libtool will87# generate entire wrapper executables (instead of simple wrapper scripts as on Unix) to ensure88# proper operation of uninstalled programs linked by libtool against the uninstalled shared library.89# These executables are compiled from C source file for which our flags may not be appropriate,90# e.g., -std=c89 flag has lead to undesirable warnings in the past.91#92# TODO We should analogously not touch CPPFLAGS and LDFLAGS but currently there are no issues.93AC_DEFUN([SECP_TRY_APPEND_DEFAULT_CFLAGS], [94# GCC and compatible (incl. clang)95if test "x$GCC" = "xyes"; then96# Try to append -Werror to CFLAGS temporarily. Otherwise checks for some unsupported97# flags will succeed.98# Note that failure to append -Werror does not necessarily mean that -Werror is not99# supported. The compiler may already be warning about something unrelated, for example100# about some path issue. If that is the case, -Werror cannot be used because all101# of those warnings would be turned into errors.102SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS="$CFLAGS"103SECP_TRY_APPEND_CFLAGS([-Werror], CFLAGS)105SECP_TRY_APPEND_CFLAGS([-std=c89 -pedantic -Wno-long-long -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef], $1) # GCC >= 3.0, -Wlong-long is implied by -pedantic.106SECP_TRY_APPEND_CFLAGS([-Wno-overlength-strings], $1) # GCC >= 4.2, -Woverlength-strings is implied by -pedantic.107SECP_TRY_APPEND_CFLAGS([-Wall], $1) # GCC >= 2.95 and probably many other compilers108SECP_TRY_APPEND_CFLAGS([-Wno-unused-function], $1) # GCC >= 3.0, -Wunused-function is implied by -Wall.109SECP_TRY_APPEND_CFLAGS([-Wextra], $1) # GCC >= 3.4, this is the newer name of -W, which we don't use because older GCCs will warn about unused functions.110SECP_TRY_APPEND_CFLAGS([-Wcast-align], $1) # GCC >= 2.95111SECP_TRY_APPEND_CFLAGS([-Wcast-align=strict], $1) # GCC >= 8.0112SECP_TRY_APPEND_CFLAGS([-Wconditional-uninitialized], $1) # Clang >= 3.0 only113SECP_TRY_APPEND_CFLAGS([-Wreserved-identifier], $1) # Clang >= 13.0 only114SECP_TRY_APPEND_CFLAGS([-Wtrailing-whitespace=any], $1) # GCC >= 15.0115SECP_TRY_APPEND_CFLAGS([-Wleading-whitespace=spaces], $1) # GCC >= 15.0117CFLAGS="$SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS"118fi120# MSVC121# Assume MSVC if we're building for Windows but not with GCC or compatible;122# libtool makes the same assumption internally.123# Note that "/opt" and "-opt" are equivalent for MSVC; we use "-opt" because "/opt" looks like a path.124if test x"$GCC" != x"yes" && test x"$build_windows" = x"yes"; then125SECP_TRY_APPEND_CFLAGS([-W3], $1) # Production quality warning level.126SECP_TRY_APPEND_CFLAGS([-wd4146], $1) # Disable warning C4146 "unary minus operator applied to unsigned type, result still unsigned".127SECP_TRY_APPEND_CFLAGS([-wd4244], $1) # Disable warning C4244 "'conversion' conversion from 'type1' to 'type2', possible loss of data".128SECP_TRY_APPEND_CFLAGS([-wd4267], $1) # Disable warning C4267 "'var' : conversion from 'size_t' to 'type', possible loss of data".129# Eliminate deprecation warnings for the older, less secure functions.130CPPFLAGS="-D_CRT_SECURE_NO_WARNINGS $CPPFLAGS"131fi132])133SECP_TRY_APPEND_DEFAULT_CFLAGS(SECP_CFLAGS)135###136### Define config arguments137###139# In dev mode, we enable all binaries and modules by default but individual options can still be overridden explicitly.140# Check for dev mode first because SECP_SET_DEFAULT needs enable_dev_mode set.141AC_ARG_ENABLE(dev_mode, [], [],142[enable_dev_mode=no])144AC_ARG_ENABLE(benchmark,145AS_HELP_STRING([--enable-benchmark],[compile benchmark [default=yes]]), [],146[SECP_SET_DEFAULT([enable_benchmark], [yes], [yes])])148AC_ARG_ENABLE(coverage,149AS_HELP_STRING([--enable-coverage],[enable coverage analysis support [default=no]]), [],150[SECP_SET_DEFAULT([enable_coverage], [no], [no])])152AC_ARG_ENABLE(tests,153AS_HELP_STRING([--enable-tests],[compile tests [default=yes]]), [],154[SECP_SET_DEFAULT([enable_tests], [yes], [yes])])156AC_ARG_ENABLE(ctime_tests,157AS_HELP_STRING([--enable-ctime-tests],[compile constant-time tests [default=yes if valgrind enabled]]), [],158[SECP_SET_DEFAULT([enable_ctime_tests], [auto], [auto])])160AC_ARG_ENABLE(experimental,161AS_HELP_STRING([--enable-experimental],[allow experimental configure options [default=no]]), [],162[SECP_SET_DEFAULT([enable_experimental], [no], [yes])])164AC_ARG_ENABLE(exhaustive_tests,165AS_HELP_STRING([--enable-exhaustive-tests],[compile exhaustive tests [default=yes]]), [],166[SECP_SET_DEFAULT([enable_exhaustive_tests], [yes], [yes])])168AC_ARG_ENABLE(examples,169AS_HELP_STRING([--enable-examples],[compile the examples [default=no]]), [],170[SECP_SET_DEFAULT([enable_examples], [no], [yes])])172AC_ARG_ENABLE(module_ecdh,173AS_HELP_STRING([--enable-module-ecdh],[enable ECDH module [default=yes]]), [],174[SECP_SET_DEFAULT([enable_module_ecdh], [yes], [yes])])176AC_ARG_ENABLE(module_recovery,177AS_HELP_STRING([--enable-module-recovery],[enable ECDSA pubkey recovery module [default=no]]), [],178[SECP_SET_DEFAULT([enable_module_recovery], [no], [yes])])180AC_ARG_ENABLE(module_extrakeys,181AS_HELP_STRING([--enable-module-extrakeys],[enable extrakeys module [default=yes]]), [],182[SECP_SET_DEFAULT([enable_module_extrakeys], [yes], [yes])])184AC_ARG_ENABLE(module_schnorrsig,185AS_HELP_STRING([--enable-module-schnorrsig],[enable schnorrsig module [default=yes]]), [],186[SECP_SET_DEFAULT([enable_module_schnorrsig], [yes], [yes])])188AC_ARG_ENABLE(module_musig,189AS_HELP_STRING([--enable-module-musig],[enable MuSig2 module [default=yes]]), [],190[SECP_SET_DEFAULT([enable_module_musig], [yes], [yes])])192AC_ARG_ENABLE(module_ellswift,193AS_HELP_STRING([--enable-module-ellswift],[enable ElligatorSwift module [default=yes]]), [],194[SECP_SET_DEFAULT([enable_module_ellswift], [yes], [yes])])196AC_ARG_ENABLE(module_silentpayments,197AS_HELP_STRING([--enable-module-silentpayments],[enable Silent Payments module [default=yes]]), [],198[SECP_SET_DEFAULT([enable_module_silentpayments], [yes], [yes])])200AC_ARG_ENABLE(external_default_callbacks,201AS_HELP_STRING([--enable-external-default-callbacks],[enable external default callback functions [default=no]]), [],202[SECP_SET_DEFAULT([enable_external_default_callbacks], [no], [no])])204# Test-only override of the (autodetected by the C code) "widemul" setting.205# Legal values are:206# * int64 (for [u]int64_t),207# * int128 (for [unsigned] __int128),208# * int128_struct (for int128 implemented as a structure),209# * and auto (the default).210AC_ARG_WITH([test-override-wide-multiply], [] ,[set_widemul=$withval], [set_widemul=auto])212AC_ARG_WITH([asm], [AS_HELP_STRING([--with-asm=x86_64|arm32|no|auto],213[assembly to use (experimental: arm32) [default=auto]])],[req_asm=$withval], [req_asm=auto])215AC_ARG_WITH([ecmult-window], [AS_HELP_STRING([--with-ecmult-window=SIZE],216[window size for ecmult precomputation for verification, specified as integer in range [2..24].]217[Larger values result in possibly better performance at the cost of an exponentially larger precomputed table.]218[The table will store 2^(SIZE-1) * 64 bytes of data but can be larger in memory due to platform-specific padding and alignment.]219[A window size larger than 15 will require you delete the prebuilt precomputed_ecmult.c file so that it can be rebuilt.]220[For very large window sizes, use "make -j 1" to reduce memory use during compilation.]221[The default value is a reasonable setting for desktop machines (currently 15). [default=15]]222)],223[set_ecmult_window=$withval], [set_ecmult_window=15])225AC_ARG_WITH([ecmult-gen-kb], [AS_HELP_STRING([--with-ecmult-gen-kb=2|22|86],226[The size of the precomputed table for signing in multiples of 1024 bytes (on typical platforms).]227[Larger values result in possibly better signing/keygeneration performance at the cost of a larger table.]228[The default value is a reasonable setting for desktop machines (currently 86). [default=86]]229)],230[set_ecmult_gen_kb=$withval], [set_ecmult_gen_kb=86])232AC_ARG_WITH([valgrind], [AS_HELP_STRING([--with-valgrind=yes|no|auto],233[Build with extra checks for running inside Valgrind [default=auto]]234)],235[req_valgrind=$withval], [req_valgrind=auto])237###238### Handle config options (except for modules)239###241if test x"$req_valgrind" = x"no"; then242enable_valgrind=no243else244SECP_VALGRIND_CHECK245if test x"$has_valgrind" != x"yes"; then246if test x"$req_valgrind" = x"yes"; then247AC_MSG_ERROR([Valgrind support explicitly requested but valgrind/memcheck.h header not available])248fi249enable_valgrind=no250else
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.