@@ -6,7 +6,7 @@ AC_CANONICAL_HOST
6
6
AH_TOP ( [ #ifndef LIBSECP256K1_CONFIG_H] )
7
7
AH_TOP ( [ #define LIBSECP256K1_CONFIG_H] )
8
8
AH_BOTTOM ( [ #endif //LIBSECP256K1_CONFIG_H] )
9
- AM_INIT_AUTOMAKE ( [ foreign] )
9
+ AM_INIT_AUTOMAKE ( [ foreign subdir-objects ] )
10
10
LT_INIT
11
11
12
12
dnl make the compilation flags quiet unless V=1 is used
@@ -23,7 +23,7 @@ if test "x$CFLAGS" = "x"; then
23
23
fi
24
24
25
25
AC_PROG_CC_C99
26
- if test x"$ac_cv_prog_cc_c99" == x"no"; then
26
+ if test x"$ac_cv_prog_cc_c99" = x"no"; then
27
27
AC_MSG_ERROR ( [ c99 compiler support required] )
28
28
fi
29
29
@@ -82,9 +82,9 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
82
82
83
83
84
84
AC_ARG_ENABLE ( benchmark ,
85
- AS_HELP_STRING ( [ --enable-benchmark] ,[ compile benchmark (default is yes )] ) ,
85
+ AS_HELP_STRING ( [ --enable-benchmark] ,[ compile benchmark (default is no )] ) ,
86
86
[ use_benchmark=$enableval] ,
87
- [ use_benchmark=yes ] )
87
+ [ use_benchmark=no ] )
88
88
89
89
AC_ARG_ENABLE ( tests ,
90
90
AS_HELP_STRING ( [ --enable-tests] ,[ compile tests (default is yes)] ) ,
@@ -96,15 +96,18 @@ AC_ARG_ENABLE(endomorphism,
96
96
[ use_endomorphism=$enableval] ,
97
97
[ use_endomorphism=no] )
98
98
99
- AC_ARG_WITH ( [ field] , [ AS_HELP_STRING ( [ --with-field=gmp| 64bit|64bit_asm |32bit|auto] ,
99
+ AC_ARG_WITH ( [ field] , [ AS_HELP_STRING ( [ --with-field=64bit|32bit|auto] ,
100
100
[ Specify Field Implementation. Default is auto] ) ] ,[ req_field=$withval] , [ req_field=auto] )
101
101
102
- AC_ARG_WITH ( [ bignum] , [ AS_HELP_STRING ( [ --with-bignum=gmp|none |auto] ,
102
+ AC_ARG_WITH ( [ bignum] , [ AS_HELP_STRING ( [ --with-bignum=gmp|no |auto] ,
103
103
[ Specify Bignum Implementation. Default is auto] ) ] ,[ req_bignum=$withval] , [ req_bignum=auto] )
104
104
105
105
AC_ARG_WITH ( [ scalar] , [ AS_HELP_STRING ( [ --with-scalar=64bit|32bit|auto] ,
106
106
[ Specify scalar implementation. Default is auto] ) ] ,[ req_scalar=$withval] , [ req_scalar=auto] )
107
107
108
+ AC_ARG_WITH ( [ asm] , [ AS_HELP_STRING ( [ --with-asm=x86_64|no|auto]
109
+ [ Specify assembly optimizations to use. Default is auto] ) ] ,[ req_asm=$withval] , [ req_asm=auto] )
110
+
108
111
AC_CHECK_TYPES ( [ __int128] )
109
112
110
113
AC_MSG_CHECKING ( [ for __builtin_expect] )
@@ -113,40 +116,54 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[void myfunc() {__builtin_expect(0,0);}]])],
113
116
[ AC_MSG_RESULT ( [ no] )
114
117
] )
115
118
116
- if test x"$req_field " = x"auto"; then
119
+ if test x"$req_asm " = x"auto"; then
117
120
SECP_64BIT_ASM_CHECK
118
121
if test x"$has_64bit_asm" = x"yes"; then
119
- set_field=64bit_asm
122
+ set_asm=x86_64
123
+ fi
124
+ if test x"$set_asm" = x; then
125
+ set_asm=no
120
126
fi
127
+ else
128
+ set_asm=$req_asm
129
+ case $set_asm in
130
+ x86_64)
131
+ SECP_64BIT_ASM_CHECK
132
+ if test x"$has_64bit_asm" != x"yes"; then
133
+ AC_MSG_ERROR ( [ x86_64 assembly optimization requested but not available] )
134
+ fi
135
+ ;;
136
+ no)
137
+ ;;
138
+ *)
139
+ AC_MSG_ERROR ( [ invalid assembly optimization selection] )
140
+ ;;
141
+ esac
142
+ fi
121
143
144
+ if test x"$req_field" = x"auto"; then
145
+ if test x"set_asm" = x"x86_64"; then
146
+ set_field=64bit
147
+ fi
122
148
if test x"$set_field" = x; then
123
149
SECP_INT128_CHECK
124
150
if test x"$has_int128" = x"yes"; then
125
151
set_field=64bit
126
152
fi
127
153
fi
128
-
129
- if test x"$set_field" = x; then
130
- SECP_GMP_CHECK
131
- if test x"$has_gmp" = x"yes"; then
132
- set_field=gmp
133
- fi
134
- fi
135
-
136
154
if test x"$set_field" = x; then
137
155
set_field=32bit
138
156
fi
139
157
else
140
158
set_field=$req_field
141
159
case $set_field in
142
- 64bit_asm)
143
- SECP_64BIT_ASM_CHECK
144
- ;;
145
160
64bit)
146
- SECP_INT128_CHECK
147
- ;;
148
- gmp)
149
- SECP_GMP_CHECK
161
+ if test x"$set_asm" != x"x86_64"; then
162
+ SECP_INT128_CHECK
163
+ if test x"$has_int128" != x"yes"; then
164
+ AC_MSG_ERROR ( [ 64bit field explicitly requested but neither __int128 support or x86_64 assembly available] )
165
+ fi
166
+ fi
150
167
;;
151
168
32bit)
152
169
;;
@@ -157,11 +174,9 @@ else
157
174
fi
158
175
159
176
if test x"$req_scalar" = x"auto"; then
160
- if test x"$set_scalar" = x; then
161
- SECP_INT128_CHECK
162
- if test x"$has_int128" = x"yes"; then
163
- set_scalar=64bit
164
- fi
177
+ SECP_INT128_CHECK
178
+ if test x"$has_int128" = x"yes"; then
179
+ set_scalar=64bit
165
180
fi
166
181
if test x"$set_scalar" = x; then
167
182
set_scalar=32bit
171
186
case $set_scalar in
172
187
64bit)
173
188
SECP_INT128_CHECK
189
+ if test x"$has_int128" != x"yes"; then
190
+ AC_MSG_ERROR ( [ 64bit scalar explicitly requested but __int128 support not available] )
191
+ fi
174
192
;;
175
193
32bit)
176
194
;;
@@ -187,36 +205,42 @@ if test x"$req_bignum" = x"auto"; then
187
205
fi
188
206
189
207
if test x"$set_bignum" = x; then
190
- set_bignum=none
208
+ set_bignum=no
191
209
fi
192
210
else
193
211
set_bignum=$req_bignum
194
212
case $set_bignum in
195
213
gmp)
196
214
SECP_GMP_CHECK
215
+ if test x"$has_gmp" != x"yes"; then
216
+ AC_MSG_ERROR ( [ gmp bignum explicitly requested but libgmp not available] )
217
+ fi
197
218
;;
198
- none )
219
+ no )
199
220
;;
200
221
*)
201
222
AC_MSG_ERROR ( [ invalid bignum implementation selection] )
202
223
;;
203
224
esac
204
225
fi
205
226
227
+ # select assembly optimization
228
+ case $set_asm in
229
+ x86_64)
230
+ AC_DEFINE ( USE_ASM_X86_64 , 1 , [ Define this symbol to enable x86_64 assembly optimizations] )
231
+ ;;
232
+ no)
233
+ ;;
234
+ *)
235
+ AC_MSG_ERROR ( [ invalid assembly optimizations] )
236
+ ;;
237
+ esac
238
+
206
239
# select field implementation
207
240
case $set_field in
208
- 64bit_asm)
209
- AC_DEFINE ( USE_FIELD_5X52_ASM , 1 , [ Define this symbol to use the assembly version for the 5x52 field implementation] )
210
- AC_DEFINE ( USE_FIELD_5X52 , 1 , [ Define this symbol to use the FIELD_5X52 implementation] )
211
- ;;
212
241
64bit)
213
- AC_DEFINE ( USE_FIELD_5X52_INT128 , 1 , [ Define this symbol to use the __int128 version for the 5x52 field implementation] )
214
242
AC_DEFINE ( USE_FIELD_5X52 , 1 , [ Define this symbol to use the FIELD_5X52 implementation] )
215
243
;;
216
- gmp)
217
- AC_DEFINE ( HAVE_LIBGMP ,1 ,[ Define this symbol if libgmp is installed] )
218
- AC_DEFINE ( USE_FIELD_GMP , 1 , [ Define this symbol to use the FIELD_GMP implementation] )
219
- ;;
220
244
32bit)
221
245
AC_DEFINE ( USE_FIELD_10X26 , 1 , [ Define this symbol to use the FIELD_10X26 implementation] )
222
246
;;
233
257
AC_DEFINE ( USE_FIELD_INV_NUM , 1 , [ Define this symbol to use the num-based field inverse implementation] )
234
258
AC_DEFINE ( USE_SCALAR_INV_NUM , 1 , [ Define this symbol to use the num-based scalar inverse implementation] )
235
259
;;
236
- none )
260
+ no )
237
261
AC_DEFINE ( USE_NUM_NONE , 1 , [ Define this symbol to use no num implementation] )
238
262
AC_DEFINE ( USE_FIELD_INV_BUILTIN , 1 , [ Define this symbol to use the native field inverse implementation] )
239
263
AC_DEFINE ( USE_SCALAR_INV_BUILTIN , 1 , [ Define this symbol to use the native scalar inverse implementation] )
258
282
259
283
if test x"$use_tests" = x"yes"; then
260
284
SECP_OPENSSL_CHECK
261
- if test x"$has_openssl_ec" == x"yes"; then
285
+ if test x"$has_openssl_ec" = x"yes"; then
262
286
AC_DEFINE ( ENABLE_OPENSSL_TESTS , 1 , [ Define this symbol if OpenSSL EC functions are available] )
263
287
SECP_TEST_INCLUDES="$SSL_CFLAGS $CRYPTO_CFLAGS"
264
288
SECP_TEST_LIBS="$CRYPTO_LIBS"
@@ -272,7 +296,7 @@ if test x"$use_tests" = x"yes"; then
272
296
fi
273
297
fi
274
298
275
- if test x"$set_field" = x"gmp" || test x"$ set_bignum" = x"gmp"; then
299
+ if test x"$set_bignum" = x"gmp"; then
276
300
SECP_LIBS="$SECP_LIBS $GMP_LIBS"
277
301
SECP_INCLUDES="$SECP_INCLUDES $GMP_CPPFLAGS"
278
302
fi
@@ -281,19 +305,20 @@ if test x"$use_endomorphism" = x"yes"; then
281
305
AC_DEFINE ( USE_ENDOMORPHISM , 1 , [ Define this symbol to use endomorphism optimization] )
282
306
fi
283
307
308
+ AC_MSG_NOTICE ( [ Using assembly optimizations: $set_asm] )
284
309
AC_MSG_NOTICE ( [ Using field implementation: $set_field] )
285
310
AC_MSG_NOTICE ( [ Using bignum implementation: $set_bignum] )
286
311
AC_MSG_NOTICE ( [ Using scalar implementation: $set_scalar] )
312
+ AC_MSG_NOTICE ( [ Using endomorphism optimizations: $use_endomorphism] )
287
313
288
314
AC_CONFIG_HEADERS ( [ src/libsecp256k1-config.h] )
289
315
AC_CONFIG_FILES ( [ Makefile libsecp256k1.pc] )
290
316
AC_SUBST ( SECP_INCLUDES )
291
317
AC_SUBST ( SECP_LIBS )
292
318
AC_SUBST ( SECP_TEST_LIBS )
293
319
AC_SUBST ( SECP_TEST_INCLUDES )
294
- AM_CONDITIONAL([ USE_ASM] , [ test x"$set_field" == x"64bit_asm"] )
295
320
AM_CONDITIONAL([ USE_TESTS] , [ test x"$use_tests" != x"no"] )
296
- AM_CONDITIONAL([ USE_BENCHMARK] , [ test x"$use_benchmark" ! = x"no "] )
321
+ AM_CONDITIONAL([ USE_BENCHMARK] , [ test x"$use_benchmark" = x"yes "] )
297
322
298
323
dnl make sure nothing new is exported so that we don't break the cache
299
324
PKGCONFIG_PATH_TEMP="$PKG_CONFIG_PATH"
0 commit comments