1 dnl escape "$0x" below using the m4 quadrigaph @S|@, and escape it again with a \ for the shell.
2 AC_DEFUN([SECP_64BIT_ASM_CHECK],[
3 AC_MSG_CHECKING(for x86_64 assembly availability)
4 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5 #include <stdint.h>]],[[
7 __asm__ __volatile__("movq \@S|@0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx");
8 ]])],[has_64bit_asm=yes],[has_64bit_asm=no])
9 AC_MSG_RESULT([$has_64bit_asm])
13 AC_DEFUN([SECP_OPENSSL_CHECK],[
15 m4_ifdef([PKG_CHECK_MODULES],[
16 PKG_CHECK_MODULES([CRYPTO], [libcrypto], [has_libcrypto=yes],[has_libcrypto=no])
17 if test x"$has_libcrypto" = x"yes"; then
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])
24 if test x$has_libcrypto = xno; then
25 AC_CHECK_HEADER(openssl/crypto.h,[
26 AC_CHECK_LIB(crypto, main,[
29 AC_DEFINE(HAVE_LIBCRYPTO,1,[Define this symbol if libcrypto is installed])
34 if test x"$has_libcrypto" = x"yes" && test x"$has_openssl_ec" = x; then
35 AC_MSG_CHECKING(for EC functions in libcrypto)
36 CPPFLAGS_TEMP="$CPPFLAGS"
37 CPPFLAGS="$CRYPTO_CPPFLAGS $CPPFLAGS"
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);
46 ECDSA_SIG *sig_openssl;
47 sig_openssl = ECDSA_SIG_new();
48 ECDSA_SIG_free(sig_openssl);
49 ]])],[has_openssl_ec=yes],[has_openssl_ec=no])
50 AC_MSG_RESULT([$has_openssl_ec])
51 CPPFLAGS="$CPPFLAGS_TEMP"
56 AC_DEFUN([SECP_GMP_CHECK],[
57 if test x"$has_gmp" != x"yes"; then
58 CPPFLAGS_TEMP="$CPPFLAGS"
59 CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
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"