Skip to content

Commit 7a88e3b

Browse files
committed
Merge pull request #5425
87bddb7 Squashed 'src/secp256k1/' changes from ad2028f..b0210a9 (Pieter Wuille) ffe3291 Remove gmp dependency and doc mentions (Pieter Wuille)
2 parents 7d42644 + 0dcfb91 commit 7a88e3b

36 files changed

+1244
-857
lines changed

depends/packages/gmp.mk

Lines changed: 0 additions & 30 deletions
This file was deleted.

depends/packages/packages.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
packages:=boost openssl gmp
1+
packages:=boost openssl
22
native_packages := native_ccache native_comparisontool
33

44
qt_native_packages = native_protobuf

depends/patches/gmp/arm_gmp_build_fix.patch

Lines changed: 0 additions & 21 deletions
This file was deleted.

depends/patches/gmp/darwin_gmp_build_fix.patch

Lines changed: 0 additions & 29 deletions
This file was deleted.

doc/build-osx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Instructions: Homebrew
3838

3939
#### Install dependencies using Homebrew
4040

41-
brew install autoconf automake libtool boost miniupnpc openssl pkg-config protobuf qt gmp
41+
brew install autoconf automake libtool boost miniupnpc openssl pkg-config protobuf qt
4242

4343
#### Installing berkeley-db4 using Homebrew
4444

doc/build-unix.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ These dependencies are required:
3333
------------|------------------|----------------------
3434
libssl | SSL Support | Secure communications
3535
libboost | Boost | C++ Library
36-
libgmp | secp256k1 | Arbitrary-precision arithmetic (version >= 3.1)
3736

3837
Optional dependencies:
3938

@@ -58,7 +57,7 @@ Dependency Build Instructions: Ubuntu & Debian
5857
----------------------------------------------
5958
Build requirements:
6059

61-
sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev libgmp-dev
60+
sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev
6261

6362
for Ubuntu 12.04 and later or Debian 7 and later libboost-all-dev has to be installed:
6463

src/secp256k1/.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ env:
1818
- FIELD=64bit ENDOMORPHISM=yes
1919
- FIELD=32bit
2020
- FIELD=32bit ENDOMORPHISM=yes
21+
- BIGNUM=none
22+
- BIGNUM=none ENDOMORPHISM=yes
2123
- BUILD=distcheck
2224
- EXTRAFLAGS=CFLAGS=-DDETERMINISTIC
2325
before_script: ./autogen.sh

src/secp256k1/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ bench_sign_LDFLAGS = -static
6868
bench_inv_SOURCES = src/bench_inv.c
6969
bench_inv_LDADD = $(COMMON_LIB) $(SECP_LIBS)
7070
bench_inv_LDFLAGS = -static
71+
bench_inv_CPPFLAGS = $(SECP_INCLUDES)
7172
endif
7273

7374
if USE_TESTS
7475
noinst_PROGRAMS += tests
7576
tests_SOURCES = src/tests.c
76-
tests_CPPFLAGS = -DVERIFY $(SECP_TEST_INCLUDES)
77+
tests_CPPFLAGS = -DVERIFY $(SECP_INCLUDES) $(SECP_TEST_INCLUDES)
7778
tests_LDADD = $(COMMON_LIB) $(SECP_LIBS) $(SECP_TEST_LIBS)
7879
tests_LDFLAGS = -static
7980
TESTS = tests

src/secp256k1/build-aux/m4/bitcoin_secp.m4

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ fi
7878
dnl
7979
AC_DEFUN([SECP_GMP_CHECK],[
8080
if test x"$has_gmp" != x"yes"; then
81-
AC_CHECK_HEADER(gmp.h,[AC_CHECK_LIB(gmp, __gmpz_init,[has_gmp=yes; GMP_LIBS=-lgmp; AC_DEFINE(HAVE_LIBGMP,1,[Define this symbol if libgmp is installed])])])
81+
CPPFLAGS_TEMP="$CPPFLAGS"
82+
CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
83+
LIBS_TEMP="$LIBS"
84+
LIBS="$GMP_LIBS $LIBS"
85+
AC_CHECK_HEADER(gmp.h,[AC_CHECK_LIB(gmp, __gmpz_init,[has_gmp=yes; GMP_LIBS="$GMP_LIBS -lgmp"; AC_DEFINE(HAVE_LIBGMP,1,[Define this symbol if libgmp is installed])])])
86+
CPPFLAGS="$CPPFLAGS_TEMP"
87+
LIBS="$LIBS_TEMP"
8288
fi
8389
if test x"$set_field" = x"gmp" && test x"$has_gmp" != x"yes"; then
8490
AC_MSG_ERROR([$set_field field support explicitly requested but libgmp was not found])

src/secp256k1/configure.ac

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,35 @@ case $host in
3333
esac
3434

3535
case $host_os in
36-
darwin*)
37-
CPPFLAGS="$CPPFLAGS -I/opt/local/include"
38-
LDFLAGS="$LDFLAGS -L/opt/local/lib"
39-
;;
36+
*darwin*)
37+
if test x$cross_compiling != xyes; then
38+
AC_PATH_PROG([BREW],brew,)
39+
if test x$BREW != x; then
40+
dnl These Homebrew packages may be keg-only, meaning that they won't be found
41+
dnl in expected paths because they may conflict with system files. Ask
42+
dnl Homebrew where each one is located, then adjust paths accordingly.
43+
44+
openssl_prefix=`$BREW --prefix openssl 2>/dev/null`
45+
gmp_prefix=`$BREW --prefix gmp 2>/dev/null`
46+
if test x$openssl_prefix != x; then
47+
PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
48+
export PKG_CONFIG_PATH
49+
fi
50+
if test x$gmp_prefix != x; then
51+
GMP_CPPFLAGS="-I$gmp_prefix/include"
52+
GMP_LIBS="-L$gmp_prefix/lib"
53+
fi
54+
else
55+
AC_PATH_PROG([PORT],port,)
56+
dnl if homebrew isn't installed and macports is, add the macports default paths
57+
dnl as a last resort.
58+
if test x$PORT != x; then
59+
CPPFLAGS="$CPPFLAGS -isystem /opt/local/include"
60+
LDFLAGS="$LDFLAGS -L/opt/local/lib"
61+
fi
62+
fi
63+
fi
64+
;;
4065
esac
4166

4267
CFLAGS="$CFLAGS -W"
@@ -70,7 +95,7 @@ AC_ARG_ENABLE(endomorphism,
7095
AC_ARG_WITH([field], [AS_HELP_STRING([--with-field=gmp|64bit|64bit_asm|32bit|auto],
7196
[Specify Field Implementation. Default is auto])],[req_field=$withval], [req_field=auto])
7297

73-
AC_ARG_WITH([bignum], [AS_HELP_STRING([--with-bignum=gmp|auto],
98+
AC_ARG_WITH([bignum], [AS_HELP_STRING([--with-bignum=gmp|none|auto],
7499
[Specify Bignum Implementation. Default is auto])],[req_bignum=$withval], [req_bignum=auto])
75100

76101
AC_ARG_WITH([scalar], [AS_HELP_STRING([--with-scalar=64bit|32bit|auto],
@@ -154,16 +179,15 @@ if test x"$req_bignum" = x"auto"; then
154179
fi
155180

156181
if test x"$set_bignum" = x; then
157-
AC_MSG_ERROR([no working bignum implementation found])
182+
set_bignum=none
158183
fi
159184
else
160185
set_bignum=$req_bignum
161186
case $set_bignum in
162187
gmp)
163188
SECP_GMP_CHECK
164189
;;
165-
openssl)
166-
SECP_OPENSSL_CHECK
190+
none)
167191
;;
168192
*)
169193
AC_MSG_ERROR([invalid bignum implementation selection])
@@ -196,9 +220,15 @@ esac
196220
# select bignum implementation
197221
case $set_bignum in
198222
gmp)
199-
AC_DEFINE(HAVE_LIBGMP,1,[Define this symbol if libgmp is installed])
200-
AC_DEFINE(USE_NUM_GMP, 1, [Define this symbol to use the gmp implementation])
201-
AC_DEFINE(USE_FIELD_INV_NUM, 1, [Define this symbol to use the USE_FIELD_INV_NUM implementation])
223+
AC_DEFINE(HAVE_LIBGMP, 1, [Define this symbol if libgmp is installed])
224+
AC_DEFINE(USE_NUM_GMP, 1, [Define this symbol to use the gmp implementation for num])
225+
AC_DEFINE(USE_FIELD_INV_NUM, 1, [Define this symbol to use the num-based field inverse implementation])
226+
AC_DEFINE(USE_SCALAR_INV_NUM, 1, [Define this symbol to use the num-based scalar inverse implementation])
227+
;;
228+
none)
229+
AC_DEFINE(USE_NUM_NONE, 1, [Define this symbol to use no num implementation])
230+
AC_DEFINE(USE_FIELD_INV_BUILTIN, 1, [Define this symbol to use the native field inverse implementation])
231+
AC_DEFINE(USE_SCALAR_INV_BUILTIN, 1, [Define this symbol to use the native scalar inverse implementation])
202232
;;
203233
*)
204234
AC_MSG_ERROR([invalid bignum implementation])
@@ -236,10 +266,11 @@ fi
236266

237267
if test x"$set_field" = x"gmp" || test x"$set_bignum" = x"gmp"; then
238268
SECP_LIBS="$SECP_LIBS $GMP_LIBS"
269+
SECP_INCLUDES="$SECP_INCLUDES $GMP_CPPFLAGS"
239270
fi
240271

241272
if test x"$use_endomorphism" = x"yes"; then
242-
AC_DEFINE(USE_ENDOMORPHISM, 1, [Define this symbol to use endomorphism])
273+
AC_DEFINE(USE_ENDOMORPHISM, 1, [Define this symbol to use endomorphism optimization])
243274
fi
244275

245276
AC_MSG_NOTICE([Using field implementation: $set_field])
@@ -256,4 +287,10 @@ AC_SUBST(YASM_BINFMT)
256287
AM_CONDITIONAL([USE_ASM], [test x"$set_field" == x"64bit_asm"])
257288
AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"])
258289
AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" != x"no"])
290+
291+
dnl make sure nothing new is exported so that we don't break the cache
292+
PKGCONFIG_PATH_TEMP="$PKG_CONFIG_PATH"
293+
unset PKG_CONFIG_PATH
294+
PKG_CONFIG_PATH="$PKGCONFIG_PATH_TEMP"
295+
259296
AC_OUTPUT

0 commit comments

Comments
 (0)