config/cxxflags.m4
author alpar
Fri, 22 Apr 2005 17:47:01 +0000
changeset 1381 998e8def9676
parent 1350 fb794edbf04b
permissions -rw-r--r--
- lp_cplex.h, lp_cplex.cc added
- lp_demo.cc and lp_maxflow_demo.cc uses GLPK is it is found CPLEX otherwise
ladanyi@1350
     1
dnl LX_C_IFDEF(MACRO-NAME, ACTION-IF-DEF, ACTION-IF-NOT-DEF)
ladanyi@1350
     2
dnl
ladanyi@1350
     3
dnl Check for the definition of macro MACRO-NAME using the current
ladanyi@1350
     4
dnl language's compiler.
ladanyi@1350
     5
dnl
ladanyi@1350
     6
dnl Orignally written by Ludovic Courtès <ludo@chbouib.org>
ladanyi@1350
     7
AC_DEFUN([LX_C_IFDEF],
ladanyi@1350
     8
  [AC_COMPILE_IFELSE([#ifndef $1
ladanyi@1350
     9
                      # error "Macro $1 is undefined!"
ladanyi@1350
    10
                      /* For some compilers (eg. SGI's CC), #error is not
ladanyi@1350
    11
                         enough...  */
ladanyi@1350
    12
                      please, do fail
ladanyi@1350
    13
                      #endif],
ladanyi@1350
    14
                     [$2], [$3])])
ladanyi@1350
    15
ladanyi@1350
    16
ladanyi@1350
    17
dnl LX_CXX_COMPILER_VENDOR(VENDOR-NAME, [NICKNAME])
ladanyi@1350
    18
dnl
ladanyi@1350
    19
dnl Set VENDOR-NAME to the lower-case name of the compiler vendor or
ladanyi@1350
    20
dnl `unknown' if the compiler's vendor is unknown. `compaq' means the
ladanyi@1350
    21
dnl CXX compiler as available on Tru64/OSF1/Digital Unix on Alpha
ladanyi@1350
    22
dnl machines. If NICKNAME is provided, set it to the compiler's usual
ladanyi@1350
    23
dnl name (eg. `g++', `cxx', `aCC', etc.).
ladanyi@1350
    24
dnl
ladanyi@1350
    25
dnl Based on work of Ludovic Courtès <ludo@chbouib.org>
ladanyi@1350
    26
AC_DEFUN([LX_CXX_COMPILER_VENDOR],
ladanyi@1350
    27
  [AC_REQUIRE([AC_PROG_CXX])
ladanyi@1350
    28
   AC_REQUIRE([AC_PROG_CXXCPP])
ladanyi@1350
    29
   AC_CACHE_CHECK([the C++ compiler vendor],
ladanyi@1350
    30
    [lx_cv_cxx_compiler_vendor],
ladanyi@1350
    31
ladanyi@1350
    32
    [AC_LANG_PUSH([C++])
ladanyi@1350
    33
ladanyi@1350
    34
     dnl Intel's icpc
ladanyi@1350
    35
     LX_C_IFDEF([__INTEL_COMPILER],
ladanyi@1350
    36
       [lx_cv_cxx_compiler_vendor=intel],
ladanyi@1350
    37
       [dnl GNU C++
ladanyi@1350
    38
        LX_C_IFDEF([__GNUG__],
ladanyi@1350
    39
         [lx_cv_cxx_compiler_vendor=gnu],
ladanyi@1350
    40
         [LX_C_IFDEF([__DECCXX],
ladanyi@1350
    41
           [lx_cv_cxx_compiler_vendor=compaq],
ladanyi@1350
    42
           [dnl HP's aCC
ladanyi@1350
    43
            LX_C_IFDEF([__HP_aCC],
ladanyi@1350
    44
             [lx_cv_cxx_compiler_vendor=hp],
ladanyi@1350
    45
             [dnl SGI CC
ladanyi@1350
    46
              LX_C_IFDEF([__sgi],
ladanyi@1350
    47
               [lx_cv_cxx_compiler_vendor=sgi],
ladanyi@1350
    48
               [dnl Note:  We are using the C compiler because VC++ doesn't
ladanyi@1350
    49
                dnl recognize `.cc'(which is used by `configure') as a C++ file
ladanyi@1350
    50
                dnl extension and requires `/TP' to be passed.
ladanyi@1350
    51
                AC_LANG_PUSH([C])
ladanyi@1350
    52
                LX_C_IFDEF([_MSC_VER],
ladanyi@1350
    53
                  [lx_cv_cxx_compiler_vendor=microsoft],
ladanyi@1350
    54
                  [lx_cv_cxx_compiler_vendor=unknown])
ladanyi@1350
    55
                AC_LANG_POP()])])])])])
ladanyi@1350
    56
ladanyi@1350
    57
     AC_LANG_POP()])
ladanyi@1350
    58
   $1="$lx_cv_cxx_compiler_vendor"
ladanyi@1350
    59
ladanyi@1350
    60
   dnl The compiler nickname
ladanyi@1350
    61
   ifelse([$2], , [],
ladanyi@1350
    62
     [case "$lx_cv_cxx_compiler_vendor" in
ladanyi@1350
    63
        intel)     $2=icpc;;
ladanyi@1350
    64
        gnu)       $2=g++;;
ladanyi@1350
    65
        compaq)    $2=cxx;;
ladanyi@1350
    66
        hp)        $2=aCC;;
ladanyi@1350
    67
        sgi)       $2=CC;;
ladanyi@1350
    68
        microsoft) $2=cl;;
ladanyi@1350
    69
        *)         $2=unknown;;
ladanyi@1350
    70
      esac])])
ladanyi@1350
    71
ladanyi@1350
    72
ladanyi@1350
    73
dnl Set some debugging and error reporting related compiler flags.
ladanyi@1350
    74
dnl uses lx_user_cxxflags
ladanyi@1350
    75
AC_DEFUN([LX_SET_CXXFLAGS],
ladanyi@1350
    76
  [AC_ARG_ENABLE([debug],
ladanyi@1369
    77
AS_HELP_STRING([--enable-debug@<:@=yes|no|full@:>@], [build with debugging support])
ladanyi@1369
    78
AS_HELP_STRING([--disable-debug], [build without debugging support @<:@default@:>@]),
ladanyi@1350
    79
     [], [enable_debug=no])
ladanyi@1350
    80
   LX_CXX_COMPILER_VENDOR([lx_cxx_compiler_vendor])
ladanyi@1350
    81
   AC_MSG_CHECKING([whether to build with debugging support])
ladanyi@1350
    82
   if test x"$enable_debug" != x"no"; then
ladanyi@1350
    83
     AC_DEFINE([DEBUG], [1], [Define for debugging support])
ladanyi@1350
    84
ladanyi@1350
    85
     lx_gnu_cxxflags="-ansi -pedantic -Wall -Wextra"
ladanyi@1350
    86
     lx_intel_cxxflags="-g"
ladanyi@1350
    87
     lx_unknown_cxxflags="-g"
ladanyi@1350
    88
ladanyi@1350
    89
     if test x"$enable_debug" = x"yes"; then
ladanyi@1350
    90
       lx_gnu_cxxflags="-g $lx_gnu_cxxflags"
ladanyi@1350
    91
       AC_MSG_RESULT([yes])
ladanyi@1350
    92
     else
ladanyi@1350
    93
       lx_gnu_cxxflags="-g3 --no-inline $lx_gnu_cxxflags"
ladanyi@1350
    94
       AC_MSG_RESULT([full])
ladanyi@1350
    95
     fi
ladanyi@1350
    96
ladanyi@1350
    97
     if test x"$lx_cxx_compiler_vendor" = x"gnu"; then
ladanyi@1350
    98
       CXXFLAGS="$lx_user_cxxflags $lx_gnu_cxxflags"
ladanyi@1350
    99
     elif test x"$lx_cxx_compiler_vendor" = x"intel"; then
ladanyi@1350
   100
       CXXFLAGS="$lx_user_cxxflags $lx_intel_cxxflags"
ladanyi@1350
   101
     else
ladanyi@1350
   102
       CXXFLAGS="$lx_user_cxxflags $lx_unknown_cxxflags"
ladanyi@1350
   103
     fi
ladanyi@1350
   104
   else
ladanyi@1350
   105
     AC_MSG_RESULT([no])
ladanyi@1350
   106
   fi
ladanyi@1350
   107
ladanyi@1350
   108
   AC_ARG_ENABLE([extra-warnings],
ladanyi@1369
   109
AS_HELP_STRING([--enable-extra-warnings], [enable extra warning messages])
ladanyi@1369
   110
AS_HELP_STRING([--disable-extra-warnings], [disable extra warning messages @<:@default@:>@]),
ladanyi@1350
   111
     [],[enable_extra_warnings=no])
ladanyi@1350
   112
   AC_MSG_CHECKING(whether to enable extra warning flags)
ladanyi@1350
   113
   if test x"$enable_extra_warnings" != x"no"; then
ladanyi@1350
   114
     if test x"$lx_cxx_compiler_vendor" = x"gnu"; then
ladanyi@1350
   115
       CXXFLAGS="$CXXFLAGS -ansi -pedantic -Wall -Wextra"
ladanyi@1350
   116
       CXXFLAGS="$CXXFLAGS -Wfloat-equal -Wundef -Wendif-labels -Wshadow"
ladanyi@1350
   117
       CXXFLAGS="$CXXFLAGS -Wpointer-arith -Wcast-qual -Wcast-align"
ladanyi@1350
   118
       CXXFLAGS="$CXXFLAGS -Wwrite-strings -Wconversion -Waggregate-return"
ladanyi@1350
   119
       CXXFLAGS="$CXXFLAGS -Wmissing-noreturn -Wmissing-format-attribute"
ladanyi@1350
   120
       CXXFLAGS="$CXXFLAGS -Wpacked -Wpadded -Wredundant-decls"
ladanyi@1350
   121
       CXXFLAGS="$CXXFLAGS -Wunreachable-code -Winline -Winvalid-pch"
ladanyi@1350
   122
       CXXFLAGS="$CXXFLAGS -Wlong-long -Wdisabled-optimization"
ladanyi@1350
   123
       CXXFLAGS="$CXXFLAGS -Wstack-protector"
ladanyi@1350
   124
     elif test x"$lx_cxx_compiler_vendor" = x"intel"; then
ladanyi@1350
   125
       CXXFLAGS="$CXXFLAGS -w2"
ladanyi@1350
   126
     fi
ladanyi@1350
   127
     AC_MSG_RESULT([yes])
ladanyi@1350
   128
   else
ladanyi@1350
   129
     AC_MSG_RESULT([no])
ladanyi@1350
   130
   fi])