2020-02-10 19:20:23 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2020-03-29 07:51:48 +02:00
|
|
|
# This script was tested on Linux and MacOS hosts, where it can be used
|
|
|
|
|
# to build native libsecp256k1 binaries.
|
|
|
|
|
#
|
|
|
|
|
# It can also be used to cross-compile to Windows:
|
|
|
|
|
# $ sudo apt-get install mingw-w64
|
|
|
|
|
# For a Windows x86 (32-bit) target, run:
|
|
|
|
|
# $ GCC_TRIPLET_HOST="i686-w64-mingw32" ./contrib/make_libsecp256k1.sh
|
|
|
|
|
# Or for a Windows x86_64 (64-bit) target, run:
|
|
|
|
|
# $ GCC_TRIPLET_HOST="x86_64-w64-mingw32" ./contrib/make_libsecp256k1.sh
|
2020-10-21 03:27:42 +02:00
|
|
|
#
|
|
|
|
|
# To cross-compile to Linux x86:
|
|
|
|
|
# sudo apt-get install gcc-multilib g++-multilib
|
|
|
|
|
# $ AUTOCONF_FLAGS="--host=i686-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32" ./contrib/make_libsecp256k1.sh
|
2020-03-29 07:51:48 +02:00
|
|
|
|
2025-05-30 17:49:13 +00:00
|
|
|
LIBSECP_VERSION="0cdc758a56360bf58a851fe91085a327ec97685a"
|
|
|
|
|
# ^ tag "v0.6.0"
|
2023-09-25 13:11:03 +00:00
|
|
|
# note: this version is duplicated in contrib/android/p4a_recipes/libsecp256k1/__init__.py
|
2024-10-18 14:47:15 +00:00
|
|
|
# (and also in electrum-ecc, for the "secp256k1" git submodule)
|
2020-02-10 19:20:23 +01:00
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
2020-02-11 16:06:32 +01:00
|
|
|
. $(dirname "$0")/build_tools_util.sh || (echo "Could not source build_tools_util.sh" && exit 1)
|
|
|
|
|
|
2022-08-24 11:18:39 -03:00
|
|
|
here="$(dirname "$(realpath "$0" 2> /dev/null || grealpath "$0")")"
|
2020-02-10 19:20:23 +01:00
|
|
|
CONTRIB="$here"
|
|
|
|
|
PROJECT_ROOT="$CONTRIB/.."
|
|
|
|
|
|
|
|
|
|
pkgname="secp256k1"
|
|
|
|
|
info "Building $pkgname..."
|
|
|
|
|
|
|
|
|
|
(
|
2022-08-24 11:18:39 -03:00
|
|
|
cd "$CONTRIB"
|
2020-02-10 19:20:23 +01:00
|
|
|
if [ ! -d secp256k1 ]; then
|
|
|
|
|
git clone https://github.com/bitcoin-core/secp256k1.git
|
|
|
|
|
fi
|
|
|
|
|
cd secp256k1
|
2020-06-15 16:56:36 +02:00
|
|
|
if ! $(git cat-file -e ${LIBSECP_VERSION}) ; then
|
|
|
|
|
info "Could not find requested version $LIBSECP_VERSION in local clone; fetching..."
|
|
|
|
|
git fetch --all
|
|
|
|
|
fi
|
2020-02-10 19:20:23 +01:00
|
|
|
git reset --hard
|
2020-09-15 15:35:57 +00:00
|
|
|
git clean -dfxq
|
2020-06-15 20:01:22 +02:00
|
|
|
git checkout "${LIBSECP_VERSION}^{commit}"
|
2020-02-10 19:20:23 +01:00
|
|
|
|
|
|
|
|
if ! [ -x configure ] ; then
|
|
|
|
|
echo "LDFLAGS = -no-undefined" >> Makefile.am
|
|
|
|
|
./autogen.sh || fail "Could not run autogen for $pkgname. Please make sure you have automake and libtool installed, and try again."
|
|
|
|
|
fi
|
|
|
|
|
if ! [ -r config.status ] ; then
|
|
|
|
|
./configure \
|
|
|
|
|
$AUTOCONF_FLAGS \
|
|
|
|
|
--prefix="$here/$pkgname/dist" \
|
|
|
|
|
--enable-module-recovery \
|
2024-04-11 13:09:57 +00:00
|
|
|
--enable-module-extrakeys \
|
|
|
|
|
--enable-module-schnorrsig \
|
2020-02-10 19:20:23 +01:00
|
|
|
--enable-experimental \
|
|
|
|
|
--enable-module-ecdh \
|
2020-06-21 09:08:16 +08:00
|
|
|
--disable-benchmark \
|
2020-02-10 19:20:23 +01:00
|
|
|
--disable-tests \
|
2020-06-21 09:08:52 +08:00
|
|
|
--disable-exhaustive-tests \
|
2020-02-10 19:20:23 +01:00
|
|
|
--disable-static \
|
|
|
|
|
--enable-shared || fail "Could not configure $pkgname. Please make sure you have a C compiler installed and try again."
|
|
|
|
|
fi
|
2022-12-03 22:50:18 +00:00
|
|
|
make "-j$CPU_COUNT" || fail "Could not build $pkgname"
|
2020-02-10 19:20:23 +01:00
|
|
|
make install || fail "Could not install $pkgname"
|
|
|
|
|
. "$here/$pkgname/dist/lib/libsecp256k1.la"
|
|
|
|
|
host_strip "$here/$pkgname/dist/lib/$dlname"
|
2021-03-07 14:28:16 +01:00
|
|
|
if [ -n "$DLL_TARGET_DIR" ] ; then
|
2022-11-04 05:20:25 +00:00
|
|
|
cp -fpv "$here/$pkgname/dist/lib/$dlname" "$DLL_TARGET_DIR/" || fail "Could not copy the $pkgname binary to DLL_TARGET_DIR"
|
2024-10-01 10:24:58 +02:00
|
|
|
else
|
|
|
|
|
cp -fpv "$here/$pkgname/dist/lib/$dlname" "$PROJECT_ROOT/electrum" || fail "Could not copy the $pkgname binary to its destination"
|
|
|
|
|
info "$dlname has been placed in the 'electrum' folder."
|
2021-03-07 14:28:16 +01:00
|
|
|
fi
|
2020-02-10 19:20:23 +01:00
|
|
|
)
|