Blame m4/asm-underscore.m4

Packit 8f70b4
# asm-underscore.m4 serial 4
Packit 8f70b4
dnl Copyright (C) 2010-2018 Free Software Foundation, Inc.
Packit 8f70b4
dnl This file is free software; the Free Software Foundation
Packit 8f70b4
dnl gives unlimited permission to copy and/or distribute it,
Packit 8f70b4
dnl with or without modifications, as long as this notice is preserved.
Packit 8f70b4
Packit 8f70b4
dnl From Bruno Haible. Based on as-underscore.m4 in GNU clisp.
Packit 8f70b4
Packit 8f70b4
# gl_ASM_SYMBOL_PREFIX
Packit 8f70b4
# Tests for the prefix of C symbols at the assembly language level and the
Packit 8f70b4
# linker level. This prefix is either an underscore or empty. Defines the
Packit 8f70b4
# C macro USER_LABEL_PREFIX to this prefix, and sets ASM_SYMBOL_PREFIX to
Packit 8f70b4
# a stringified variant of this prefix.
Packit 8f70b4
Packit 8f70b4
AC_DEFUN([gl_ASM_SYMBOL_PREFIX],
Packit 8f70b4
[
Packit 8f70b4
  AC_REQUIRE([AC_PROG_EGREP])
Packit 8f70b4
  dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because
Packit 8f70b4
  dnl 1. It works only for GCC.
Packit 8f70b4
  dnl 2. It is incorrectly defined on some platforms, in some GCC versions.
Packit 8f70b4
  AC_REQUIRE([gl_C_ASM])
Packit 8f70b4
  AC_CACHE_CHECK(
Packit 8f70b4
    [whether C symbols are prefixed with underscore at the linker level],
Packit 8f70b4
    [gl_cv_prog_as_underscore],
Packit 8f70b4
    [cat > conftest.c <
Packit 8f70b4
#ifdef __cplusplus
Packit 8f70b4
extern "C" int foo (void);
Packit 8f70b4
#endif
Packit 8f70b4
int foo(void) { return 0; }
Packit 8f70b4
EOF
Packit 8f70b4
     # Look for the assembly language name in the .s file.
Packit 8f70b4
     AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $gl_c_asm_opt conftest.c) >/dev/null 2>&1
Packit 8f70b4
     if LC_ALL=C $EGREP '(^|[[^a-zA-Z0-9_]])_foo([[^a-zA-Z0-9_]]|$)' conftest.$gl_asmext >/dev/null; then
Packit 8f70b4
       gl_cv_prog_as_underscore=yes
Packit 8f70b4
     else
Packit 8f70b4
       gl_cv_prog_as_underscore=no
Packit 8f70b4
     fi
Packit 8f70b4
     rm -f conftest*
Packit 8f70b4
    ])
Packit 8f70b4
  if test $gl_cv_prog_as_underscore = yes; then
Packit 8f70b4
    USER_LABEL_PREFIX=_
Packit 8f70b4
  else
Packit 8f70b4
    USER_LABEL_PREFIX=
Packit 8f70b4
  fi
Packit 8f70b4
  AC_DEFINE_UNQUOTED([USER_LABEL_PREFIX], [$USER_LABEL_PREFIX],
Packit 8f70b4
    [Define to the prefix of C symbols at the assembler and linker level,
Packit 8f70b4
     either an underscore or empty.])
Packit 8f70b4
  ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"'
Packit 8f70b4
  AC_SUBST([ASM_SYMBOL_PREFIX])
Packit 8f70b4
])
Packit 8f70b4
Packit 8f70b4
# gl_C_ASM
Packit 8f70b4
# Determines how to produce an assembly language file from C source code.
Packit 8f70b4
# Sets the variables:
Packit 8f70b4
#   gl_asmext - the extension of assembly language output,
Packit 8f70b4
#   gl_c_asm_opt - the C compiler option that produces assembly language output.
Packit 8f70b4
Packit 8f70b4
AC_DEFUN([gl_C_ASM],
Packit 8f70b4
[
Packit 8f70b4
  AC_EGREP_CPP([MicrosoftCompiler],
Packit 8f70b4
    [
Packit 8f70b4
#ifdef _MSC_VER
Packit 8f70b4
MicrosoftCompiler
Packit 8f70b4
#endif
Packit 8f70b4
    ],
Packit 8f70b4
    [gl_asmext='asm'
Packit 8f70b4
     gl_c_asm_opt='-c -Fa'
Packit 8f70b4
    ],
Packit 8f70b4
    [gl_asmext='s'
Packit 8f70b4
     gl_c_asm_opt='-S'
Packit 8f70b4
    ])
Packit 8f70b4
])