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.
8
dnl From Bruno Haible, Marcus Daniels.
12
AC_DEFUN([CL_GLOBAL_CONSTRUCTORS],
13
[AC_REQUIRE([CL_AS_UNDERSCORE])dnl
14
if test -n "$GCC"; then
15
AC_CACHE_CHECK(for the global constructors function prefix,
16
cl_cv_cplusplus_ctorprefix, [
17
cat > conftest.cc << EOF
18
struct foo { foo (); };
21
# look for the assembly language name in the .s file
22
AC_TRY_COMMAND(${CXX-g++} $CXXFLAGS -S conftest.cc) >/dev/null 2>&1
23
if grep '_GLOBAL_\$I\$foobar' conftest.s >/dev/null ; then
24
cl_cv_cplusplus_ctorprefix='_GLOBAL_$I$'
26
if grep '_GLOBAL_\.I\.foobar' conftest.s >/dev/null ; then
27
cl_cv_cplusplus_ctorprefix='_GLOBAL_.I.'
29
if grep '_GLOBAL__I_foobar' conftest.s >/dev/null ; then
30
cl_cv_cplusplus_ctorprefix='_GLOBAL__I_'
32
cl_cv_cplusplus_ctorprefix=unknown
38
if test "$cl_cv_cplusplus_ctorprefix" '!=' unknown; then
39
ac_value='"'"$cl_cv_cplusplus_ctorprefix"'"'
40
AC_DEFINE_UNQUOTED(CL_GLOBAL_CONSTRUCTOR_PREFIX,$ac_value)
41
AC_CACHE_CHECK(for the global destructors function prefix,
42
cl_cv_cplusplus_dtorprefix, [
43
cat > conftest.cc << EOF
44
struct foo { foo (); ~ foo (); };
47
# look for the assembly language name in the .s file
48
AC_TRY_COMMAND(${CXX-g++} $CXXFLAGS -S conftest.cc) >/dev/null 2>&1
49
if grep '_GLOBAL_\$D\$foobar' conftest.s >/dev/null ; then
50
cl_cv_cplusplus_dtorprefix='_GLOBAL_$D$'
52
if grep '_GLOBAL_\.D\.foobar' conftest.s >/dev/null ; then
53
cl_cv_cplusplus_dtorprefix='_GLOBAL_.D.'
55
if grep '_GLOBAL__D_foobar' conftest.s >/dev/null ; then
56
cl_cv_cplusplus_dtorprefix='_GLOBAL__D_'
58
cl_cv_cplusplus_dtorprefix=none
64
if test "$cl_cv_cplusplus_dtorprefix" '!=' none; then
65
ac_value='"'"$cl_cv_cplusplus_ctorprefix"'"'
66
AC_DEFINE_UNQUOTED(CL_GLOBAL_DESTRUCTOR_PREFIX,$ac_value)
68
dnl Check whether the global constructors/destructors functions are file-scope
69
dnl only by default. This is the case in egcs-1.1.2 or newer.
70
AC_CACHE_CHECK(whether the global constructors function need to be exported,
71
cl_cv_cplusplus_ctorexport, [
72
cat > conftest1.cc << EOF
73
struct foo { foo (); };
76
cat > conftest2.cc << EOF
79
#define ASM_UNDERSCORE_PREFIX "_"
81
#define ASM_UNDERSCORE_PREFIX ""
83
struct foo { foo (); };
85
extern "C" void ctor (void) __asm__ (ASM_UNDERSCORE_PREFIX CL_GLOBAL_CONSTRUCTOR_PREFIX "foobar");
86
int main() { ctor(); return 0; }
88
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
89
cl_cv_cplusplus_ctorexport=no
91
cl_cv_cplusplus_ctorexport=yes
95
if test "$cl_cv_cplusplus_ctorexport" = yes; then
96
AC_DEFINE(CL_NEED_GLOBALIZE_CTORDTOR)