configure.ac: Check that the chosen assembler will actually work.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 26 Jun 2016 11:17:45 +0000 (12:17 +0100)
If the system assembler doesn't like the GNUish directive syntax I'm
using, then the build will fail badly and be hard to fix.  Now, if the
assembler doesn't look like it's going to work, then declare the target
platform to be unknown so as to disable all of this fancy machinery.

configure.ac

index f5d004f..1802a8a 100644 (file)
@@ -47,6 +47,43 @@ AC_PROG_YACC
 AC_SUBST(AM_CFLAGS)
 
 dnl--------------------------------------------------------------------------
+dnl Define language support for assembler.
+dnl
+dnl This is stolen from https://gitlab.crest.iu.edu/jsfiroz/hpx/commit/
+dnl 84be4345db6eec3797a57b8e53483cb43f4733bf
+
+AC_LANG_DEFINE([CPPAS], [cppas], [CPPAS], [CCAS], [C],
+  [ac_ext=S ac_cpp='$CPP $CPPFLAGS'
+   ac_compile='$CCAS -c $CCASFLAGS $CPPFLAGS dnl
+       conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
+   ac_link='$CCAS -oconftest$ac_exeext $CCASFLAGS $CPPFLAGS $LDFLAGS dnl
+       conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'])
+
+AC_DEFUN([AC_LANG_PREPROC(CPPAS)], [AC_REQUIRE([AC_PROG_CPP])])
+AC_DEFUN([AC_LANG_COMPILER(CPPAS)], [AC_REQUIRE([AM_PROG_AS])])
+AC_DEFUN([AC_LANG_CONFTEST(CPPAS)],
+  [cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$1
+_ACEOF])
+
+AC_CACHE_CHECK(
+  [whether the assembler is likely to work], [mdw_cv_gnuish_as],
+  [AC_LANG_PUSH([CPPAS])
+   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+       .text
+       .L\$_test = 23
+.macro mymac
+       .L\$_test = .L\$_test + 1
+.endm
+       .globl  foo
+       .extern bar
+       mymac]])],
+     [mdw_cv_gnuish_as=yes], [mdw_cv_gnuish_as=no])
+   AC_LANG_POP([CPPAS])])
+AM_CONDITIONAL([GNUISH_AS], [test $mdw_cv_gnuish_as = yes])
+
+dnl--------------------------------------------------------------------------
 dnl Host-specific configuration.
 
 AC_MSG_CHECKING([CPU family and ABI])
@@ -71,13 +108,17 @@ m4_ifdef([catacomb_seen_abi/$3],
          [m4_undefine([catacomb_seen_abi/$3])])])
 
 dnl Identify the current host.
-case $host_cpu,$host_os in
-  m4_define([catacomb_CPU_CASE],
-    [$1) CPUFAM=$2 ABI=$3 ;;
+if test $mdw_cv_gnuish_as = no; then
+  CPUFAM=nil ABI=nil
+else
+  case $host_cpu,$host_os in
+    m4_define([catacomb_CPU_CASE],
+      [$1) CPUFAM=$2 ABI=$3 ;;
 ])
-  catacomb_CPU_FAMILIES([catacomb_CPU_CASE])
-  *) CPUFAM=nil ABI=nil ;;
-esac
+    catacomb_CPU_FAMILIES([catacomb_CPU_CASE])
+    *) CPUFAM=nil ABI=nil ;;
+  esac
+fi
 
 dnl Figure out the current CPU.
 catacomb_CPU_FAMILIES([catacomb_CLEAR_FLAGS])