[AD] Autodetection of constructor attribute support |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
This patch adds autodetection of __attribute__((constructor)) support
into configure script. Constructor functions can be disabled with
--disable-constructor option of configure script.
diff -ruN old/allegro-3.9.30/acconfig.h new/allegro-3.9.30/acconfig.h
--- old/allegro-3.9.30/acconfig.h Mon Dec 20 06:39:26 1999
+++ new/allegro-3.9.30/acconfig.h Sun Jan 23 15:26:21 2000
@@ -67,3 +67,6 @@
/* Define to (void *)-1, if MAP_FAILED is not defined. */
#undef MAP_FAILED
+/* Define if constructor attribute is supported. */
+#undef ALLEGRO_USE_CONSTRUCTOR
+
diff -ruN old/allegro-3.9.30/aclocal.m4 new/allegro-3.9.30/aclocal.m4
--- old/allegro-3.9.30/aclocal.m4 Mon Dec 20 06:39:26 1999
+++ new/allegro-3.9.30/aclocal.m4 Sun Jan 23 15:30:01 2000
@@ -243,3 +243,30 @@
fi
])
+dnl
+dnl Test for constructor attribute support.
+dnl
+dnl Variables:
+dnl allegro_support_constructor=(yes|no)
+dnl
+AC_DEFUN(ALLEGRO_ACTEST_CONSTRUCTOR,
+[AC_MGS_CHECKING(for constructor attribute)
+AC_ARG_ENABLE(constructor,
+[ --enable-constructor[=x] enable the use of constructor attr [default=yes]],
+test "X$enableval" != "Xno" && allegro_enable_constructor=yes,
+allegro_enable_constructor=yes)
+
+if test -n "$allegro_enable_constructor"; then
+ AC_TRY_RUN([static int notsupported = 1;
+ void test_ctor (void) __attribute__ ((constructor));
+ void test_ctor (void) { notsupported = 0; }
+ int main (void) { return (notsupported); }],
+ allegro_support_constructor=yes,
+ allegro_support_constructor=no,
+ allegro_support_constructor=no)
+else
+ allegro_support_constructor=no
+fi
+
+AC_MSG_RESULT($allegro_support_constructor)])
+
diff -ruN old/allegro-3.9.30/configure.in new/allegro-3.9.30/configure.in
--- old/allegro-3.9.30/configure.in Mon Dec 20 06:39:26 1999
+++ new/allegro-3.9.30/configure.in Sun Jan 23 15:22:19 2000
@@ -131,6 +131,12 @@
AC_DEFINE(ALLEGRO_LITTLE_ENDIAN)
fi
+dnl Test for constructor attribute support.
+ALLEGRO_ACTEST_CONSTRUCTOR
+if test "X$allegro_support_constructor" = "Xyes"; then
+ AC_DEFINE(ALLEGRO_USE_CONSTRUCTOR)
+fi
+
dnl How to compile C and asm files.
if test -n "GCC"; then
if test "X$allegro_strict_warnings" = "Xyes"; then
diff -ruN old/allegro-3.9.30/include/allegro/alconfig.h new/allegro-3.9.30/include/allegro/alconfig.h
--- old/allegro-3.9.30/include/allegro/alconfig.h Mon Dec 20 06:39:28 1999
+++ new/allegro-3.9.30/include/allegro/alconfig.h Sun Jan 23 15:30:29 2000
@@ -55,8 +55,6 @@
#define AL_PRINTFUNC(type, name, args, a, b) AL_FUNC(type, name, args) __attribute__ ((format (printf, a, b)))
- #define CONSTRUCTOR_FUNCTION(func) func __attribute__ ((constructor))
-
#define INLINE inline
#ifndef ZERO_SIZE
@@ -68,6 +66,12 @@
#ifdef __i386__
#define ALLEGRO_I386
#endif
+#endif
+
+
+/* use constructor functions, if supported */
+#ifdef ALLEGRO_USE_CONSTRUCTOR
+ #define CONSTRUCTOR_FUNCTION(func) func __attribute__ ((constructor))
#endif
--
Michael Bukin