]>
Commit | Line | Data |
---|---|---|
6fac238f | 1 | dnl libsecp25k1 helper checks |
2 | AC_DEFUN([SECP_INT128_CHECK],[ | |
3 | has_int128=$ac_cv_type___int128 | |
4 | if test x"$has_int128" != x"yes" && test x"$set_field" = x"64bit"; then | |
5 | AC_MSG_ERROR([$set_field field support explicitly requested but is not compatible with this host]) | |
6 | fi | |
7 | if test x"$has_int128" != x"yes" && test x"$set_scalar" = x"64bit"; then | |
8 | AC_MSG_ERROR([$set_scalar scalar support explicitly requested but is not compatible with this host]) | |
9 | fi | |
10 | ]) | |
11 | ||
12 | dnl | |
13 | AC_DEFUN([SECP_64BIT_ASM_CHECK],[ | |
67935050 PW |
14 | AC_MSG_CHECKING(for x86_64 assembly availability) |
15 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
16 | #include <stdint.h>]],[[ | |
17 | uint64_t a = 11, tmp; | |
18 | __asm__ __volatile__("movq $0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx"); | |
19 | ]])],[has_64bit_asm=yes],[has_64bit_asm=no]) | |
20 | AC_MSG_RESULT([$has_64bit_asm]) | |
21 | if test x"$set_field" == x"64bit_asm"; then | |
22 | if test x"$has_64bit_asm" == x"no"; then | |
23 | AC_MSG_ERROR([$set_field field support explicitly requested but no x86_64 assembly available]) | |
6fac238f | 24 | fi |
25 | fi | |
26 | ]) | |
27 | ||
28 | dnl | |
29 | AC_DEFUN([SECP_OPENSSL_CHECK],[ | |
30 | if test x"$use_pkgconfig" = x"yes"; then | |
31 | : #NOP | |
32 | m4_ifdef([PKG_CHECK_MODULES],[ | |
971fe815 CF |
33 | PKG_CHECK_MODULES([CRYPTO], [libcrypto], [has_libcrypto=yes],[has_libcrypto=no]) |
34 | if test x"$has_libcrypto" = x"yes"; then | |
35 | TEMP_LIBS="$LIBS" | |
36 | LIBS="$LIBS $CRYPTO_LIBS" | |
37 | AC_CHECK_LIB(crypto, main,[AC_DEFINE(HAVE_LIBCRYPTO,1,[Define this symbol if libcrypto is installed])],[has_libcrypto=no]) | |
38 | LIBS="$TEMP_LIBS" | |
39 | fi | |
6fac238f | 40 | ]) |
41 | else | |
42 | AC_CHECK_HEADER(openssl/crypto.h,[AC_CHECK_LIB(crypto, main,[has_libcrypto=yes; CRYPTO_LIBS=-lcrypto; AC_DEFINE(HAVE_LIBCRYPTO,1,[Define this symbol if libcrypto is installed])] | |
43 | )]) | |
44 | LIBS= | |
45 | fi | |
46 | if test x"$has_libcrypto" == x"yes" && test x"$has_openssl_ec" = x; then | |
47 | AC_MSG_CHECKING(for EC functions in libcrypto) | |
48 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
49 | #include <openssl/ec.h> | |
50 | #include <openssl/ecdsa.h> | |
51 | #include <openssl/obj_mac.h>]],[[ | |
52 | EC_KEY *eckey = EC_KEY_new_by_curve_name(NID_secp256k1); | |
53 | ECDSA_sign(0, NULL, 0, NULL, NULL, eckey); | |
54 | ECDSA_verify(0, NULL, 0, NULL, 0, eckey); | |
55 | EC_KEY_free(eckey); | |
56 | ]])],[has_openssl_ec=yes],[has_openssl_ec=no]) | |
57 | AC_MSG_RESULT([$has_openssl_ec]) | |
58 | fi | |
59 | ]) | |
60 | ||
61 | dnl | |
62 | AC_DEFUN([SECP_GMP_CHECK],[ | |
63 | if test x"$has_gmp" != x"yes"; then | |
e2274c58 CF |
64 | CPPFLAGS_TEMP="$CPPFLAGS" |
65 | CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS" | |
66 | LIBS_TEMP="$LIBS" | |
67 | LIBS="$GMP_LIBS $LIBS" | |
68 | 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])])]) | |
69 | CPPFLAGS="$CPPFLAGS_TEMP" | |
70 | LIBS="$LIBS_TEMP" | |
6fac238f | 71 | fi |
72 | if test x"$set_field" = x"gmp" && test x"$has_gmp" != x"yes"; then | |
73 | AC_MSG_ERROR([$set_field field support explicitly requested but libgmp was not found]) | |
74 | fi | |
75 | if test x"$set_bignum" = x"gmp" && test x"$has_gmp" != x"yes"; then | |
76 | AC_MSG_ERROR([$set_bignum field support explicitly requested but libgmp was not found]) | |
77 | fi | |
78 | ]) | |
79 |