]> Git Repo - secp256k1.git/blame - configure.ac
Update configure.ac to make it build on OpenBSD
[secp256k1.git] / configure.ac
CommitLineData
78cd96b1
CF
1AC_PREREQ([2.60])
2AC_INIT([libsecp256k1],[0.1])
6fac238f 3AC_CONFIG_AUX_DIR([build-aux])
4AC_CONFIG_MACRO_DIR([build-aux/m4])
78cd96b1
CF
5AC_CANONICAL_HOST
6AH_TOP([#ifndef LIBSECP256K1_CONFIG_H])
7AH_TOP([#define LIBSECP256K1_CONFIG_H])
f735446c 8AH_BOTTOM([#endif /*LIBSECP256K1_CONFIG_H*/])
5190079e 9AM_INIT_AUTOMAKE([foreign subdir-objects])
78cd96b1
CF
10LT_INIT
11
53628757
CF
12dnl make the compilation flags quiet unless V=1 is used
13m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
14
78cd96b1
CF
15PKG_PROG_PKG_CONFIG
16
3ab1178d
CF
17AC_PATH_TOOL(AR, ar)
18AC_PATH_TOOL(RANLIB, ranlib)
19AC_PATH_TOOL(STRIP, strip)
fbecc38a 20AX_PROG_CC_FOR_BUILD
3ab1178d 21
056ad310 22if test "x$CFLAGS" = "x"; then
c88e2b8c
PW
23 CFLAGS="-O3 -g"
24fi
25
ed5334a7 26AM_PROG_CC_C_O
27
f735446c
GM
28AC_PROG_CC_C89
29if test x"$ac_cv_prog_cc_c89" = x"no"; then
30 AC_MSG_ERROR([c89 compiler support required])
78cd96b1
CF
31fi
32
33case $host in
34 *mingw*)
35 use_pkgconfig=no
36 ;;
37 *)
38 use_pkgconfig=yes
39 ;;
40esac
41
a86f241d 42case $host_os in
e2274c58
CF
43 *darwin*)
44 if test x$cross_compiling != xyes; then
45 AC_PATH_PROG([BREW],brew,)
46 if test x$BREW != x; then
47 dnl These Homebrew packages may be keg-only, meaning that they won't be found
48 dnl in expected paths because they may conflict with system files. Ask
49 dnl Homebrew where each one is located, then adjust paths accordingly.
50
51 openssl_prefix=`$BREW --prefix openssl 2>/dev/null`
52 gmp_prefix=`$BREW --prefix gmp 2>/dev/null`
53 if test x$openssl_prefix != x; then
54 PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
55 export PKG_CONFIG_PATH
56 fi
57 if test x$gmp_prefix != x; then
58 GMP_CPPFLAGS="-I$gmp_prefix/include"
59 GMP_LIBS="-L$gmp_prefix/lib"
60 fi
61 else
62 AC_PATH_PROG([PORT],port,)
63 dnl if homebrew isn't installed and macports is, add the macports default paths
64 dnl as a last resort.
65 if test x$PORT != x; then
66 CPPFLAGS="$CPPFLAGS -isystem /opt/local/include"
67 LDFLAGS="$LDFLAGS -L/opt/local/lib"
68 fi
69 fi
70 fi
71 ;;
a86f241d
PD
72esac
73
a099073a
GM
74CFLAGS="$CFLAGS -W"
75
7c3771dd 76warn_CFLAGS="-std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings"
a099073a
GM
77saved_CFLAGS="$CFLAGS"
78CFLAGS="$CFLAGS $warn_CFLAGS"
79AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}])
80AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
81 [ AC_MSG_RESULT([yes]) ],
82 [ AC_MSG_RESULT([no])
83 CFLAGS="$saved_CFLAGS"
84 ])
85
86
78cd96b1 87AC_ARG_ENABLE(benchmark,
8336040f 88 AS_HELP_STRING([--enable-benchmark],[compile benchmark (default is no)]),
78cd96b1 89 [use_benchmark=$enableval],
8336040f 90 [use_benchmark=no])
78cd96b1
CF
91
92AC_ARG_ENABLE(tests,
93 AS_HELP_STRING([--enable-tests],[compile tests (default is yes)]),
94 [use_tests=$enableval],
95 [use_tests=yes])
96
97AC_ARG_ENABLE(endomorphism,
0e9baf6f 98 AS_HELP_STRING([--enable-endomorphism],[enable endomorphism (default is no)]),
78cd96b1 99 [use_endomorphism=$enableval],
0e9baf6f 100 [use_endomorphism=no])
fbecc38a
TD
101
102AC_ARG_ENABLE(ecmult_static_precomputation,
a83bb480 103 AS_HELP_STRING([--enable-ecmult-static-precomputation],[enable precomputed ecmult table for signing (default is yes)]),
fbecc38a 104 [use_ecmult_static_precomputation=$enableval],
a83bb480 105 [use_ecmult_static_precomputation=yes])
78cd96b1 106
7277fd76 107AC_ARG_WITH([field], [AS_HELP_STRING([--with-field=64bit|32bit|auto],
0e9baf6f 108[Specify Field Implementation. Default is auto])],[req_field=$withval], [req_field=auto])
78cd96b1 109
1ba4a60a 110AC_ARG_WITH([bignum], [AS_HELP_STRING([--with-bignum=gmp|no|auto],
78cd96b1
CF
111[Specify Bignum Implementation. Default is auto])],[req_bignum=$withval], [req_bignum=auto])
112
1d52a8b1
PW
113AC_ARG_WITH([scalar], [AS_HELP_STRING([--with-scalar=64bit|32bit|auto],
114[Specify scalar implementation. Default is auto])],[req_scalar=$withval], [req_scalar=auto])
115
1ba4a60a
PW
116AC_ARG_WITH([asm], [AS_HELP_STRING([--with-asm=x86_64|no|auto]
117[Specify assembly optimizations to use. Default is auto])],[req_asm=$withval], [req_asm=auto])
118
78cd96b1
CF
119AC_CHECK_TYPES([__int128])
120
1f46b006
CF
121AC_MSG_CHECKING([for __builtin_expect])
122AC_COMPILE_IFELSE([AC_LANG_SOURCE([[void myfunc() {__builtin_expect(0,0);}]])],
123 [ AC_MSG_RESULT([yes]);AC_DEFINE(HAVE_BUILTIN_EXPECT,1,[Define this symbol if __builtin_expect is available]) ],
124 [ AC_MSG_RESULT([no])
125 ])
1c7fa133 126
1ba4a60a 127if test x"$req_asm" = x"auto"; then
0e9baf6f
CF
128 SECP_64BIT_ASM_CHECK
129 if test x"$has_64bit_asm" = x"yes"; then
1ba4a60a
PW
130 set_asm=x86_64
131 fi
132 if test x"$set_asm" = x; then
133 set_asm=no
78cd96b1 134 fi
1ba4a60a
PW
135else
136 set_asm=$req_asm
137 case $set_asm in
138 x86_64)
139 SECP_64BIT_ASM_CHECK
140 if test x"$has_64bit_asm" != x"yes"; then
141 AC_MSG_ERROR([x86_64 assembly optimization requested but not available])
142 fi
143 ;;
144 no)
145 ;;
146 *)
147 AC_MSG_ERROR([invalid assembly optimization selection])
148 ;;
149 esac
150fi
78cd96b1 151
1ba4a60a
PW
152if test x"$req_field" = x"auto"; then
153 if test x"set_asm" = x"x86_64"; then
154 set_field=64bit
155 fi
78cd96b1
CF
156 if test x"$set_field" = x; then
157 SECP_INT128_CHECK
158 if test x"$has_int128" = x"yes"; then
0e9baf6f 159 set_field=64bit
78cd96b1
CF
160 fi
161 fi
78cd96b1 162 if test x"$set_field" = x; then
0e9baf6f 163 set_field=32bit
78cd96b1
CF
164 fi
165else
166 set_field=$req_field
167 case $set_field in
0e9baf6f 168 64bit)
1ba4a60a
PW
169 if test x"$set_asm" != x"x86_64"; then
170 SECP_INT128_CHECK
171 if test x"$has_int128" != x"yes"; then
172 AC_MSG_ERROR([64bit field explicitly requested but neither __int128 support or x86_64 assembly available])
173 fi
174 fi
78cd96b1 175 ;;
0e9baf6f 176 32bit)
78cd96b1
CF
177 ;;
178 *)
179 AC_MSG_ERROR([invalid field implementation selection])
180 ;;
181 esac
182fi
183
1d52a8b1 184if test x"$req_scalar" = x"auto"; then
1ba4a60a
PW
185 SECP_INT128_CHECK
186 if test x"$has_int128" = x"yes"; then
187 set_scalar=64bit
1d52a8b1
PW
188 fi
189 if test x"$set_scalar" = x; then
190 set_scalar=32bit
191 fi
192else
193 set_scalar=$req_scalar
194 case $set_scalar in
195 64bit)
196 SECP_INT128_CHECK
1ba4a60a
PW
197 if test x"$has_int128" != x"yes"; then
198 AC_MSG_ERROR([64bit scalar explicitly requested but __int128 support not available])
199 fi
1d52a8b1
PW
200 ;;
201 32bit)
202 ;;
203 *)
204 AC_MSG_ERROR([invalid scalar implementation selected])
205 ;;
206 esac
207fi
208
78cd96b1
CF
209if test x"$req_bignum" = x"auto"; then
210 SECP_GMP_CHECK
211 if test x"$has_gmp" = x"yes"; then
212 set_bignum=gmp
213 fi
214
78cd96b1 215 if test x"$set_bignum" = x; then
1ba4a60a 216 set_bignum=no
78cd96b1
CF
217 fi
218else
219 set_bignum=$req_bignum
220 case $set_bignum in
221 gmp)
222 SECP_GMP_CHECK
1ba4a60a
PW
223 if test x"$has_gmp" != x"yes"; then
224 AC_MSG_ERROR([gmp bignum explicitly requested but libgmp not available])
225 fi
78cd96b1 226 ;;
1ba4a60a 227 no)
78cd96b1
CF
228 ;;
229 *)
230 AC_MSG_ERROR([invalid bignum implementation selection])
231 ;;
232 esac
233fi
234
1ba4a60a
PW
235# select assembly optimization
236case $set_asm in
237x86_64)
238 AC_DEFINE(USE_ASM_X86_64, 1, [Define this symbol to enable x86_64 assembly optimizations])
239 ;;
240no)
241 ;;
242*)
243 AC_MSG_ERROR([invalid assembly optimizations])
244 ;;
245esac
246
78cd96b1
CF
247# select field implementation
248case $set_field in
0e9baf6f 24964bit)
78cd96b1
CF
250 AC_DEFINE(USE_FIELD_5X52, 1, [Define this symbol to use the FIELD_5X52 implementation])
251 ;;
0e9baf6f 25232bit)
78cd96b1
CF
253 AC_DEFINE(USE_FIELD_10X26, 1, [Define this symbol to use the FIELD_10X26 implementation])
254 ;;
255*)
256 AC_MSG_ERROR([invalid field implementation])
257 ;;
258esac
259
260# select bignum implementation
261case $set_bignum in
262gmp)
597128d3
PW
263 AC_DEFINE(HAVE_LIBGMP, 1, [Define this symbol if libgmp is installed])
264 AC_DEFINE(USE_NUM_GMP, 1, [Define this symbol to use the gmp implementation for num])
d1502eb4
PW
265 AC_DEFINE(USE_FIELD_INV_NUM, 1, [Define this symbol to use the num-based field inverse implementation])
266 AC_DEFINE(USE_SCALAR_INV_NUM, 1, [Define this symbol to use the num-based scalar inverse implementation])
78cd96b1 267 ;;
1ba4a60a 268no)
597128d3
PW
269 AC_DEFINE(USE_NUM_NONE, 1, [Define this symbol to use no num implementation])
270 AC_DEFINE(USE_FIELD_INV_BUILTIN, 1, [Define this symbol to use the native field inverse implementation])
271 AC_DEFINE(USE_SCALAR_INV_BUILTIN, 1, [Define this symbol to use the native scalar inverse implementation])
272 ;;
78cd96b1
CF
273*)
274 AC_MSG_ERROR([invalid bignum implementation])
275 ;;
276esac
277
1d52a8b1
PW
278#select scalar implementation
279case $set_scalar in
28064bit)
281 AC_DEFINE(USE_SCALAR_4X64, 1, [Define this symbol to use the 4x64 scalar implementation])
282 ;;
28332bit)
284 AC_DEFINE(USE_SCALAR_8X32, 1, [Define this symbol to use the 8x32 scalar implementation])
285 ;;
286*)
287 AC_MSG_ERROR([invalid scalar implementation])
288 ;;
289esac
290
78cd96b1
CF
291if test x"$use_tests" = x"yes"; then
292 SECP_OPENSSL_CHECK
28ade27d 293 if test x"$has_openssl_ec" = x"yes"; then
78cd96b1
CF
294 AC_DEFINE(ENABLE_OPENSSL_TESTS, 1, [Define this symbol if OpenSSL EC functions are available])
295 SECP_TEST_INCLUDES="$SSL_CFLAGS $CRYPTO_CFLAGS"
296 SECP_TEST_LIBS="$CRYPTO_LIBS"
297
298 case $host in
299 *mingw*)
300 SECP_TEST_LIBS="$SECP_TEST_LIBS -lgdi32"
301 ;;
302 esac
303
304 fi
305fi
306
7277fd76 307if test x"$set_bignum" = x"gmp"; then
78cd96b1 308 SECP_LIBS="$SECP_LIBS $GMP_LIBS"
e2274c58 309 SECP_INCLUDES="$SECP_INCLUDES $GMP_CPPFLAGS"
78cd96b1
CF
310fi
311
312if test x"$use_endomorphism" = x"yes"; then
c35ff1ea 313 AC_DEFINE(USE_ENDOMORPHISM, 1, [Define this symbol to use endomorphism optimization])
78cd96b1
CF
314fi
315
fbecc38a
TD
316if test x"$use_ecmult_static_precomputation" = x"yes"; then
317 AC_DEFINE(USE_ECMULT_STATIC_PRECOMPUTATION, 1, [Define this symbol to use a statically generated ecmult table])
318fi
319
ae55e850
PW
320AC_C_BIGENDIAN()
321
1ba4a60a 322AC_MSG_NOTICE([Using assembly optimizations: $set_asm])
78cd96b1
CF
323AC_MSG_NOTICE([Using field implementation: $set_field])
324AC_MSG_NOTICE([Using bignum implementation: $set_bignum])
1d52a8b1 325AC_MSG_NOTICE([Using scalar implementation: $set_scalar])
1ba4a60a 326AC_MSG_NOTICE([Using endomorphism optimizations: $use_endomorphism])
78cd96b1
CF
327
328AC_CONFIG_HEADERS([src/libsecp256k1-config.h])
c7ee71f7 329AC_CONFIG_FILES([Makefile libsecp256k1.pc])
78cd96b1
CF
330AC_SUBST(SECP_INCLUDES)
331AC_SUBST(SECP_LIBS)
332AC_SUBST(SECP_TEST_LIBS)
333AC_SUBST(SECP_TEST_INCLUDES)
78cd96b1 334AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"])
8336040f 335AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
fbecc38a 336AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$use_ecmult_static_precomputation" = x"yes"])
e2274c58
CF
337
338dnl make sure nothing new is exported so that we don't break the cache
339PKGCONFIG_PATH_TEMP="$PKG_CONFIG_PATH"
340unset PKG_CONFIG_PATH
341PKG_CONFIG_PATH="$PKGCONFIG_PATH_TEMP"
342
78cd96b1 343AC_OUTPUT
This page took 0.06945 seconds and 4 git commands to generate.