From fffaa1865539409d41ee1427cfce20a2cfe68123 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Mon, 20 Aug 2012 15:10:49 -0700 Subject: build: Check for and add visibility compiler flags --- Makefile.am | 4 ++-- configure.ac | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 332b96c..1acfbe6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,8 +30,8 @@ AM_CPPFLAGS = -DLIBRARYBUILD \ -I$(top_srcdir)/src/libnurbs/internals \ -I$(top_srcdir)/src/libnurbs/interface \ -I$(top_srcdir)/src/libnurbs/nurbtess -AM_CFLAGS = $(GL_CFLAGS) $(OSMESA_CFLAGS) $(WARNCFLAGS) -AM_CXXFLAGS = $(GL_CFLAGS) $(OSMESA_CFLAGS) $(WARNCXXFLAGS) +AM_CFLAGS = $(GL_CFLAGS) $(OSMESA_CFLAGS) $(WARNCFLAGS) $(VISIBILITY_CFLAGS) +AM_CXXFLAGS = $(GL_CFLAGS) $(OSMESA_CFLAGS) $(WARNCXXFLAGS) $(VISIBILITY_CXXFLAGS) GLU_LIBRARY_VERSION=1:3:1 lib_LTLIBRARIES = libGLU.la diff --git a/configure.ac b/configure.ac index 68ff97a..74ffcea 100644 --- a/configure.ac +++ b/configure.ac @@ -77,11 +77,36 @@ else ]) fi -dnl Set up C warning flags. +dnl Set up C warning and visibility flags. if test "x$GCC" = xyes; then WARNCFLAGS="-Wall" + + # Enable -fvisibility=hidden if using a gcc that supports it + save_CFLAGS="$CFLAGS" + AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden]) + VISIBILITY_CFLAGS="-fvisibility=hidden" + CFLAGS="$CFLAGS $VISIBILITY_CFLAGS" + AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]), + [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]); + + # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed. + CFLAGS=$save_CFLAGS + if test "x$GXX" = xyes; then WARNCXXFLAGS="-Wall" + + # Enable -fvisibility=hidden if using a gcc that supports it + save_CXXFLAGS="$CXXFLAGS" + AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden]) + VISIBILITY_CXXFLAGS="-fvisibility=hidden" + CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS" + AC_LANG_PUSH([C++]) + AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]), + [VISIBILITY_CXXFLAGS=""; AC_MSG_RESULT([no])]); + AC_LANG_POP([C++]) + + # Restore CXXFLAGS; VISIBILITY_CXXFLAGS are added to it where needed. + CXXFLAGS=$save_CXXFLAGS fi else AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) @@ -92,6 +117,8 @@ else fi AC_SUBST([WARNCFLAGS]) AC_SUBST([WARNCXXFLAGS]) +AC_SUBST([VISIBILITY_CFLAGS]) +AC_SUBST([VISIBILITY_CXXFLAGS]) AC_OUTPUT([ Makefile -- cgit v1.2.3