changeset 15609:eb8d35d87eb5

asm-underscore.m4: Support for MSVC. * m4/asm-underscore.m4 (gl_C_ASM): New macro. (gl_ASM_SYMBOL_PREFIX): Require it. Use its results.
author Bruno Haible <bruno@clisp.org>
date Mon, 12 Sep 2011 01:41:44 +0200
parents c20dc5d73f44
children de2ecfd7fc4a
files ChangeLog m4/asm-underscore.m4
diffstat 2 files changed, 32 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-09-11  Bruno Haible  <bruno@clisp.org>
+
+	asm-underscore.m4: Support for MSVC.
+	* m4/asm-underscore.m4 (gl_C_ASM): New macro.
+	(gl_ASM_SYMBOL_PREFIX): Require it. Use its results.
+
 2011-09-11  Reuben Thomas  <rrt@sc3d.org>
 
 	Doc about crypt functions.
--- a/m4/asm-underscore.m4
+++ b/m4/asm-underscore.m4
@@ -1,4 +1,4 @@
-# asm-underscore.m4 serial 1
+# asm-underscore.m4 serial 2
 dnl Copyright (C) 2010-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,6 +17,7 @@
   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 @@
 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 @@
   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'
+    ])
+])