Merge commit 'a39d4083cab589d7cd6a13e8a4b8db8875261d75'
[gnulib.git] / m4 / asm-underscore.m4
index 1736cc4..910144a 100644 (file)
@@ -1,5 +1,5 @@
-# asm-underscore.m4 serial 1
-dnl Copyright (C) 2010 Free Software Foundation, Inc.
+# asm-underscore.m4 serial 2
+dnl Copyright (C) 2010-2014 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -17,6 +17,7 @@ AC_DEFUN([gl_ASM_SYMBOL_PREFIX],
   dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because
   dnl 1. It works only for GCC.
   dnl 2. It is incorrectly defined on some platforms, in some GCC versions.
+  AC_REQUIRE([gl_C_ASM])
   AC_CACHE_CHECK(
     [whether C symbols are prefixed with underscore at the linker level],
     [gl_cv_prog_as_underscore],
@@ -27,8 +28,8 @@ extern "C" int foo (void);
 int foo(void) { return 0; }
 EOF
      # Look for the assembly language name in the .s file.
-     AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c) >/dev/null 2>&1
-     if grep _foo conftest.s >/dev/null ; then
+     AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $gl_c_asm_opt conftest.c) >/dev/null 2>&1
+     if grep _foo conftest.$gl_asmext >/dev/null ; then
        gl_cv_prog_as_underscore=yes
      else
        gl_cv_prog_as_underscore=no
@@ -46,3 +47,25 @@ EOF
   ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"'
   AC_SUBST([ASM_SYMBOL_PREFIX])
 ])
+
+# gl_C_ASM
+# Determines how to produce an assembly language file from C source code.
+# Sets the variables:
+#   gl_asmext - the extension of assembly language output,
+#   gl_c_asm_opt - the C compiler option that produces assembly language output.
+
+AC_DEFUN([gl_C_ASM],
+[
+  AC_EGREP_CPP([MicrosoftCompiler],
+    [
+#ifdef _MSC_VER
+MicrosoftCompiler
+#endif
+    ],
+    [gl_asmext='asm'
+     gl_c_asm_opt='-c -Fa'
+    ],
+    [gl_asmext='s'
+     gl_c_asm_opt='-S'
+    ])
+])