Revert to the canonical way of customizing CXXFLAGS
authorAkos Ladanyi <ladanyi@tmit.bme.hu>
Wed, 05 Nov 2008 14:44:37 +0000
changeset 375a637fb9d457b
parent 374 51597950d0fe
child 378 efbd0ab50a77
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').
Makefile.am
configure.ac
lemon/Makefile.am
     1.1 --- a/Makefile.am	Wed Nov 05 08:11:44 2008 +0000
     1.2 +++ b/Makefile.am	Wed Nov 05 14:44:37 2008 +0000
     1.3 @@ -1,5 +1,7 @@
     1.4  ACLOCAL_AMFLAGS = -I m4
     1.5  
     1.6 +AM_CXXFLAGS = $(WARNINGCXXFLAGS)
     1.7 +
     1.8  AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir)
     1.9  LDADD = $(top_builddir)/lemon/libemon.la
    1.10  
     2.1 --- a/configure.ac	Wed Nov 05 08:11:44 2008 +0000
     2.2 +++ b/configure.ac	Wed Nov 05 14:44:37 2008 +0000
     2.3 @@ -19,8 +19,6 @@
     2.4  AC_CONFIG_SRCDIR([lemon/list_graph.h])
     2.5  AC_CONFIG_HEADERS([config.h lemon/config.h])
     2.6  
     2.7 -lx_cmdline_cxxflags_set=${CXXFLAGS+set}
     2.8 -
     2.9  dnl Do compilation tests using the C++ compiler.
    2.10  AC_LANG([C++])
    2.11  
    2.12 @@ -46,9 +44,10 @@
    2.13  fi
    2.14  
    2.15  dnl Set custom compiler flags when using g++.
    2.16 -if test x"$lx_cmdline_cxxflags_set" != x"set" -a "$GXX" = yes -a "$ICC" = no; then
    2.17 -  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"
    2.18 +if test "$GXX" = yes -a "$ICC" = no; then
    2.19 +  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"
    2.20  fi
    2.21 +AC_SUBST([WARNINGCXXFLAGS])
    2.22  
    2.23  dnl Checks for libraries.
    2.24  #LX_CHECK_GLPK
    2.25 @@ -113,7 +112,7 @@
    2.26  echo Package version............... : $PACKAGE-$VERSION
    2.27  echo
    2.28  echo C++ compiler.................. : $CXX
    2.29 -echo C++ compiles flags............ : $CXXFLAGS
    2.30 +echo C++ compiles flags............ : $WARNINGCXXFLAGS $CXXFLAGS
    2.31  echo
    2.32  #echo GLPK support.................. : $lx_glpk_found
    2.33  #echo CPLEX support................. : $lx_cplex_found
     3.1 --- a/lemon/Makefile.am	Wed Nov 05 08:11:44 2008 +0000
     3.2 +++ b/lemon/Makefile.am	Wed Nov 05 14:44:37 2008 +0000
     3.3 @@ -12,7 +12,7 @@
     3.4          lemon/color.cc \
     3.5          lemon/random.cc
     3.6  
     3.7 -#lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS)
     3.8 +#lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS) $(AM_CXXFLAGS)
     3.9  #lemon_libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS) $(SOPLEX_LIBS)
    3.10  
    3.11  lemon_HEADERS += \