@@ -85,42 +85,42 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
85
85
] )
86
86
87
87
AC_ARG_ENABLE ( benchmark ,
88
- AS_HELP_STRING ( [ --enable-benchmark] ,[ compile benchmark ( default is yes) ] ) ,
88
+ AS_HELP_STRING ( [ --enable-benchmark] ,[ compile benchmark [ default= yes] ] ) ,
89
89
[ use_benchmark=$enableval] ,
90
90
[ use_benchmark=yes] )
91
91
92
92
AC_ARG_ENABLE ( coverage ,
93
- AS_HELP_STRING ( [ --enable-coverage] ,[ enable compiler flags to support kcov coverage analysis] ) ,
93
+ AS_HELP_STRING ( [ --enable-coverage] ,[ enable compiler flags to support kcov coverage analysis [ default=no ] ] ) ,
94
94
[ enable_coverage=$enableval] ,
95
95
[ enable_coverage=no] )
96
96
97
97
AC_ARG_ENABLE ( tests ,
98
- AS_HELP_STRING ( [ --enable-tests] ,[ compile tests ( default is yes) ] ) ,
98
+ AS_HELP_STRING ( [ --enable-tests] ,[ compile tests [ default= yes] ] ) ,
99
99
[ use_tests=$enableval] ,
100
100
[ use_tests=yes] )
101
101
102
102
AC_ARG_ENABLE ( openssl_tests ,
103
- AS_HELP_STRING ( [ --enable-openssl-tests] ,[ enable OpenSSL tests, if OpenSSL is available ( default is auto) ] ) ,
103
+ AS_HELP_STRING ( [ --enable-openssl-tests] ,[ enable OpenSSL tests [ default= auto] ] ) ,
104
104
[ enable_openssl_tests=$enableval] ,
105
105
[ enable_openssl_tests=auto] )
106
106
107
107
AC_ARG_ENABLE ( experimental ,
108
- AS_HELP_STRING ( [ --enable-experimental] ,[ allow experimental configure options ( default is no) ] ) ,
108
+ AS_HELP_STRING ( [ --enable-experimental] ,[ allow experimental configure options [ default=no ] ] ) ,
109
109
[ use_experimental=$enableval] ,
110
110
[ use_experimental=no] )
111
111
112
112
AC_ARG_ENABLE ( exhaustive_tests ,
113
- AS_HELP_STRING ( [ --enable-exhaustive-tests] ,[ compile exhaustive tests ( default is yes) ] ) ,
113
+ AS_HELP_STRING ( [ --enable-exhaustive-tests] ,[ compile exhaustive tests [ default= yes] ] ) ,
114
114
[ use_exhaustive_tests=$enableval] ,
115
115
[ use_exhaustive_tests=yes] )
116
116
117
117
AC_ARG_ENABLE ( endomorphism ,
118
- AS_HELP_STRING ( [ --enable-endomorphism] ,[ enable endomorphism ( default is no) ] ) ,
118
+ AS_HELP_STRING ( [ --enable-endomorphism] ,[ enable endomorphism [ default=no ] ] ) ,
119
119
[ use_endomorphism=$enableval] ,
120
120
[ use_endomorphism=no] )
121
121
122
122
AC_ARG_ENABLE ( ecmult_static_precomputation ,
123
- AS_HELP_STRING ( [ --enable-ecmult-static-precomputation] ,[ enable precomputed ecmult table for signing ( default is yes) ] ) ,
123
+ AS_HELP_STRING ( [ --enable-ecmult-static-precomputation] ,[ enable precomputed ecmult table for signing [ default=auto ] ] ) ,
124
124
[ use_ecmult_static_precomputation=$enableval] ,
125
125
[ use_ecmult_static_precomputation=auto] )
126
126
@@ -130,65 +130,100 @@ AC_ARG_ENABLE(module_ecdh,
130
130
[ enable_module_ecdh=no] )
131
131
132
132
AC_ARG_ENABLE ( module_recovery ,
133
- AS_HELP_STRING ( [ --enable-module-recovery] ,[ enable ECDSA pubkey recovery module ( default is no) ] ) ,
133
+ AS_HELP_STRING ( [ --enable-module-recovery] ,[ enable ECDSA pubkey recovery module [ default=no ] ] ) ,
134
134
[ enable_module_recovery=$enableval] ,
135
135
[ enable_module_recovery=no] )
136
136
137
+ AC_ARG_ENABLE ( external_default_callbacks ,
138
+ AS_HELP_STRING ( [ --enable-external-default-callbacks] ,[ enable external default callback functions (default is no)] ) ,
139
+ [ use_external_default_callbacks=$enableval] ,
140
+ [ use_external_default_callbacks=no] )
141
+
137
142
AC_ARG_ENABLE ( jni ,
138
- AS_HELP_STRING ( [ --enable-jni] ,[ enable libsecp256k1_jni ( default is no) ] ) ,
143
+ AS_HELP_STRING ( [ --enable-jni] ,[ enable libsecp256k1_jni [ default=no ] ] ) ,
139
144
[ use_jni=$enableval] ,
140
145
[ use_jni=no] )
141
146
142
147
AC_ARG_WITH ( [ field] , [ AS_HELP_STRING ( [ --with-field=64bit|32bit|auto] ,
143
- [ Specify Field Implementation. Default is auto] ) ] ,[ req_field=$withval] , [ req_field=auto] )
148
+ [ finite field implementation to use [ default= auto] ] ) ] ,[ req_field=$withval] , [ req_field=auto] )
144
149
145
150
AC_ARG_WITH ( [ bignum] , [ AS_HELP_STRING ( [ --with-bignum=gmp|no|auto] ,
146
- [ Specify Bignum Implementation. Default is auto] ) ] ,[ req_bignum=$withval] , [ req_bignum=auto] )
151
+ [ bignum implementation to use [ default= auto] ] ) ] ,[ req_bignum=$withval] , [ req_bignum=auto] )
147
152
148
153
AC_ARG_WITH ( [ scalar] , [ AS_HELP_STRING ( [ --with-scalar=64bit|32bit|auto] ,
149
- [ Specify scalar implementation. Default is auto] ) ] ,[ req_scalar=$withval] , [ req_scalar=auto] )
154
+ [ scalar implementation to use [ default= auto] ] ) ] ,[ req_scalar=$withval] , [ req_scalar=auto] )
150
155
151
- AC_ARG_WITH ( [ asm] , [ AS_HELP_STRING ( [ --with-asm=x86_64|arm|no|auto]
152
- [ Specify assembly optimizations to use. Default is auto (experimental: arm)] ) ] ,[ req_asm=$withval] , [ req_asm=auto] )
156
+ AC_ARG_WITH ( [ asm] , [ AS_HELP_STRING ( [ --with-asm=x86_64|arm|no|auto] ,
157
+ [ assembly optimizations to use (experimental: arm) [ default=auto ] ] ) ] ,[ req_asm=$withval] , [ req_asm=auto] )
153
158
154
- AC_CHECK_TYPES ( [ __int128] )
159
+ AC_ARG_WITH ( [ ecmult-window] , [ AS_HELP_STRING ( [ --with-ecmult-window=SIZE|auto] ,
160
+ [ window size for ecmult precomputation for verification, specified as integer in range [ 2..24] .]
161
+ [ Larger values result in possibly better performance at the cost of an exponentially larger precomputed table.]
162
+ [ The table will store 2^(SIZE-2) * 64 bytes of data but can be larger in memory due to platform-specific padding and alignment.]
163
+ [ If the endomorphism optimization is enabled, two tables of this size are used instead of only one.]
164
+ [ "auto" is a reasonable setting for desktop machines (currently 15). [ default=auto] ]
165
+ ) ] ,
166
+ [ req_ecmult_window=$withval] , [ req_ecmult_window=auto] )
155
167
156
- AC_MSG_CHECKING ( [ for __builtin_expect] )
157
- AC_COMPILE_IFELSE ( [ AC_LANG_SOURCE ( [ [ void myfunc() {__builtin_expect(0,0);}] ] ) ] ,
158
- [ AC_MSG_RESULT ( [ yes] ) ;AC_DEFINE ( HAVE_BUILTIN_EXPECT ,1 ,[ Define this symbol if __builtin_expect is available] ) ] ,
159
- [ AC_MSG_RESULT ( [ no] )
160
- ] )
168
+ AC_CHECK_TYPES ( [ __int128] )
161
169
162
170
if test x"$enable_coverage" = x"yes"; then
163
171
AC_DEFINE ( COVERAGE , 1 , [ Define this symbol to compile out all VERIFY code] )
164
172
CFLAGS="$CFLAGS -O0 --coverage"
165
- LDFLAGS="--coverage"
173
+ LDFLAGS="$LDFLAGS --coverage"
166
174
else
167
175
CFLAGS="$CFLAGS -O3"
168
176
fi
169
177
170
178
if test x"$use_ecmult_static_precomputation" != x"no"; then
179
+ # Temporarily switch to an environment for the native compiler
171
180
save_cross_compiling=$cross_compiling
172
181
cross_compiling=no
173
- TEMP_CC ="$CC"
182
+ SAVE_CC ="$CC"
174
183
CC="$CC_FOR_BUILD"
175
- AC_MSG_CHECKING ( [ native compiler: ${CC_FOR_BUILD}] )
184
+ SAVE_CFLAGS="$CFLAGS"
185
+ CFLAGS="$CFLAGS_FOR_BUILD"
186
+ SAVE_CPPFLAGS="$CPPFLAGS"
187
+ CPPFLAGS="$CPPFLAGS_FOR_BUILD"
188
+ SAVE_LDFLAGS="$LDFLAGS"
189
+ LDFLAGS="$LDFLAGS_FOR_BUILD"
190
+
191
+ warn_CFLAGS_FOR_BUILD="-Wall -Wextra -Wno-unused-function"
192
+ saved_CFLAGS="$CFLAGS"
193
+ CFLAGS="$CFLAGS $warn_CFLAGS_FOR_BUILD"
194
+ AC_MSG_CHECKING ( [ if native ${CC_FOR_BUILD} supports ${warn_CFLAGS_FOR_BUILD}] )
195
+ AC_COMPILE_IFELSE ( [ AC_LANG_SOURCE ( [ [ char foo;] ] ) ] ,
196
+ [ AC_MSG_RESULT ( [ yes] ) ] ,
197
+ [ AC_MSG_RESULT ( [ no] )
198
+ CFLAGS="$saved_CFLAGS"
199
+ ] )
200
+
201
+ AC_MSG_CHECKING ( [ for working native compiler: ${CC_FOR_BUILD}] )
176
202
AC_RUN_IFELSE (
177
- [ AC_LANG_PROGRAM ( [ ] , [ return 0 ] ) ] ,
203
+ [ AC_LANG_PROGRAM ( [ ] , [ ] ) ] ,
178
204
[ working_native_cc=yes] ,
179
205
[ working_native_cc=no] ,[ dnl] )
180
- CC="$TEMP_CC"
206
+
207
+ CFLAGS_FOR_BUILD="$CFLAGS"
208
+
209
+ # Restore the environment
181
210
cross_compiling=$save_cross_compiling
211
+ CC="$SAVE_CC"
212
+ CFLAGS="$SAVE_CFLAGS"
213
+ CPPFLAGS="$SAVE_CPPFLAGS"
214
+ LDFLAGS="$SAVE_LDFLAGS"
182
215
183
216
if test x"$working_native_cc" = x"no"; then
217
+ AC_MSG_RESULT ( [ no] )
184
218
set_precomp=no
219
+ m4_define ( [ please_set_for_build] , [ Please set CC_FOR_BUILD, CFLAGS_FOR_BUILD, CPPFLAGS_FOR_BUILD, and/or LDFLAGS_FOR_BUILD.] )
185
220
if test x"$use_ecmult_static_precomputation" = x"yes"; then
186
- AC_MSG_ERROR ( [ ${CC_FOR_BUILD} does not produce working binaries. Please set CC_FOR_BUILD ] )
221
+ AC_MSG_ERROR ( [ native compiler ${CC_FOR_BUILD} does not produce working binaries. please_set_for_build ] )
187
222
else
188
- AC_MSG_RESULT ( [ ${CC_FOR_BUILD} does not produce working binaries. Please set CC_FOR_BUILD ] )
223
+ AC_MSG_WARN ( [ Disabling statically generated ecmult table because the native compiler ${CC_FOR_BUILD} does not produce working binaries. please_set_for_build ] )
189
224
fi
190
225
else
191
- AC_MSG_RESULT ( [ ok ] )
226
+ AC_MSG_RESULT ( [ yes ] )
192
227
set_precomp=yes
193
228
fi
194
229
else
@@ -366,6 +401,28 @@ case $set_scalar in
366
401
;;
367
402
esac
368
403
404
+ # set ecmult window size
405
+ if test x"$req_ecmult_window" = x"auto"; then
406
+ set_ecmult_window=15
407
+ else
408
+ set_ecmult_window=$req_ecmult_window
409
+ fi
410
+
411
+ error_window_size=[ 'window size for ecmult precomputation not an integer in range [ 2..24] or "auto"']
412
+ case $set_ecmult_window in
413
+ ''|*[ [ !0-9] ] *)
414
+ # no valid integer
415
+ AC_MSG_ERROR ( $error_window_size )
416
+ ;;
417
+ *)
418
+ if test "$set_ecmult_window" -lt 2 -o "$set_ecmult_window" -gt 24 ; then
419
+ # not in range
420
+ AC_MSG_ERROR ( $error_window_size )
421
+ fi
422
+ AC_DEFINE_UNQUOTED ( ECMULT_WINDOW_SIZE , $set_ecmult_window , [ Set window size for ecmult precomputation] )
423
+ ;;
424
+ esac
425
+
369
426
if test x"$use_tests" = x"yes"; then
370
427
SECP_OPENSSL_CHECK
371
428
if test x"$has_openssl_ec" = x"yes"; then
@@ -441,17 +498,9 @@ if test x"$use_external_asm" = x"yes"; then
441
498
AC_DEFINE ( USE_EXTERNAL_ASM , 1 , [ Define this symbol if an external (non-inline) assembly implementation is used] )
442
499
fi
443
500
444
- AC_MSG_NOTICE ( [ Using static precomputation: $set_precomp] )
445
- AC_MSG_NOTICE ( [ Using assembly optimizations: $set_asm] )
446
- AC_MSG_NOTICE ( [ Using field implementation: $set_field] )
447
- AC_MSG_NOTICE ( [ Using bignum implementation: $set_bignum] )
448
- AC_MSG_NOTICE ( [ Using scalar implementation: $set_scalar] )
449
- AC_MSG_NOTICE ( [ Using endomorphism optimizations: $use_endomorphism] )
450
- AC_MSG_NOTICE ( [ Building benchmarks: $use_benchmark] )
451
- AC_MSG_NOTICE ( [ Building for coverage analysis: $enable_coverage] )
452
- AC_MSG_NOTICE ( [ Building ECDH module: $enable_module_ecdh] )
453
- AC_MSG_NOTICE ( [ Building ECDSA pubkey recovery module: $enable_module_recovery] )
454
- AC_MSG_NOTICE ( [ Using jni: $use_jni] )
501
+ if test x"$use_external_default_callbacks" = x"yes"; then
502
+ AC_DEFINE ( USE_EXTERNAL_DEFAULT_CALLBACKS , 1 , [ Define this symbol if an external implementation of the default callbacks is used] )
503
+ fi
455
504
456
505
if test x"$enable_experimental" = x"yes"; then
457
506
AC_MSG_NOTICE ( [ ******] )
@@ -482,7 +531,7 @@ AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
482
531
AM_CONDITIONAL([ USE_ECMULT_STATIC_PRECOMPUTATION] , [ test x"$set_precomp" = x"yes"] )
483
532
AM_CONDITIONAL([ ENABLE_MODULE_ECDH] , [ test x"$enable_module_ecdh" = x"yes"] )
484
533
AM_CONDITIONAL([ ENABLE_MODULE_RECOVERY] , [ test x"$enable_module_recovery" = x"yes"] )
485
- AM_CONDITIONAL([ USE_JNI] , [ test x"$use_jni" == x"yes"] )
534
+ AM_CONDITIONAL([ USE_JNI] , [ test x"$use_jni" = x"yes"] )
486
535
AM_CONDITIONAL([ USE_EXTERNAL_ASM] , [ test x"$use_external_asm" = x"yes"] )
487
536
AM_CONDITIONAL([ USE_ASM_ARM] , [ test x"$set_asm" = x"arm"] )
488
537
@@ -492,3 +541,26 @@ unset PKG_CONFIG_PATH
492
541
PKG_CONFIG_PATH="$PKGCONFIG_PATH_TEMP"
493
542
494
543
AC_OUTPUT
544
+
545
+ echo
546
+ echo "Build Options:"
547
+ echo " with endomorphism = $use_endomorphism"
548
+ echo " with ecmult precomp = $set_precomp"
549
+ echo " with external callbacks = $use_external_default_callbacks"
550
+ echo " with jni = $use_jni"
551
+ echo " with benchmarks = $use_benchmark"
552
+ echo " with coverage = $enable_coverage"
553
+ echo " module ecdh = $enable_module_ecdh"
554
+ echo " module recovery = $enable_module_recovery"
555
+ echo
556
+ echo " asm = $set_asm"
557
+ echo " bignum = $set_bignum"
558
+ echo " field = $set_field"
559
+ echo " scalar = $set_scalar"
560
+ echo " ecmult window size = $set_ecmult_window"
561
+ echo
562
+ echo " CC = $CC"
563
+ echo " CFLAGS = $CFLAGS"
564
+ echo " CPPFLAGS = $CPPFLAGS"
565
+ echo " LDFLAGS = $LDFLAGS"
566
+ echo
0 commit comments