asm-underscore.m4 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # asm-underscore.m4 serial 1
  2. dnl Copyright (C) 2010 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. dnl From Bruno Haible. Based on as-underscore.m4 in GNU clisp.
  7. # gl_ASM_SYMBOL_PREFIX
  8. # Tests for the prefix of C symbols at the assembly language level and the
  9. # linker level. This prefix is either an underscore or empty. Defines the
  10. # C macro USER_LABEL_PREFIX to this prefix, and sets ASM_SYMBOL_PREFIX to
  11. # a stringified variant of this prefix.
  12. AC_DEFUN([gl_ASM_SYMBOL_PREFIX],
  13. [
  14. dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because
  15. dnl 1. It works only for GCC.
  16. dnl 2. It is incorrectly defined on some platforms, in some GCC versions.
  17. AC_CACHE_CHECK(
  18. [whether C symbols are prefixed with underscore at the linker level],
  19. [gl_cv_prog_as_underscore],
  20. [cat > conftest.c <<EOF
  21. #ifdef __cplusplus
  22. extern "C" int foo (void);
  23. #endif
  24. int foo(void) { return 0; }
  25. EOF
  26. # Look for the assembly language name in the .s file.
  27. AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c) >/dev/null 2>&1
  28. if grep _foo conftest.s >/dev/null ; then
  29. gl_cv_prog_as_underscore=yes
  30. else
  31. gl_cv_prog_as_underscore=no
  32. fi
  33. rm -f conftest*
  34. ])
  35. if test $gl_cv_prog_as_underscore = yes; then
  36. USER_LABEL_PREFIX=_
  37. else
  38. USER_LABEL_PREFIX=
  39. fi
  40. AC_DEFINE_UNQUOTED([USER_LABEL_PREFIX], [$USER_LABEL_PREFIX],
  41. [Define to the prefix of C symbols at the assembler and linker level,
  42. either an underscore or empty.])
  43. ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"'
  44. AC_SUBST([ASM_SYMBOL_PREFIX])
  45. ])