You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.2 KiB

  1. dnl Copyright (C) 1993-2002 Free Software Foundation, Inc.
  2. dnl This file is free software, distributed under the terms of the GNU
  3. dnl General Public License. As a special exception to the GNU General
  4. dnl Public License, this file may be distributed as part of a program
  5. dnl that contains a configuration script generated by Autoconf, under
  6. dnl the same distribution terms as the rest of that program.
  7. dnl From Bruno Haible, Marcus Daniels.
  8. AC_PREREQ(2.13)
  9. AC_DEFUN([CL_GLOBAL_CONSTRUCTORS],
  10. [AC_REQUIRE([CL_AS_UNDERSCORE])dnl
  11. if test -n "$GCC"; then
  12. AC_CACHE_CHECK(for the global constructors function prefix,
  13. cl_cv_cplusplus_ctorprefix, [
  14. cat > conftest.cc << EOF
  15. struct foo { foo (); };
  16. foo foobar;
  17. EOF
  18. # look for the assembly language name in the .s file
  19. AC_TRY_COMMAND(${CXX-g++} $CXXFLAGS -S conftest.cc) >/dev/null 2>&1
  20. if grep '_GLOBAL_\$I\$foobar' conftest.s >/dev/null ; then
  21. cl_cv_cplusplus_ctorprefix='_GLOBAL_$I$'
  22. else
  23. if grep '_GLOBAL_\.I\.foobar' conftest.s >/dev/null ; then
  24. cl_cv_cplusplus_ctorprefix='_GLOBAL_.I.'
  25. else
  26. if grep '_GLOBAL__I_foobar' conftest.s >/dev/null ; then
  27. cl_cv_cplusplus_ctorprefix='_GLOBAL__I_'
  28. else
  29. cl_cv_cplusplus_ctorprefix=unknown
  30. fi
  31. fi
  32. fi
  33. rm -f conftest*
  34. ])
  35. if test "$cl_cv_cplusplus_ctorprefix" '!=' unknown; then
  36. ac_value='"'"$cl_cv_cplusplus_ctorprefix"'"'
  37. AC_DEFINE_UNQUOTED(CL_GLOBAL_CONSTRUCTOR_PREFIX,$ac_value)
  38. AC_CACHE_CHECK(for the global destructors function prefix,
  39. cl_cv_cplusplus_dtorprefix, [
  40. cat > conftest.cc << EOF
  41. struct foo { foo (); ~ foo (); };
  42. foo foobar;
  43. EOF
  44. # look for the assembly language name in the .s file
  45. AC_TRY_COMMAND(${CXX-g++} $CXXFLAGS -S conftest.cc) >/dev/null 2>&1
  46. if grep '_GLOBAL_\$D\$foobar' conftest.s >/dev/null ; then
  47. cl_cv_cplusplus_dtorprefix='_GLOBAL_$D$'
  48. else
  49. if grep '_GLOBAL_\.D\.foobar' conftest.s >/dev/null ; then
  50. cl_cv_cplusplus_dtorprefix='_GLOBAL_.D.'
  51. else
  52. if grep '_GLOBAL__D_foobar' conftest.s >/dev/null ; then
  53. cl_cv_cplusplus_dtorprefix='_GLOBAL__D_'
  54. else
  55. cl_cv_cplusplus_dtorprefix=none
  56. fi
  57. fi
  58. fi
  59. rm -f conftest*
  60. ])
  61. if test "$cl_cv_cplusplus_dtorprefix" '!=' none; then
  62. ac_value='"'"$cl_cv_cplusplus_ctorprefix"'"'
  63. AC_DEFINE_UNQUOTED(CL_GLOBAL_DESTRUCTOR_PREFIX,$ac_value)
  64. fi
  65. dnl Check whether the global constructors/destructors functions are file-scope
  66. dnl only by default. This is the case in egcs-1.1.2 or newer.
  67. AC_CACHE_CHECK(whether the global constructors function need to be exported,
  68. cl_cv_cplusplus_ctorexport, [
  69. cat > conftest1.cc << EOF
  70. struct foo { foo (); };
  71. foo foobar;
  72. EOF
  73. cat > conftest2.cc << EOF
  74. #include "confdefs.h"
  75. #ifdef ASM_UNDERSCORE
  76. #define ASM_UNDERSCORE_PREFIX "_"
  77. #else
  78. #define ASM_UNDERSCORE_PREFIX ""
  79. #endif
  80. struct foo { foo (); };
  81. foo::foo () {}
  82. extern "C" void ctor (void) __asm__ (ASM_UNDERSCORE_PREFIX CL_GLOBAL_CONSTRUCTOR_PREFIX "foobar");
  83. int main() { ctor(); return 0; }
  84. EOF
  85. if AC_TRY_COMMAND(${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest1.cc conftest2.cc $LIBS 1>&5) >/dev/null 2>&1 && test -s conftest${ac_exeext}; then
  86. cl_cv_cplusplus_ctorexport=no
  87. else
  88. cl_cv_cplusplus_ctorexport=yes
  89. fi
  90. rm -f conftest*
  91. ])
  92. if test "$cl_cv_cplusplus_ctorexport" = yes; then
  93. AC_DEFINE(CL_NEED_GLOBALIZE_CTORDTOR)
  94. fi
  95. fi
  96. fi
  97. ])