]>
Commit | Line | Data |
---|---|---|
3f8fdfbe | 1 | dnl escape "$0x" below using the m4 quadrigaph @S|@, and escape it again with a \ for the shell. |
6fac238f | 2 | AC_DEFUN([SECP_64BIT_ASM_CHECK],[ |
67935050 PW |
3 | AC_MSG_CHECKING(for x86_64 assembly availability) |
4 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
5 | #include <stdint.h>]],[[ | |
6 | uint64_t a = 11, tmp; | |
3f8fdfbe | 7 | __asm__ __volatile__("movq \@S|@0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx"); |
67935050 PW |
8 | ]])],[has_64bit_asm=yes],[has_64bit_asm=no]) |
9 | AC_MSG_RESULT([$has_64bit_asm]) | |
6fac238f | 10 | ]) |
11 | ||
12 | dnl | |
13 | AC_DEFUN([SECP_OPENSSL_CHECK],[ | |
2b4cf416 | 14 | has_libcrypto=no |
6fac238f | 15 | m4_ifdef([PKG_CHECK_MODULES],[ |
971fe815 CF |
16 | PKG_CHECK_MODULES([CRYPTO], [libcrypto], [has_libcrypto=yes],[has_libcrypto=no]) |
17 | if test x"$has_libcrypto" = x"yes"; then | |
18 | TEMP_LIBS="$LIBS" | |
19 | LIBS="$LIBS $CRYPTO_LIBS" | |
20 | AC_CHECK_LIB(crypto, main,[AC_DEFINE(HAVE_LIBCRYPTO,1,[Define this symbol if libcrypto is installed])],[has_libcrypto=no]) | |
21 | LIBS="$TEMP_LIBS" | |
22 | fi | |
6fac238f | 23 | ]) |
2b4cf416 LD |
24 | if test x$has_libcrypto = xno; then |
25 | AC_CHECK_HEADER(openssl/crypto.h,[ | |
26 | AC_CHECK_LIB(crypto, main,[ | |
27 | has_libcrypto=yes | |
28 | CRYPTO_LIBS=-lcrypto | |
29 | AC_DEFINE(HAVE_LIBCRYPTO,1,[Define this symbol if libcrypto is installed]) | |
30 | ]) | |
31 | ]) | |
32 | LIBS= | |
33 | fi | |
28ade27d | 34 | if test x"$has_libcrypto" = x"yes" && test x"$has_openssl_ec" = x; then |
6fac238f | 35 | AC_MSG_CHECKING(for EC functions in libcrypto) |
84b5fc5b | 36 | CPPFLAGS_TEMP="$CPPFLAGS" |
37 | CPPFLAGS="$CRYPTO_CPPFLAGS $CPPFLAGS" | |
6fac238f | 38 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
39 | #include <openssl/ec.h> | |
40 | #include <openssl/ecdsa.h> | |
41 | #include <openssl/obj_mac.h>]],[[ | |
42 | EC_KEY *eckey = EC_KEY_new_by_curve_name(NID_secp256k1); | |
43 | ECDSA_sign(0, NULL, 0, NULL, NULL, eckey); | |
44 | ECDSA_verify(0, NULL, 0, NULL, 0, eckey); | |
45 | EC_KEY_free(eckey); | |
12de8638 GM |
46 | ECDSA_SIG *sig_openssl; |
47 | sig_openssl = ECDSA_SIG_new(); | |
12de8638 | 48 | ECDSA_SIG_free(sig_openssl); |
6fac238f | 49 | ]])],[has_openssl_ec=yes],[has_openssl_ec=no]) |
50 | AC_MSG_RESULT([$has_openssl_ec]) | |
84b5fc5b | 51 | CPPFLAGS="$CPPFLAGS_TEMP" |
6fac238f | 52 | fi |
53 | ]) | |
54 | ||
55 | dnl | |
56 | AC_DEFUN([SECP_GMP_CHECK],[ | |
57 | if test x"$has_gmp" != x"yes"; then | |
e2274c58 CF |
58 | CPPFLAGS_TEMP="$CPPFLAGS" |
59 | CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS" | |
60 | LIBS_TEMP="$LIBS" | |
61 | LIBS="$GMP_LIBS $LIBS" | |
62 | 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])])]) | |
63 | CPPFLAGS="$CPPFLAGS_TEMP" | |
64 | LIBS="$LIBS_TEMP" | |
6fac238f | 65 | fi |
6fac238f | 66 | ]) |