# HG changeset patch # User Akos Ladanyi # Date 1225896277 0 # Node ID a637fb9d457b737f827ebc09b6aa350d0f4cc0e9 # Parent 51597950d0fe0dfc124696b999aafbc9a8ca14e7 Revert to the canonical way of customizing CXXFLAGS A default list of compiler flags is set via AM_CXXFLAGS Automake variable. However this gets overridden by per-target CXXFLAGS variables (e.g. foo_CXXFLAGS in case the foo target). Because of this you should append $(AM_CXXFLAGS) to the end of the per-target CXXFLAGS variables (e.g. foo_CXXFLAGS = ... $(AM_CXXFLAGS)). After this default list of flags the contents of the CXXFLAGS user variable is passed to the compiler. This variable has a default value determined by configure (in case of g++ it is '-g -O2'). You can override this by specifying CXXFLAGS when invoking make (e.g. make CXXFLAGS='-O3'). diff -r 51597950d0fe -r a637fb9d457b Makefile.am --- a/Makefile.am Wed Nov 05 08:11:44 2008 +0000 +++ b/Makefile.am Wed Nov 05 14:44:37 2008 +0000 @@ -1,5 +1,7 @@ ACLOCAL_AMFLAGS = -I m4 +AM_CXXFLAGS = $(WARNINGCXXFLAGS) + AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir) LDADD = $(top_builddir)/lemon/libemon.la diff -r 51597950d0fe -r a637fb9d457b configure.ac --- a/configure.ac Wed Nov 05 08:11:44 2008 +0000 +++ b/configure.ac Wed Nov 05 14:44:37 2008 +0000 @@ -19,8 +19,6 @@ AC_CONFIG_SRCDIR([lemon/list_graph.h]) AC_CONFIG_HEADERS([config.h lemon/config.h]) -lx_cmdline_cxxflags_set=${CXXFLAGS+set} - dnl Do compilation tests using the C++ compiler. AC_LANG([C++]) @@ -46,9 +44,10 @@ fi dnl Set custom compiler flags when using g++. -if test x"$lx_cmdline_cxxflags_set" != x"set" -a "$GXX" = yes -a "$ICC" = no; then - CXXFLAGS="$CXXFLAGS -Wall -W -Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas" +if test "$GXX" = yes -a "$ICC" = no; then + WARNINGCXXFLAGS="-Wall -W -Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas" fi +AC_SUBST([WARNINGCXXFLAGS]) dnl Checks for libraries. #LX_CHECK_GLPK @@ -113,7 +112,7 @@ echo Package version............... : $PACKAGE-$VERSION echo echo C++ compiler.................. : $CXX -echo C++ compiles flags............ : $CXXFLAGS +echo C++ compiles flags............ : $WARNINGCXXFLAGS $CXXFLAGS echo #echo GLPK support.................. : $lx_glpk_found #echo CPLEX support................. : $lx_cplex_found diff -r 51597950d0fe -r a637fb9d457b lemon/Makefile.am --- a/lemon/Makefile.am Wed Nov 05 08:11:44 2008 +0000 +++ b/lemon/Makefile.am Wed Nov 05 14:44:37 2008 +0000 @@ -12,7 +12,7 @@ lemon/color.cc \ lemon/random.cc -#lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS) +#lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS) $(AM_CXXFLAGS) #lemon_libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS) $(SOPLEX_LIBS) lemon_HEADERS += \