summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-10-31 22:19:03 -0500
committerDan McGee <dan@archlinux.org>2007-11-04 10:42:07 -0600
commitc26fe63ee5d84492bcfb36664af8a90619e6ded5 (patch)
tree591814b7bf5a0cc483f56968797e0c64556a81e7
parent8feccaed7861010caefa4f7b9824a612a78e3043 (diff)
Add some more autoconf macros to filter our CFLAGS usage
Hopefully these new autoconf macros, with a little magic, will allow us to compile with any compiler and still choose the options we have available to us. Tested locally with gcc 4.2.2 and gcc 3.4.6; the latter doesn't support two of the items we previously had hardcoded in our CFLAGS. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--acinclude.m441
-rw-r--r--configure.ac5
-rw-r--r--lib/libalpm/Makefile.am9
3 files changed, 54 insertions, 1 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 566953df..b9a77cd4 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -6623,3 +6623,44 @@ AC_DEFUN([GCC_STACK_PROTECT_CC],[
fi
fi
])
+
+dnl GCC_VISIBILITY_CC
+dnl checks -fvisibility=internal with the C compiler, if it exists then
+dnl defines ENABLE_VISIBILITY_CC in both configure script and Makefiles
+AC_DEFUN([GCC_VISIBILITY_CC],[
+ AC_LANG_ASSERT(C)
+ if test "X$CC" != "X"; then
+ AC_CACHE_CHECK([whether ${CC} accepts -fvisibility=internal],
+ visibility_cv_cc,
+ [visibility_old_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS -fvisibility=internal"
+ AC_TRY_COMPILE(,, visibility_cv_cc=yes, visibility_cv_cc=no)
+ CFLAGS="$visibility_old_cflags"
+ ])
+ if test $visibility_cv_cc = yes; then
+ AC_DEFINE([ENABLE_VISIBILITY_CC], 1, [Define if symbol visibility C support is enabled.])
+ fi
+ AM_CONDITIONAL([ENABLE_VISIBILITY_CC], test "x$visibility_cv_cc" = "xyes")
+ fi
+])
+
+dnl GCC_GNU89_INLINE_CC
+dnl checks -fgnu89-inline with the C compiler, if it exists then defines
+dnl ENABLE_GNU89_INLINE_CC in both configure script and Makefiles
+AC_DEFUN([GCC_GNU89_INLINE_CC],[
+ AC_LANG_ASSERT(C)
+ if test "X$CC" != "X"; then
+ AC_CACHE_CHECK([for -fgnu89-inline],
+ gnu89_inline_cv_cc,
+ [ gnu89_inline_old_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS -fgnu89-inline"
+ AC_TRY_COMPILE(,, gnu89_inline_cv_cc=yes, gnu89_inline_cv_cc=no)
+ CFLAGS="$gnu89_inline_old_cflags"
+ ])
+ if test $gnu89_inline_cv_cc = yes; then
+ AC_DEFINE([ENABLE_GNU89_INLINE_CC], 1, [Define if gnu89 inlining semantics should be used.])
+ fi
+ AM_CONDITIONAL([ENABLE_GNU89_INLINE_CC], test "x$gnu89_inline_cv_cc" = "xyes")
+ fi
+])
+
diff --git a/configure.ac b/configure.ac
index d93cea84..823d4691 100644
--- a/configure.ac
+++ b/configure.ac
@@ -162,6 +162,11 @@ AC_CHECK_FUNCS([realpath regcomp strcasecmp strdup strerror strnlen \
# Enable large file support if available
AC_SYS_LARGEFILE
+# Check if we can use symbol visibility support in GCC
+GCC_VISIBILITY_CC
+# Check if we have -fgnu89-inline flag
+GCC_GNU89_INLINE_CC
+
# Host-dependant flags
case "${host}" in
*-*-cygwin*)
diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am
index e42a0bd0..b84dcc33 100644
--- a/lib/libalpm/Makefile.am
+++ b/lib/libalpm/Makefile.am
@@ -7,7 +7,14 @@ include_HEADERS = alpm_list.h alpm.h
DEFS = -DLOCALEDIR=\"@localedir@\" @DEFS@
-AM_CFLAGS = -fvisibility=internal -pedantic -D_GNU_SOURCE -fgnu89-inline
+AM_CFLAGS = -pedantic -D_GNU_SOURCE
+
+if ENABLE_VISIBILITY_CC
+AM_CFLAGS += -fvisibility=internal
+endif
+if ENABLE_GNU89_INLINE_CC
+AM_CFLAGS += -fgnu89-inline
+endif
libalpm_la_SOURCES = \
add.h add.c \