tmake_libsecp256k1.sh - electrum - Electrum Bitcoin wallet
HTML git clone https://git.parazyd.org/electrum
DIR Log
DIR Files
DIR Refs
DIR Submodules
---
tmake_libsecp256k1.sh (2777B)
---
1 #!/bin/bash
2
3 # This script was tested on Linux and MacOS hosts, where it can be used
4 # to build native libsecp256k1 binaries.
5 #
6 # It can also be used to cross-compile to Windows:
7 # $ sudo apt-get install mingw-w64
8 # For a Windows x86 (32-bit) target, run:
9 # $ GCC_TRIPLET_HOST="i686-w64-mingw32" ./contrib/make_libsecp256k1.sh
10 # Or for a Windows x86_64 (64-bit) target, run:
11 # $ GCC_TRIPLET_HOST="x86_64-w64-mingw32" ./contrib/make_libsecp256k1.sh
12 #
13 # To cross-compile to Linux x86:
14 # sudo apt-get install gcc-multilib g++-multilib
15 # $ AUTOCONF_FLAGS="--host=i686-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32" ./contrib/make_libsecp256k1.sh
16
17 LIBSECP_VERSION="dbd41db16a0e91b2566820898a3ab2d7dad4fe00"
18
19 set -e
20
21 . $(dirname "$0")/build_tools_util.sh || (echo "Could not source build_tools_util.sh" && exit 1)
22
23 here=$(dirname $(realpath "$0" 2> /dev/null || grealpath "$0"))
24 CONTRIB="$here"
25 PROJECT_ROOT="$CONTRIB/.."
26
27 pkgname="secp256k1"
28 info "Building $pkgname..."
29
30 (
31 cd $CONTRIB
32 if [ ! -d secp256k1 ]; then
33 git clone https://github.com/bitcoin-core/secp256k1.git
34 fi
35 cd secp256k1
36 if ! $(git cat-file -e ${LIBSECP_VERSION}) ; then
37 info "Could not find requested version $LIBSECP_VERSION in local clone; fetching..."
38 git fetch --all
39 fi
40 git reset --hard
41 git clean -dfxq
42 git checkout "${LIBSECP_VERSION}^{commit}"
43
44 if ! [ -x configure ] ; then
45 echo "libsecp256k1_la_LDFLAGS = -no-undefined" >> Makefile.am
46 echo "LDFLAGS = -no-undefined" >> Makefile.am
47 ./autogen.sh || fail "Could not run autogen for $pkgname. Please make sure you have automake and libtool installed, and try again."
48 fi
49 if ! [ -r config.status ] ; then
50 ./configure \
51 $AUTOCONF_FLAGS \
52 --prefix="$here/$pkgname/dist" \
53 --enable-module-recovery \
54 --enable-experimental \
55 --enable-module-ecdh \
56 --disable-benchmark \
57 --disable-tests \
58 --disable-exhaustive-tests \
59 --disable-static \
60 --enable-shared || fail "Could not configure $pkgname. Please make sure you have a C compiler installed and try again."
61 fi
62 make -j4 || fail "Could not build $pkgname"
63 make install || fail "Could not install $pkgname"
64 . "$here/$pkgname/dist/lib/libsecp256k1.la"
65 host_strip "$here/$pkgname/dist/lib/$dlname"
66 cp -fpv "$here/$pkgname/dist/lib/$dlname" "$PROJECT_ROOT/electrum" || fail "Could not copy the $pkgname binary to its destination"
67 info "$dlname has been placed in the inner 'electrum' folder."
68 if [ -n "$DLL_TARGET_DIR" ] ; then
69 cp -fpv "$here/$pkgname/dist/lib/$dlname" "$DLL_TARGET_DIR" || fail "Could not copy the $pkgname binary to DLL_TARGET_DIR"
70 fi
71 )