From b788ebab4b978e7fb4d47d1301a400d9cfd5e9a2 Mon Sep 17 00:00:00 2001 From: tchernobog Date: Mon, 20 Feb 2006 21:26:08 +0000 Subject: [PATCH] - Fix Python/C++ module compilation when compiler supports the -fvisibility=hidden option - Update Makefile consequentially git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@361 3ecf2c5c-341e-0410-92b4-d18e462d057c --- Makefile.am | 5 +++++ configure.ac | 15 ++++++++------- m4/compilerflags.m4 | 38 +++++++++++++++++++++++-------------- m4/linkingflags.m4 | 17 +++++++++++------ src/templates/parameter.tcc | 2 +- 5 files changed, 49 insertions(+), 28 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1972104..fe3a70a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -120,6 +120,8 @@ src_backend_pyloader_libpyloader_la_CPPFLAGS = \ -DLOCALEDIR="\"$(localedir)\"" \ $(PYTHON_CPPFLAGS) \ $(GLIBMM_CFLAGS) +src_backend_pyloader_libpyloader_la_CXXFLAGS = \ + $(VISIB_HIDDEN) src_backend_pyloader_libpyloader_la_LIBADD = \ $(PYTHON_LDFLAGS) \ $(PYTHON_EXTRA_LIBS) \ @@ -157,6 +159,8 @@ src_backend_libbackend_la_CPPFLAGS = \ -DLOCALEDIR="\"$(localedir)\"" \ $(PYTHON_CPPFLAGS) \ $(GLIBMM_CFLAGS) +src_backend_libbackend_la_CXXFLAGS = \ + $(VISIB_HIDDEN) src_backend_libbackend_la_LIBADD = \ src/backend/pyloader/libpyloader.la src_backend_libbackend_la_LDFLAGS = \ @@ -210,6 +214,7 @@ sgpemv2_CPPFLAGS = \ $(GTKMM_CFLAGS) \ $(PYTHON_CPPFLAGS) \ $(GTHREAD_CFLAGS) +sgpemv2_CXXFLAGS = $(VISIB_HIDDEN) sgpemv2_LDFLAGS = $(LT_LDFLAGS) sgpemv2_LDADD = \ src/backend/libbackend.la \ diff --git a/configure.ac b/configure.ac index 1d46dc1..a6dea25 100644 --- a/configure.ac +++ b/configure.ac @@ -60,11 +60,11 @@ CAIRO_VERSION=1.0.0 dnl c++ compiler and flags AC_PROG_CXX -AC_CHECK_CXXFLAG([Wall]) -AC_CHECK_CXXFLAG([pedantic]) -AC_CHECK_CXXFLAG([Wextra]) -AC_CHECK_CXXFLAG([Wno-long-long]) -AC_CHECK_LDFLAG([--as-needed]) +AC_CHECK_CXXFLAG([CXXFLAGS], [Wall]) +AC_CHECK_CXXFLAG([CXXFLAGS], [pedantic]) +AC_CHECK_CXXFLAG([CXXFLAGS], [Wextra]) +AC_CHECK_CXXFLAG([CXXFLAGS], [Wno-long-long]) +AC_CHECK_LDFLAG([LDFLAGS],[--as-needed]) AC_PROG_INSTALL @@ -119,8 +119,9 @@ AC_COMPILE_IFELSE( AC_DEFINE([SG_DLLLOCAL],[__attribute__ ((visibility("hidden")))]) AC_DEFINE([SG_DLLPUBLIC],[__attribute__ ((visibility("default")))]) - AC_CHECK_CXXFLAG([fvisibility=hidden]) - AC_CHECK_CXXFLAG([fvisibility-inlines-hidden]) + AC_CHECK_CXXFLAG([VISIB_HIDDEN], [fvisibility=hidden]) + AC_SUBST([VISIB_HIDDEN]) + AC_CHECK_CXXFLAG([CXXFLAGS],[fvisibility-inlines-hidden]) ],[ AC_MSG_RESULT([no]) AC_DEFINE([SG_DLLIMPORT],[/* unsupported */]) diff --git a/m4/compilerflags.m4 b/m4/compilerflags.m4 index bb651b3..a843dc6 100644 --- a/m4/compilerflags.m4 +++ b/m4/compilerflags.m4 @@ -2,22 +2,27 @@ dnl ************************************************** dnl Copyright (C) 2004 Matteo Settenvini dnl ************************************************** -dnl ---------- AX_CHECK_CXXFLAG --------------------- +dnl ---------- AC_CHECK_CXXFLAG --------------------- dnl This macro checks if a particular flag for the -dnl C++ compiler works. If it is so, it adds the flag -dnl to the CXXFLAGS variable. -dnl Example of usage : AC_CHECK_CXXFLAG([Wall]) +dnl C++ compiler works. If it is so, it puts the flag +dnl into the first macro parameter. +dnl Example of usage : AC_CHECK_CXXFLAG([CXXFLAGS],[Wall]) dnl ------------------------------------------------- AC_DEFUN([AC_CHECK_CXXFLAG], -[ AC_REQUIRE([AC_PROG_CXX])dnl - AC_MSG_CHECKING([whether $CXX supports the -$1 flag]) +[ if test -z "$1" -o -z "$2"; then + AC_MSG_FAILURE([Wrong parameters passed to the m4 macro. +Please contact the package mantainer.]) + fi + AC_REQUIRE([AC_PROG_CXX])dnl + AC_MSG_CHECKING([whether $CXX supports the -$2 flag]) ac_check_cxxflags=$CXXFLAGS - CXXFLAGS="-$1" + CXXFLAGS="-$2" AC_LANG_PUSH([C++]) AC_COMPILE_IFELSE( AC_LANG_PROGRAM([], [return 0;]), [AC_MSG_RESULT([yes]) - CXXFLAGS="-$1 $ac_check_cxxflags" ], + CXXFLAGS="$ac_check_cxxflags" + $1="-$2 $[$1]" ], [AC_MSG_RESULT([no]) CXXFLAGS=$ac_check_cxxflags ] ) @@ -29,19 +34,24 @@ AC_DEFUN([AC_CHECK_CXXFLAG], dnl ---------- AC_CHECK_CFLAG --------------------- dnl This macro checks if a particular flag for the dnl C compiler works. If it is so, it adds the flag -dnl to the CFLAGS variable. -dnl Example of usage : AC_CHECK_CFLAG([Wall]) +dnl into the first macro parameter. +dnl Example of usage : AC_CHECK_CFLAG([CFLAGS],[Wall]) dnl ------------------------------------------------- AC_DEFUN([AC_CHECK_CFLAG], -[ AC_REQUIRE([AC_PROG_CC])dnl - AC_MSG_CHECKING([whether $CC supports the -$1 flag]) +[ if test -z "$1" -o -z "$2"; then + AC_MSG_FAILURE([Wrong parameters passed to the m4 macro. +Please contact the package mantainer.]) + fi + AC_REQUIRE([AC_PROG_CC])dnl + AC_MSG_CHECKING([whether $CC supports the -$2 flag]) ac_check_cflags=$CFLAGS - CFLAGS="-$1" + CFLAGS="-$2" AC_LANG_PUSH([C]) AC_COMPILE_IFELSE( AC_LANG_PROGRAM([], [return 0;]), [AC_MSG_RESULT([yes]) - CFLAGS="-$1 $ac_check_cflags" ], + CFLAGS="$ac_check_cflags" + $1="-$2 $[$1]" ], [AC_MSG_RESULT([no]) CFLAGS=$ac_check_cflags ] ) diff --git a/m4/linkingflags.m4 b/m4/linkingflags.m4 index e1ace94..802cbe8 100644 --- a/m4/linkingflags.m4 +++ b/m4/linkingflags.m4 @@ -5,19 +5,24 @@ dnl ************************************************** dnl ---------- AX_CHECK_LDFLAG --------------------- dnl This macro checks if a particular flag for the dnl C++ compiler works. If it is so, it adds the flag -dnl to the CXXFLAGS variable. -dnl Example of usage : AC_CHECK_LDFLAG([--as-needed]) +dnl to the end of the first parameter. +dnl Example of usage : AC_CHECK_LDFLAG([LDFLAGS],[--as-needed]) dnl ------------------------------------------------- AC_DEFUN([AC_CHECK_LDFLAG], -[ AC_REQUIRE([AC_PROG_CC])dnl - AC_MSG_CHECKING([whether the linker supports the $1 flag]) +[ if test -z "$1" -o -z "$2"; then + AC_MSG_FAILURE([Wrong parameters passed to the m4 macro. +Please contact the package mantainer.]) + fi + AC_REQUIRE([AC_PROG_CC])dnl + AC_MSG_CHECKING([whether the linker supports the $2 flag]) ac_check_ldflags=$LDFLAGS - LDFLAGS="-Wl,$1" + LDFLAGS="-Wl,$2" AC_LANG_PUSH([C]) AC_LINK_IFELSE( AC_LANG_PROGRAM([], [return 0;]), [AC_MSG_RESULT([yes]) - LDFLAGS="-Wl,$1 $ac_check_ldflags" ], + LDFLAGS=$ac_check_ldflags + $1="-Wl,$2 $[$1]" ], [AC_MSG_RESULT([no]) LDFLAGS=$ac_check_ldflags ] ) diff --git a/src/templates/parameter.tcc b/src/templates/parameter.tcc index 579dd43..ce60062 100644 --- a/src/templates/parameter.tcc +++ b/src/templates/parameter.tcc @@ -1,4 +1,4 @@ -// src/templates/parameter.tcc - Copyright 2005, 2006, University +// Src/templates/parameter.tcc - Copyright 2005, 2006, University // of Padova, dept. of Pure and Applied // Mathematics //