@@ -96,15 +96,18 @@ AC_ARG_ENABLE(endomorphism,
9696 [ use_endomorphism=$enableval] ,
9797 [ use_endomorphism=no] )
9898
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=gmp|64bit|32bit|auto] ,
100100[ Specify Field Implementation. Default is auto] ) ] ,[ req_field=$withval] , [ req_field=auto] )
101101
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] ,
103103[ Specify Bignum Implementation. Default is auto] ) ] ,[ req_bignum=$withval] , [ req_bignum=auto] )
104104
105105AC_ARG_WITH ( [ scalar] , [ AS_HELP_STRING ( [ --with-scalar=64bit|32bit|auto] ,
106106[ Specify scalar implementation. Default is auto] ) ] ,[ req_scalar=$withval] , [ req_scalar=auto] )
107107
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+
108111AC_CHECK_TYPES ( [ __int128] )
109112
110113AC_MSG_CHECKING ( [ for __builtin_expect] )
@@ -113,40 +116,66 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[void myfunc() {__builtin_expect(0,0);}]])],
113116 [ AC_MSG_RESULT ( [ no] )
114117 ] )
115118
116- if test x"$req_field " = x"auto"; then
119+ if test x"$req_asm " = x"auto"; then
117120 SECP_64BIT_ASM_CHECK
118121 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
120126 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
121143
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
122148 if test x"$set_field" = x; then
123149 SECP_INT128_CHECK
124150 if test x"$has_int128" = x"yes"; then
125151 set_field=64bit
126152 fi
127153 fi
128-
129154 if test x"$set_field" = x; then
130155 SECP_GMP_CHECK
131156 if test x"$has_gmp" = x"yes"; then
132157 set_field=gmp
133158 fi
134159 fi
135-
136160 if test x"$set_field" = x; then
137161 set_field=32bit
138162 fi
139163else
140164 set_field=$req_field
141165 case $set_field in
142- 64bit_asm)
143- SECP_64BIT_ASM_CHECK
144- ;;
145166 64bit)
146- SECP_INT128_CHECK
167+ if test x"$set_asm" != x"x86_64"; then
168+ SECP_INT128_CHECK
169+ if test x"$has_int128" != x"yes"; then
170+ AC_MSG_ERROR ( [ 64bit field explicitly requested but neither __int128 support or x86_64 assembly available] )
171+ fi
172+ fi
147173 ;;
148174 gmp)
149175 SECP_GMP_CHECK
176+ if test x"$has_gmp" != x"yes"; then
177+ AC_MSG_ERROR ( [ gmp field explicitly requested but libgmp not available] )
178+ fi
150179 ;;
151180 32bit)
152181 ;;
@@ -157,11 +186,9 @@ else
157186fi
158187
159188if 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
189+ SECP_INT128_CHECK
190+ if test x"$has_int128" = x"yes"; then
191+ set_scalar=64bit
165192 fi
166193 if test x"$set_scalar" = x; then
167194 set_scalar=32bit
171198 case $set_scalar in
172199 64bit)
173200 SECP_INT128_CHECK
201+ if test x"$has_int128" != x"yes"; then
202+ AC_MSG_ERROR ( [ 64bit scalar explicitly requested but __int128 support not available] )
203+ fi
174204 ;;
175205 32bit)
176206 ;;
@@ -187,30 +217,40 @@ if test x"$req_bignum" = x"auto"; then
187217 fi
188218
189219 if test x"$set_bignum" = x; then
190- set_bignum=none
220+ set_bignum=no
191221 fi
192222else
193223 set_bignum=$req_bignum
194224 case $set_bignum in
195225 gmp)
196226 SECP_GMP_CHECK
227+ if test x"$has_gmp" != x"yes"; then
228+ AC_MSG_ERROR ( [ gmp bignum explicitly requested but libgmp not available] )
229+ fi
197230 ;;
198- none )
231+ no )
199232 ;;
200233 *)
201234 AC_MSG_ERROR ( [ invalid bignum implementation selection] )
202235 ;;
203236 esac
204237fi
205238
239+ # select assembly optimization
240+ case $set_asm in
241+ x86_64)
242+ AC_DEFINE ( USE_ASM_X86_64 , 1 , [ Define this symbol to enable x86_64 assembly optimizations] )
243+ ;;
244+ no)
245+ ;;
246+ *)
247+ AC_MSG_ERROR ( [ invalid assembly optimizations] )
248+ ;;
249+ esac
250+
206251# select field implementation
207252case $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- ;;
21225364bit)
213- AC_DEFINE ( USE_FIELD_5X52_INT128 , 1 , [ Define this symbol to use the __int128 version for the 5x52 field implementation] )
214254 AC_DEFINE ( USE_FIELD_5X52 , 1 , [ Define this symbol to use the FIELD_5X52 implementation] )
215255 ;;
216256gmp)
233273 AC_DEFINE ( USE_FIELD_INV_NUM , 1 , [ Define this symbol to use the num-based field inverse implementation] )
234274 AC_DEFINE ( USE_SCALAR_INV_NUM , 1 , [ Define this symbol to use the num-based scalar inverse implementation] )
235275 ;;
236- none )
276+ no )
237277 AC_DEFINE ( USE_NUM_NONE , 1 , [ Define this symbol to use no num implementation] )
238278 AC_DEFINE ( USE_FIELD_INV_BUILTIN , 1 , [ Define this symbol to use the native field inverse implementation] )
239279 AC_DEFINE ( USE_SCALAR_INV_BUILTIN , 1 , [ Define this symbol to use the native scalar inverse implementation] )
@@ -281,17 +321,18 @@ if test x"$use_endomorphism" = x"yes"; then
281321 AC_DEFINE ( USE_ENDOMORPHISM , 1 , [ Define this symbol to use endomorphism optimization] )
282322fi
283323
324+ AC_MSG_NOTICE ( [ Using assembly optimizations: $set_asm] )
284325AC_MSG_NOTICE ( [ Using field implementation: $set_field] )
285326AC_MSG_NOTICE ( [ Using bignum implementation: $set_bignum] )
286327AC_MSG_NOTICE ( [ Using scalar implementation: $set_scalar] )
328+ AC_MSG_NOTICE ( [ Using endomorphism optimizations: $use_endomorphism] )
287329
288330AC_CONFIG_HEADERS ( [ src/libsecp256k1-config.h] )
289331AC_CONFIG_FILES ( [ Makefile libsecp256k1.pc] )
290332AC_SUBST ( SECP_INCLUDES )
291333AC_SUBST ( SECP_LIBS )
292334AC_SUBST ( SECP_TEST_LIBS )
293335AC_SUBST ( SECP_TEST_INCLUDES )
294- AM_CONDITIONAL([ USE_ASM] , [ test x"$set_field" = x"64bit_asm"] )
295336AM_CONDITIONAL([ USE_TESTS] , [ test x"$use_tests" != x"no"] )
296337AM_CONDITIONAL([ USE_BENCHMARK] , [ test x"$use_benchmark" = x"yes"] )
297338
0 commit comments