From: Mark Wooding Date: Wed, 18 May 2016 09:29:03 +0000 (+0100) Subject: configure.ac: Improve the host CPU family detection. X-Git-Tag: 2.2.3~1^2~22^2~8 X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/commitdiff_plain/ff1f7e22126144d898d5ef5e75aaaa1aeb697c4c configure.ac: Improve the host CPU family detection. In particular, also collect the ABI. --- diff --git a/configure.ac b/configure.ac index 516e3a05..b76c5619 100644 --- a/configure.ac +++ b/configure.ac @@ -49,22 +49,81 @@ AC_SUBST(AM_CFLAGS) dnl-------------------------------------------------------------------------- dnl Host-specific configuration. +AC_MSG_CHECKING([CPU family and ABI]) + +dnl The table of CPU families and ABIs which we might support. Support is +dnl not uniform: each dispatched function might or might not have an +dnl implementation for any particular CPU/ABI combination. AC_DEFUN([catacomb_CPU_FAMILIES], - [$1([i[[3-6]]86], [X86])]) + [$1([i[[3-6]]86,*], [x86], [sysv])]) + +dnl A utility to clear the `seen' flags, used so as to process each CPU or +dnl ABI once. +m4_define([catacomb_CLEAR_FLAGS], +[m4_ifdef([catacomb_seen_cpu/$2], + [m4_undefine([catacomb_seen_cpu/$2])])dnl +m4_ifdef([catacomb_seen_abi/$3], + [m4_undefine([catacomb_seen_abi/$3])])]) -case $host_cpu in +dnl Identify the current host. +case $host_cpu,$host_os in m4_define([catacomb_CPU_CASE], - [$1) - AC_DEFINE([CPUFAM_$2], [1], [Define if host CPU family is $2.]) - cpufam=$2 - ;; + [$1) CPUFAM=$2 ABI=$3 ;; ]) catacomb_CPU_FAMILIES([catacomb_CPU_CASE]) - *) cpufam=nil ;; + *) CPUFAM=nil ABI=nil ;; +esac + +dnl Figure out the current CPU. +catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS]) +case $CPUFAM in + m4_define([catacomb_DEFINE_CPU], + [m4_ifdef([catacomb_seen_cpu/$2], [], + [$2) + AC_DEFINE([CPUFAM_]m4_translit([$2], [a-z], [A-Z]), [1], + [Define if host CPU family is \`$2\'.]) + ;;m4_define([catacomb_seen_cpu/$2], [t])])]) + catacomb_CPU_FAMILIES([catacomb_DEFINE_CPU]) + nil) ;; + *) AC_MSG_ERROR([BUG: unexpected cpufam \`$CPUFAM']) ;; +esac +AC_SUBST([CPUFAM]) + +dnl Figure out the current ABI. +catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS]) +case $ABI in + m4_define([catacomb_DEFINE_ABI], + [m4_ifdef([catacomb_seen_abi/$3], [], + [$3) + AC_DEFINE([ABI_]m4_translit([$3], [a-z], [A-Z]), [1], + [Define if host ABI variant is \`$3\'.]) + ;;m4_define([catacomb_seen_abi/$3], [t])])]) + catacomb_CPU_FAMILIES([catacomb_DEFINE_ABI]) + nil) ;; + *) AC_MSG_ERROR([BUG: unexpected ABI \`$ABI']) ;; +esac +AC_SUBST([ABI]) + +dnl Establish Automake conditions for things. +catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS]) +m4_define([catacomb_COND_CPU], +[m4_define([_CPU], m4_translit([$2], [a-z], [A-Z])) +m4_define([_ABI], m4_translit([$3], [a-z], [A-Z])) +AM_CONDITIONAL([CPUABI_]_CPU[_]_ABI, [test x$CPUFAM/$ABI = x$2/$3]) +m4_ifdef([catacomb_seen_cpu/$2], [], +[AM_CONDITIONAL([CPUFAM_]_CPU, [test x$CPUFAM = x$2])dnl +m4_define([catacomb_seen_cpu/$2], [t])]) +m4_ifdef([catacomb_seen_abi/$3], [], +[AM_CONDITIONAL([ABI_]_ABI, [test x$ABI = x$3])dnl +m4_define([catacomb_seen_abi/$3], [t])])]) +catacomb_CPU_FAMILIES([catacomb_COND_CPU]) +AM_CONDITIONAL([KNOWN_CPUFAM], [test x$CPUFAM != xnil]) + +dnl Report on what we found. +case $CPUFAM in + nil) AC_MSG_RESULT([not supported]) ;; + *) AC_MSG_RESULT([$CPUFAM/$ABI]) ;; esac -m4_define([catacomb_CPU_DEFS], - [AM_CONDITIONAL([CPUFAM_$2], [test x$cpufam = x$2])]) -catacomb_CPU_FAMILIES([catacomb_CPU_DEFS]) dnl-------------------------------------------------------------------------- dnl C programming environment.