Skip to content

Commit

Permalink
configure.ac: use AX_SUBDIRS_CONFIGURE; don't alter ac_configure_args
Browse files Browse the repository at this point in the history
Altering ac_configure_args to configure libsecp256k1 with options
differing from those of libwally-core causes issues if the wally
Makefile is out of date and needs to call autoreconf etc to
regenerate itself. The secp arguments are passed back to the top
level configure which changes and possibly breaks the original
configuration.

Instead, import and use AX_SUBDIRS_CONFIGURE from the autoconf-archive
which supports sub-confiration with bespoke arguments.

Because autoreconf does not recurse into subdirectories named by
AX_SUBDIRS_CONFIGURE, we lose the automagic Autotools (re)generation in
src/secp256k1, so add an explicit call to src/secp256k1/autogen.sh in
tools/autogen.sh.
  • Loading branch information
jgriffiths committed Oct 16, 2023
1 parent d63dc2d commit 069cc0d
Show file tree
Hide file tree
Showing 4 changed files with 351 additions and 14 deletions.
3 changes: 1 addition & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,7 @@ export ARFLAGS
export AR_FLAGS
export LD
export LDFLAGS
ac_configure_args="${ac_configure_args} --disable-shared --with-pic --enable-experimental --enable-module-ecdh --enable-module-recovery --enable-module-ecdsa-s2c --enable-module-rangeproof --enable-module-surjectionproof --enable-module-whitelist --enable-module-generator --enable-module-extrakeys --enable-module-schnorrsig ${secp256k1_test_opt} --enable-exhaustive-tests=no --enable-benchmark=no --disable-dependency-tracking ${secp_asm}"
AC_CONFIG_SUBDIRS([src/secp256k1])

AX_SUBDIRS_CONFIGURE([src/secp256k1], [[--disable-shared], [--enable-static], [--with-pic], [--enable-experimental], [--enable-module-ecdh], [--enable-module-recovery], [--enable-module-ecdsa-s2c], [--enable-module-rangeproof], [--enable-module-surjectionproof], [--enable-module-whitelist], [--enable-module-generator], [--enable-module-extrakeys], [--enable-module-schnorrsig], [$secp256k1_test_opt], [--enable-exhaustive-tests=no], [--enable-benchmark=no], [--disable-dependency-tracking], [$secp_asm]])

AC_OUTPUT
24 changes: 12 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import copy, os, platform, shutil
import distutils.sysconfig

CONFIGURE_ARGS = '--enable-swig-python --enable-python-manylinux'
CONFIGURE_ARGS += ' --disable-swig-java --disable-tests --disable-dependency-tracking'
CONFIGURE_ARGS = ['--disable-shared', '--enable-static', '--with-pic',
'--enable-swig-python', '--enable-python-manylinux',
'--disable-swig-java', '--disable-tests', '--disable-dependency-tracking']

distutils_env = distutils.sysconfig.get_config_vars()
configure_env = copy.deepcopy(os.environ)
Expand All @@ -26,11 +27,11 @@
if is_x86 and not is_native:
# We are cross-compiling or compiling a univeral2 binary.
# Configure our source code as a cross compile to make the build work
CONFIGURE_ARGS += ' --host x86_64-apple-darwin'
CONFIGURE_ARGS += ['--host', 'x86_64-apple-darwin']
arch = 'universal2' if len(archs) > 1 else archs[0]
CONFIGURE_ARGS += ' --target {}-apple-macos'.format(arch)
CONFIGURE_ARGS += ['--target', '{}-apple-macos'.format(arch)]
if len(archs) > 1:
CONFIGURE_ARGS += ' --with-asm=no'
CONFIGURE_ARGS += ['--with-asm=no']
if 'PY_CFLAGS' in distutils_env:
configure_env['CFLAGS'] = distutils_env['PY_CFLAGS']
configure_env['LDFLAGS'] = distutils_env['PY_LDFLAGS']
Expand All @@ -40,18 +41,17 @@
# then build using the standard Python ext module machinery.
# (Windows requires source generation to be done separately).
import multiprocessing
import os
import subprocess

abs_path = os.path.dirname(os.path.abspath(__file__)) + '/'

def call(cmd):
subprocess.check_call(cmd.split(' '), cwd=abs_path, env=configure_env)
def call(args):
subprocess.check_call(args, cwd=abs_path, env=configure_env)

call('./tools/cleanup.sh')
call('./tools/autogen.sh')
call('./configure {}'.format(CONFIGURE_ARGS))
call('make -j{}'.format(multiprocessing.cpu_count()))
call(['./tools/cleanup.sh'])
call(['./tools/autogen.sh'])
call(['./configure'] + CONFIGURE_ARGS)
call(['make', '-j{}'.format(multiprocessing.cpu_count())])

define_macros=[
('SWIG_PYTHON_BUILD', None),
Expand Down
4 changes: 4 additions & 0 deletions tools/autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ if uname | grep "Darwin" >/dev/null 2>&1; then
done
done
fi

if [ -x src/secp256k1/autogen.sh ] ; then
cd src/secp256k1 && ./autogen.sh
fi
Loading

0 comments on commit 069cc0d

Please sign in to comment.