You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

starwels_secp.m4 2.3KB

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