VirtualBox

source: kBuild/trunk/src/grep/m4/asm-underscore.m4

Last change on this file was 3529, checked in by bird, 3 years ago

Imported grep 3.7 from grep-3.7.tar.gz (sha256: c22b0cf2d4f6bbe599c902387e8058990e1eee99aef333a203829e5fd3dbb342), applying minimal auto-props.

  • Property svn:eol-style set to LF
File size: 2.7 KB
Line 
1# asm-underscore.m4 serial 5
2dnl Copyright (C) 2010-2021 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 AC_REQUIRE([AC_PROG_EGREP])
18 dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because
19 dnl 1. It works only for GCC.
20 dnl 2. It is incorrectly defined on some platforms, in some GCC versions.
21 AC_REQUIRE([gl_C_ASM])
22 AC_CACHE_CHECK(
23 [whether C symbols are prefixed with underscore at the linker level],
24 [gl_cv_prog_as_underscore],
25 [cat > conftest.c <<EOF
26#ifdef __cplusplus
27extern "C" int foo (void);
28#endif
29int foo(void) { return 0; }
30EOF
31 # Look for the assembly language name in the .s file.
32 AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $gl_c_asm_opt conftest.c) >/dev/null 2>&1
33 if LC_ALL=C $EGREP '(^|[[^a-zA-Z0-9_]])_foo([[^a-zA-Z0-9_]]|$)' conftest.$gl_asmext >/dev/null; then
34 gl_cv_prog_as_underscore=yes
35 else
36 gl_cv_prog_as_underscore=no
37 fi
38 rm -f conftest*
39 ])
40 if test $gl_cv_prog_as_underscore = yes; then
41 USER_LABEL_PREFIX=_
42 else
43 USER_LABEL_PREFIX=
44 fi
45 AC_DEFINE_UNQUOTED([USER_LABEL_PREFIX], [$USER_LABEL_PREFIX],
46 [Define to the prefix of C symbols at the assembler and linker level,
47 either an underscore or empty.])
48 ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"'
49 AC_SUBST([ASM_SYMBOL_PREFIX])
50])
51
52# gl_C_ASM
53# Determines how to produce an assembly language file from C source code.
54# Sets the variables:
55# gl_asmext - the extension of assembly language output,
56# gl_c_asm_opt - the C compiler option that produces assembly language output.
57
58AC_DEFUN([gl_C_ASM],
59[
60 AC_EGREP_CPP([MicrosoftCompiler],
61 [
62#ifdef _MSC_VER
63MicrosoftCompiler
64#endif
65 ],
66 [dnl Microsoft's 'cl' and 'clang-cl' produce an .asm file, whereas 'clang'
67 dnl produces a .s file. Need to distinguish 'clang' and 'clang-cl'.
68 rm -f conftest*
69 echo 'int dummy;' > conftest.c
70 AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c) >/dev/null 2>&1
71 if test -f conftest.o; then
72 gl_asmext='s'
73 gl_c_asm_opt='-S'
74 else
75 gl_asmext='asm'
76 gl_c_asm_opt='-c -Fa'
77 fi
78 rm -f conftest*
79 ],
80 [gl_asmext='s'
81 gl_c_asm_opt='-S'
82 ])
83])
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette