progs/perftest.c: Use from Glibc syscall numbers.
[catacomb] / configure.ac
index 8c32c92..88d2ec5 100644 (file)
@@ -37,8 +37,15 @@ mdw_SILENT_RULES
 
 AC_PROG_CC
 AX_CFLAGS_WARN_ALL
-AM_PROG_LIBTOOL
+LT_INIT
 mdw_LIBTOOL_VERSION_INFO
+case $host_os in
+  cygwin* | mingw* | pw32* | os2* | darwin* | cegcc*)
+    TEST_LDFLAGS=-no-fast-install ;;
+  *)
+    TEST_LDFLAGS=-no-install ;;
+esac
+AC_SUBST([TEST_LDFLAGS])
 
 AM_PROG_AS
 
@@ -78,8 +85,8 @@ AC_DEFUN([catacomb_CPU_FAMILIES],
    $1([i[[3-6]]86,*], [x86], [sysv])
    $1([x86_64,cygwin], [amd64], [win])
    $1([x86_64,*], [amd64], [sysv])
-   $1([arm,*-gnueabi | arm,*-gnueabihf | dnl
-       armv*,*-gnueabi | armv*,*-gnueabihf], [armel], [gnueabi])])
+   $1([arm,* | armv*,*], [armel], [std])
+   $1([aarch64,*], [arm64], [std])])
 
 dnl A utility to clear the `seen' flags, used so as to process each CPU or
 dnl ABI once.
@@ -98,8 +105,8 @@ case $host_cpu,$host_os in
   *) CPUFAM=nil ABI=nil ;;
 esac
 
-dnl Now check the assembler.  We may have target-specific requirements here,
-dnl so we couldn't do this any earlier.
+dnl Now check the assembler.  We have target-specific requirements here, so
+dnl we couldn't do this any earlier.
 AC_CACHE_CHECK(
   [whether the assembler is likely to work], [mdw_cv_gnuish_as],
   [AC_LANG_PUSH([CPPAS])
@@ -113,6 +120,22 @@ AC_CACHE_CHECK(
        .extern bar
        mymac]])],
      [mdw_cv_gnuish_as=yes], [mdw_cv_gnuish_as=no])
+   case $CPUFAM in
+     x86 | amd64)
+       AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+       .text
+       .arch pentium4
+       .intel_syntax noprefix
+       .globl  foo
+foo:
+       adc     dword ptr var, 0
+       ret
+       .data
+var:   .long   1
+       ]])],
+        [:], [mdw_cv_gnuish_as=no])
+       ;;
+   esac
    AC_LANG_POP([CPPAS])])
 AM_CONDITIONAL([GNUISH_AS], [test $mdw_cv_gnuish_as = yes])
 if test $mdw_cv_gnuish_as = no; then CPUFAM=nil ABI=nil; fi
@@ -129,7 +152,7 @@ m4_define([catacomb_DEFINE_CPU_OR_ABI],
        ;;m4_define([catacomb_seen_$3/$$2], [t])])])
   catacomb_CPU_FAMILIES([_def])
   nil) ;;
-  *) AC_MSG_ERROR([BUG: unexpected $1 \`$1']) ;;
+  *) AC_MSG_ERROR([BUG: unexpected $1 `$$1']) ;;
 esac])
 
 dnl Now that's out the way, we can explain what we're doing.
@@ -138,9 +161,9 @@ AC_MSG_CHECKING([CPU family and ABI])
 dnl Figure out the target CPU family and ABI.
 catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS])
 catacomb_DEFINE_CPU_OR_ABI([CPUFAM], [2], [cpu],
-  [CPUFAM_], [Define if target CPU is \`$][2\'.])
+  [CPUFAM_], [Define if target CPU is `$][2'.])
 catacomb_DEFINE_CPU_OR_ABI([ABI], [3], [abi],
-  [ABI_], [Define if target ABI is \`$][3\'.])
+  [ABI_], [Define if target ABI is `$][3'.])
 
 dnl Establish Automake conditions for things.
 catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS])
@@ -163,6 +186,26 @@ case $CPUFAM in
   *) AC_MSG_RESULT([$CPUFAM/$ABI]) ;;
 esac
 
+dnl Consider enabling support for assembler-level debugging toys.
+AC_ARG_ENABLE([asm-debug],
+  AS_HELP_STRING([--enable-asm-debug],
+    [enable assembler debugging features]),
+  [mdw_asm_debug=$enableval], [mdw_asm_debug=no])
+case $CPUFAM in nil) mdw_asm_debug=no ;; esac
+case $mdw_asm_debug in
+  no) ;;
+  *) AC_DEFINE([ENABLE_ASM_DEBUG], [1],
+       [Define to enable assembler-level debugging.]) ;;
+esac
+AM_CONDITIONAL([ASM_DEBUG], [test x$mdw_asm_debug != xno])
+
+dnl Check for leading underscores on C symbols.
+LT_SYS_SYMBOL_USCORE
+case $sys_symbol_underscore in
+  yes) AC_DEFINE([SYM_USCORE], [1],
+        [Define if C symbols are prefixed with an underscore.]) ;;
+esac
+
 dnl--------------------------------------------------------------------------
 dnl CPU-specific assembler features.
 
@@ -219,15 +262,38 @@ AC_CHECK_TYPE([socklen_t], [],
   [AC_DEFINE([socklen_t], [int],
      [Define to `int' if <sys/socket.h> does not define])],
   [AC_INCLUDES_DEFAULT
-#include <sys/socket.h>
+@%:@include <sys/socket.h>
 ])
 
 dnl The maths library.
-mdw_ORIG_LIBS=$LIBS LIBS=
+mdw_ORIG_LIBS=$LIBS LIBS=$CATACOMB_LIBS
 AC_SEARCH_LIBS([log], [m])
 AC_SEARCH_LIBS([sqrt], [m])
-AC_SUBST([MATHLIBS], [$LIBS])
-LIBS=$mdw_ORIG_LIBS
+CATACOMB_LIBS=$LIBS LIBS=$mdw_ORIG_LIBS
+
+dnl Logging is weird under Termux.  Unfortunately, it involves macros, so we
+dnl have to do this the hard way.
+AC_CACHE_CHECK(
+  [library needed for syslog], [mdw_cv_syslog_lib],
+  [mdw_ORIG_LIBS=$LIBS LIBS=
+   for i in 0 1; do
+     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+        [[@%:@include <syslog.h>]],
+        [[openlog("test", LOG_PID, LOG_DAEMON);
+          syslog(LOG_ERR, "this is a test");]])],
+       [ok=t], [ok=nil])
+     case $i,$ok in
+       *,t) mdw_cv_syslog_lib=${LIBS:-none}; break ;;
+       0,nil) LIBS="-llog" ;;
+       1,nil) AC_MSG_ERROR("failed to link test program") ;;
+     esac
+   done
+   LIBS=$mdw_ORIG_LIBS])
+case $mdw_cv_syslog_lib in
+  none) LOGLIBS= ;;
+  *) LOGLIBS=$mdw_cv_syslog_lib ;;
+esac
+AC_SUBST([LOGLIBS])
 
 dnl Find out whether very long integer types are available.
 AC_CHECK_HEADERS([stdint.h])
@@ -240,6 +306,9 @@ AC_CHECK_HEADERS([sys/auxv.h])
 AC_CHECK_HEADERS([linux/auxvec.h])
 AC_CHECK_FUNCS([getauxval])
 
+dnl Some equipment for measuring CPU performance.
+AC_CHECK_HEADERS([linux/perf_event.h])
+
 dnl Find the bit lengths of the obvious integer types.  This will be useful
 dnl when deciding on a representation for multiprecision integers.
 type_bits="" type_bits_sep=""
@@ -264,7 +333,7 @@ limits="" limits_sep=""
 AC_DEFUN([catacomb_COMPILE_TIME_CONSTANT],
   [case "$2" in
      =*)
-       $1="$2"; $1=${$1#=}
+       $1="$2"; $1=${$1@%:@=}
        ;;
      *)
        AC_CACHE_CHECK([compile-time value of $2], [mdw_cv_constant_$3],
@@ -274,11 +343,11 @@ AC_DEFUN([catacomb_COMPILE_TIME_CONSTANT],
    esac])
 AC_DEFUN([catacomb_LIMIT],
 [catacomb_COMPILE_TIME_CONSTANT([lo], [$2], [$1_min],
-[#include <limits.h>
-#include <stddef.h>])
+[@%:@include <limits.h>
+@%:@include <stddef.h>])
  catacomb_COMPILE_TIME_CONSTANT([hi], [$3], [$1_max],
-[#include <limits.h>
-#include <stddef.h>])
+[@%:@include <limits.h>
+@%:@include <stddef.h>])
  limits="$limits$limits_sep('$1', $lo, $hi)" limits_sep=", "])
 catacomb_LIMIT([SCHAR],                [SCHAR_MIN],    [SCHAR_MAX])
 catacomb_LIMIT([CHAR],         [CHAR_MIN],     [CHAR_MAX])
@@ -302,9 +371,9 @@ AC_SUBST([limits])
 dnl Figure out other aspects of the implementation's arithmetic.
 AC_CACHE_CHECK([whether negative numbers use two's complement],
        [catacomb_cv_neg_twoc],
-[AC_TRY_COMPILE(
-[#include <limits.h>],
-[int check[2*!!(-INT_MAX == INT_MIN + 1) - 1];],
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[@%:@include <limits.h>]],
+[[int check[2*!!(-INT_MAX == INT_MIN + 1) - 1];]])],
 [catacomb_cv_neg_twoc=yes],
 [catacomb_cv_neg_twoc=no])])
 case $catacomb_cv_neg_twoc in
@@ -322,18 +391,18 @@ AC_SEARCH_LIBS([clock_gettime], [rt])
 CATACOMB_LIBS=$LIBS LIBS=$mdw_ORIG_LIBS
 if test "$ac_cv_search_clock_gettime" != no; then
   AC_DEFINE([HAVE_CLOCK_GETTIME], [1],
-           [Define if you have the \`clock_gettime' function.])
+           [Define if you have the `clock_gettime' function.])
 fi
 AC_CHECK_FUNCS([getentropy])
 AC_CACHE_CHECK([whether the freewheel noise generator will work],
        [catacomb_cv_freewheel],
-[AC_TRY_LINK(
-[#include <setjmp.h>
-#include <sys/time.h>],
-[struct itimerval itv = { { 0, 0 }, { 0, 5000 } };
+[AC_LINK_IFELSE([AC_LANG_PROGRAM(
+[[@%:@include <setjmp.h>
+@%:@include <sys/time.h>]],
+[[struct itimerval itv = { { 0, 0 }, { 0, 5000 } };
 jmp_buf j;
 setitimer(ITIMER_REAL, &itv, 0);
-sigsetjmp(j, 1);],
+sigsetjmp(j, 1);]])],
 [catacomb_cv_freewheel=yes],
 [catacomb_cv_freewheel=no])])
 case $catacomb_cv_freewheel in
@@ -352,11 +421,17 @@ LIBS=$mdw_ORIG_LIBS
 dnl Memory locking support.
 AC_CHECK_FUNCS([mlock])
 
+dnl See if we can find Valgrind's header files.
+AC_CHECK_HEADER([valgrind/memcheck.h],
+  AC_DEFINE([HAVE_VALGRIND_H], [1],
+           [Define if the Valgrind header files are available.])
+  [])
+
 dnl Set the master libraries we need.
 AC_SUBST([CATACOMB_LIBS])
 
 dnl Necessary support libraries.
-PKG_CHECK_MODULES([mLib], [mLib >= 2.2.2.1])
+PKG_CHECK_MODULES([mLib], [mLib >= 2.4.1])
 AM_CFLAGS="$AM_CFLAGS $mLib_CFLAGS"
 
 dnl--------------------------------------------------------------------------
@@ -384,7 +459,7 @@ AC_ARG_ENABLE([mpw],
 dnl--------------------------------------------------------------------------
 dnl Produce output.
 
-AC_CONFIG_HEADER([config/config.h])
+AC_CONFIG_HEADERS([config/config.h])
 
 AC_CONFIG_FILES(
   [Makefile]