Blame m4/asm-underscore.m4

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