COIN-OR::LEMON - Graph Library

source: lemon-0.x/config/cxxflags.m4 @ 1430:48b4f46f9d4e

Last change on this file since 1430:48b4f46f9d4e was 1369:f1cf6b807414, checked in by Akos Ladanyi, 20 years ago

irrelevant changes

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