Changeset 2881 for trunk/configure.ac


Ignore:
Timestamp:
Nov 18, 2012, 2:28:05 AM (9 years ago)
Author:
Peter
Message:

Define PP variables in config.h rather than in CPPFLAGS. Include
config.h into all source files. Only ammend CXXFLAGS with '-Wall
-pedantic' when --enable-debug. In default mode we respect CXXFLAGS
value set by user, or set to default value '-O3'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r2878 r2881  
    8585AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
    8686
    87 # Let user overide default CXXFLAGS
    88 if test "${CXXFLAGS+set}" != set; then
    89   CXXFLAGS=""  # Setting CXXFLAGS here to prevent expansion in AC_PROG_CXX
    90 fi
     87# record if CXXFLAGS was set by user for further use below
     88AS_IF([test "${CXXFLAGS+set}" = set], [
     89  CXXFLAGS_set_by_user=yes
     90],[
     91  CXXFLAGS_set_by_user=no
     92  # set CXXFLAGS to avoid expansion in AC_PROG_CXX
     93  CXXFLAGS=
     94])
     95
    9196# Checks for programs.
    9297AC_PROG_CXX
     
    299304fi
    300305
     306AC_DEFINE([HAVE_INLINE], [1], [Define if inline is available on system])
     307AC_ARG_ENABLE([debug],
     308  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
     309
    301310# we use prefix INTERNAL_ for variables that are solely needed for
    302311# building yat, i.e., they are not needed for a user of yat and are
    303312# not propagated to yat-config or yat.m4.
    304 AS_IF([test x"$ax_cv_cxx_compiler_vendor" = x"gnu"], [
    305   YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-Wall -pedantic])
    306 ])
    307 YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS], [-DHAVE_INLINE=1])
    308 AC_ARG_ENABLE([debug],
    309   [AS_HELP_STRING([--enable-debug],[turn on debug options and code])])
    310 if test "${enable_debug}" = "yes" ; then
    311   YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS], [-DYAT_DEBUG=1])
    312   YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-g -O])
    313 else
     313AS_IF([test "${enable_debug}" = "yes"], [
     314  AC_DEFINE([YAT_DEBUG], [1], [Define to activate yat assertioons])
     315  YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-Wall -pedantic -g -O])
     316], [
    314317  # avoid defining GSL_RANGE_CHECK_OFF if GSL_RANGE_CHECK is already defined
    315318  AC_CHECK_DECL([GSL_RANGE_CHECK],[],
    316                 [YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS],[-DGSL_RANGE_CHECK_OFF])])
    317   YAT_CPP_ADD_FLAG([INTERNAL_CPPFLAGS], [-DNDEBUG])
    318   YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-O3])
    319 fi
     319                [AC_DEFINE([GSL_RANGE_CHECK_OFF], [1],
     320                           [Define to turn off GSL range checks])])
     321  AC_DEFINE([NDEBUG], [1], [Define to turn off assertions])
     322  # If CXXFLAGS not set by user, set it to default value
     323  AS_IF([test x$CXXFLAGS_set_by_user != xyes], [
     324    YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS],[-O3])
     325  ])
     326])
    320327
    321328# turn off compiler warning #654 from intel compiler
     
    336343])
    337344
    338 # some versions of boost uses long long - turn off compiler warnings
    339 # with -Wno-long-long
    340 yat_save_CXXFLAGS=$CXXFLAGS
    341 AC_MSG_CHECKING([whether boost uses long long])
    342 CXXFLAGS="$INTERNAL_CXXFLAGS $CXXFLAGS"
    343 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
    344   [
    345     @%:@include <boost/iterator/transform_iterator.hpp>
    346     @%:@include <boost/thread.hpp>
    347     @%:@include <cmath>
    348     @%:@include <functional>
    349     @%:@include <vector>
    350   ],[
     345AS_IF([test x$enable_debug = xyes], [
     346  # some versions of boost uses long long - turn off compiler warnings
     347  # with -Wno-long-long
     348  yat_save_CXXFLAGS=$CXXFLAGS
     349  AC_MSG_CHECKING([whether boost uses long long])
     350  CXXFLAGS="$INTERNAL_CXXFLAGS $CXXFLAGS"
     351  AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
     352    [
     353      @%:@include <boost/iterator/transform_iterator.hpp>
     354      @%:@include <boost/thread.hpp>
     355      @%:@include <cmath>
     356      @%:@include <functional>
     357      @%:@include <vector>
     358    ],[
    351359      using namespace boost;
    352360      typedef std::pointer_to_unary_function<double, double> F;
     
    356364      int x = boost::thread::hardware_concurrency();
    357365      ++x;
    358   ])],
    359 [AC_MSG_RESULT([no])],
    360 [AC_MSG_RESULT([yes])
    361  YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-Wno-long-long])
    362 ])
    363 # restore CXXFLAGS
    364 CXXFLAGS=$yat_save_CXXFLAGS
     366    ])],
     367  [AC_MSG_RESULT([no])],
     368  [AC_MSG_RESULT([yes])
     369   YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-Wno-long-long])
     370  ])
     371  # restore CXXFLAGS
     372  CXXFLAGS=$yat_save_CXXFLAGS
     373])
    365374
    366375#doxygen stuff
Note: See TracChangeset for help on using the changeset viewer.