1 dnl libsecp25k1 helper checks
2 AC_DEFUN([SECP_INT128_CHECK],[
3 has_int128=$ac_cv_type___int128
6 dnl escape "$0x" below using the m4 quadrigaph @S|@, and escape it again with a \ for the shell.
7 AC_DEFUN([SECP_64BIT_ASM_CHECK],[
8 AC_MSG_CHECKING(for x86_64 assembly availability)
9 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
10 #include <stdint.h>]],[[
12 __asm__ __volatile__("movq \@S|@0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx");
13 ]])],[has_64bit_asm=yes],[has_64bit_asm=no])
14 AC_MSG_RESULT([$has_64bit_asm])
18 AC_DEFUN([SECP_OPENSSL_CHECK],[
20 m4_ifdef([PKG_CHECK_MODULES],[
21 PKG_CHECK_MODULES([CRYPTO], [libcrypto], [has_libcrypto=yes],[has_libcrypto=no])
22 if test x"$has_libcrypto" = x"yes"; then
24 LIBS="$LIBS $CRYPTO_LIBS"
25 AC_CHECK_LIB(crypto, main,[AC_DEFINE(HAVE_LIBCRYPTO,1,[Define this symbol if libcrypto is installed])],[has_libcrypto=no])
29 if test x$has_libcrypto = xno; then
30 AC_CHECK_HEADER(openssl/crypto.h,[
31 AC_CHECK_LIB(crypto, main,[
34 AC_DEFINE(HAVE_LIBCRYPTO,1,[Define this symbol if libcrypto is installed])
39 if test x"$has_libcrypto" = x"yes" && test x"$has_openssl_ec" = x; then
40 AC_MSG_CHECKING(for EC functions in libcrypto)
41 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
42 #include <openssl/ec.h>
43 #include <openssl/ecdsa.h>
44 #include <openssl/obj_mac.h>]],[[
45 EC_KEY *eckey = EC_KEY_new_by_curve_name(NID_secp256k1);
46 ECDSA_sign(0, NULL, 0, NULL, NULL, eckey);
47 ECDSA_verify(0, NULL, 0, NULL, 0, eckey);
49 ECDSA_SIG *sig_openssl;
50 sig_openssl = ECDSA_SIG_new();
51 ECDSA_SIG_free(sig_openssl);
52 ]])],[has_openssl_ec=yes],[has_openssl_ec=no])
53 AC_MSG_RESULT([$has_openssl_ec])
58 AC_DEFUN([SECP_GMP_CHECK],[
59 if test x"$has_gmp" != x"yes"; then
60 CPPFLAGS_TEMP="$CPPFLAGS"
61 CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
63 LIBS="$GMP_LIBS $LIBS"
64 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])])])
65 CPPFLAGS="$CPPFLAGS_TEMP"