Changeset 1514 for trunk/configure.ac


Ignore:
Timestamp:
Sep 23, 2012, 10:30:43 AM (11 years ago)
Author:
Peter Johansson
Message:

Closes #488. Change how configure sets CXXFLAGS and CPPFLAGS. There
are three cases: 1) As before, if --enable-debug is given, we append
'-pedantic -Wall -Wno-long-long -g -O'. 2) Otherwise, and CXXFLAGS was
not set by user, we set CXXFLAGS to '-O3' just as before.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r1495 r1514  
    6565AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
    6666
    67 # Let user overide default CXXFLAGS
    68 if test "${CXXFLAGS+set}" != set; then
    69   CXXFLAGS=""  # Setting CXXFLAGS here to prevent expansion in AC_PROG_CXX
    70 fi
     67# record if CXXFLAGS was set by user for further use below
     68AS_IF([test "${CXXFLAGS+set}" = set], [
     69  CXXFLAGS_set_by_user=yes
     70],[
     71  CXXFLAGS_set_by_user=no
     72  # set CXXFLAGS to avoid expansion in AC_PROG_CXX
     73  CXXFLAGS=
     74])
    7175
    7276# Checks for programs.
     
    9599
    96100AC_ARG_ENABLE([debug],
    97   [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
    98 
    99 # -Wno-long-long is needed to suppress compiler diagnostics regarding
    100 # using extension beyond the C++ standard (usage of non C++ standard
    101 # 'long long' types).
    102 AS_IF([test x$enable_debug = xyes],
    103   [YAT_CXX_ADD_FLAG([CXXFLAGS],[-pedantic -Wall -Wno-long-long -g -O])],
    104   [YAT_CPP_ADD_FLAG([CPPFLAGS],[-DNDEBUG])
    105    YAT_CXX_ADD_FLAG([CXXFLAGS],[-O3])])
     101  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])],
     102  [], [enable_debug=no])
     103
     104# Set CXXFLAGS depending on whether CXXFLAGS was provided by user and
     105# whether we are in debug mode
     106AS_IF([test x$enable_debug = xyes], [
     107  # in debug we alsways add flags below i.e. we turn on warnings,
     108  # debug symbols, and low level of optimisation.
     109
     110  # -Wno-long-long is needed to suppress compiler diagnostics regarding
     111  # using extension beyond the C++ standard (usage of non C++ standard
     112  # 'long long' types).
     113  YAT_CXX_ADD_FLAG([CXXFLAGS],[-pedantic -Wall -Wno-long-long -g -O])
     114],[
     115  # in standard mode we set to CXXFLAGS default to '-O3', but only if
     116  # CXXFLAGS was not proved by user. If user provided a VALUE FOR
     117  # CXXFLAGS we listen to that and leave as is.
     118  AS_IF([test x$CXXFLAGS_set_by_user != xyes], [
     119    YAT_CXX_ADD_FLAG([CXXFLAGS],[-O3])
     120  ])
     121])
     122
     123AC_ARG_ENABLE([assert],
     124  [AS_HELP_STRING([--enable-assert], [turn on assertions])])
     125
     126# if assert not enabled/disabled explicitly, default behaviour is to
     127# enable assert in debug mode and disable otherwise
     128test "${enable_assert+set}" = set || enable_assert=$enable_debug
     129
     130# FIXME perhaps we should AC_DEFINE NDEBUG instead but then we need to
     131# include config.h in all source files.
     132#
     133# propagate enable_assert to CPPFLAGS
     134AS_IF([test x$enable_assert != xyes],[YAT_CPP_ADD_FLAG([CPPFLAGS],[-DNDEBUG])])
    106135
    107136AC_MSG_CHECKING([g++ deprecation attribute])
Note: See TracChangeset for help on using the changeset viewer.