]> Git Repo - secp256k1.git/blame - build-aux/m4/bitcoin_secp.m4
Merge pull request #150
[secp256k1.git] / build-aux / m4 / bitcoin_secp.m4
CommitLineData
6fac238f 1dnl libsecp25k1 helper checks
2AC_DEFUN([SECP_INT128_CHECK],[
3has_int128=$ac_cv_type___int128
4if 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])
6fi
7if 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])
9fi
10])
11
12dnl
13AC_DEFUN([SECP_64BIT_ASM_CHECK],[
67935050
PW
14AC_MSG_CHECKING(for x86_64 assembly availability)
15AC_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])
20AC_MSG_RESULT([$has_64bit_asm])
21if 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
25fi
26])
27
28dnl
29AC_DEFUN([SECP_OPENSSL_CHECK],[
30if 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 ])
41else
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=
45fi
46if 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])
58fi
59])
60
61dnl
62AC_DEFUN([SECP_GMP_CHECK],[
63if 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 71fi
72if 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])
74fi
75if 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])
77fi
78])
79
This page took 0.030859 seconds and 4 git commands to generate.