1# asm-underscore.m4 serial 2 2dnl Copyright (C) 2010-2012 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7dnl From Bruno Haible. Based on as-underscore.m4 in GNU clisp. 8 9# gl_ASM_SYMBOL_PREFIX 10# Tests for the prefix of C symbols at the assembly language level and the 11# linker level. This prefix is either an underscore or empty. Defines the 12# C macro USER_LABEL_PREFIX to this prefix, and sets ASM_SYMBOL_PREFIX to 13# a stringified variant of this prefix. 14 15AC_DEFUN([gl_ASM_SYMBOL_PREFIX], 16[ 17 dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because 18 dnl 1. It works only for GCC. 19 dnl 2. It is incorrectly defined on some platforms, in some GCC versions. 20 AC_REQUIRE([gl_C_ASM]) 21 AC_CACHE_CHECK( 22 [whether C symbols are prefixed with underscore at the linker level], 23 [gl_cv_prog_as_underscore], 24 [cat > conftest.c <<EOF 25#ifdef __cplusplus 26extern "C" int foo (void); 27#endif 28int foo(void) { return 0; } 29EOF 30 # Look for the assembly language name in the .s file. 31 AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $gl_c_asm_opt conftest.c) >/dev/null 2>&1 32 if grep _foo conftest.$gl_asmext >/dev/null ; then 33 gl_cv_prog_as_underscore=yes 34 else 35 gl_cv_prog_as_underscore=no 36 fi 37 rm -f conftest* 38 ]) 39 if test $gl_cv_prog_as_underscore = yes; then 40 USER_LABEL_PREFIX=_ 41 else 42 USER_LABEL_PREFIX= 43 fi 44 AC_DEFINE_UNQUOTED([USER_LABEL_PREFIX], [$USER_LABEL_PREFIX], 45 [Define to the prefix of C symbols at the assembler and linker level, 46 either an underscore or empty.]) 47 ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"' 48 AC_SUBST([ASM_SYMBOL_PREFIX]) 49]) 50 51# gl_C_ASM 52# Determines how to produce an assembly language file from C source code. 53# Sets the variables: 54# gl_asmext - the extension of assembly language output, 55# gl_c_asm_opt - the C compiler option that produces assembly language output. 56 57AC_DEFUN([gl_C_ASM], 58[ 59 AC_EGREP_CPP([MicrosoftCompiler], 60 [ 61#ifdef _MSC_VER 62MicrosoftCompiler 63#endif 64 ], 65 [gl_asmext='asm' 66 gl_c_asm_opt='-c -Fa' 67 ], 68 [gl_asmext='s' 69 gl_c_asm_opt='-S' 70 ]) 71]) 72