bitcoin_secp.m4 (2290B)
1 dnl escape "$0x" below using the m4 quadrigaph @S|@, and escape it again with a \ for the shell. 2 AC_DEFUN([SECP_X86_64_ASM_CHECK],[ 3 AC_MSG_CHECKING(for x86_64 assembly availability) 4 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 5 #include <stdint.h>]],[[ 6 uint64_t a = 11, tmp; 7 __asm__ __volatile__("movq \@S|@0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx"); 8 ]])], [has_x86_64_asm=yes], [has_x86_64_asm=no]) 9 AC_MSG_RESULT([$has_x86_64_asm]) 10 ]) 11 12 AC_DEFUN([SECP_ARM32_ASM_CHECK], [ 13 AC_MSG_CHECKING(for ARM32 assembly availability) 14 SECP_ARM32_ASM_CHECK_CFLAGS_saved_CFLAGS="$CFLAGS" 15 CFLAGS="-x assembler" 16 AC_LINK_IFELSE([AC_LANG_SOURCE([[ 17 .syntax unified 18 .eabi_attribute 24, 1 19 .eabi_attribute 25, 1 20 .text 21 .global main 22 main: 23 ldr r0, =0x002A 24 mov r7, #1 25 swi 0 26 ]])], [has_arm32_asm=yes], [has_arm32_asm=no]) 27 AC_MSG_RESULT([$has_arm32_asm]) 28 CFLAGS="$SECP_ARM32_ASM_CHECK_CFLAGS_saved_CFLAGS" 29 ]) 30 31 AC_DEFUN([SECP_VALGRIND_CHECK],[ 32 AC_MSG_CHECKING([for valgrind support]) 33 if test x"$has_valgrind" != x"yes"; then 34 CPPFLAGS_TEMP="$CPPFLAGS" 35 CPPFLAGS="$VALGRIND_CPPFLAGS $CPPFLAGS" 36 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 37 #include <valgrind/memcheck.h> 38 ]], [[ 39 #if defined(NVALGRIND) 40 # error "Valgrind does not support this platform." 41 #endif 42 ]])], [has_valgrind=yes]) 43 CPPFLAGS="$CPPFLAGS_TEMP" 44 fi 45 AC_MSG_RESULT($has_valgrind) 46 ]) 47 48 dnl SECP_TRY_APPEND_CFLAGS(flags, VAR) 49 dnl Append flags to VAR if CC accepts them. 50 AC_DEFUN([SECP_TRY_APPEND_CFLAGS], [ 51 AC_MSG_CHECKING([if ${CC} supports $1]) 52 SECP_TRY_APPEND_CFLAGS_saved_CFLAGS="$CFLAGS" 53 CFLAGS="$1 $CFLAGS" 54 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], [flag_works=yes], [flag_works=no]) 55 AC_MSG_RESULT($flag_works) 56 CFLAGS="$SECP_TRY_APPEND_CFLAGS_saved_CFLAGS" 57 if test x"$flag_works" = x"yes"; then 58 $2="$$2 $1" 59 fi 60 unset flag_works 61 AC_SUBST($2) 62 ]) 63 64 dnl SECP_SET_DEFAULT(VAR, default, default-dev-mode) 65 dnl Set VAR to default or default-dev-mode, depending on whether dev mode is enabled 66 AC_DEFUN([SECP_SET_DEFAULT], [ 67 if test "${enable_dev_mode+set}" != set; then 68 AC_MSG_ERROR([[Set enable_dev_mode before calling SECP_SET_DEFAULT]]) 69 fi 70 if test x"$enable_dev_mode" = x"yes"; then 71 $1="$3" 72 else 73 $1="$2" 74 fi 75 ])