1 dnl LX_C_IFDEF(MACRO-NAME, ACTION-IF-DEF, ACTION-IF-NOT-DEF)
3 dnl Check for the definition of macro MACRO-NAME using the current
4 dnl language's compiler.
6 dnl Orignally written by Ludovic Courtès <ludo@chbouib.org>
8 [AC_COMPILE_IFELSE([#ifndef $1
9 # error "Macro $1 is undefined!"
10 /* For some compilers (eg. SGI's CC), #error is not
17 dnl LX_CXX_COMPILER_VENDOR(VENDOR-NAME, [NICKNAME])
19 dnl Set VENDOR-NAME to the lower-case name of the compiler vendor or
20 dnl `unknown' if the compiler's vendor is unknown. `compaq' means the
21 dnl CXX compiler as available on Tru64/OSF1/Digital Unix on Alpha
22 dnl machines. If NICKNAME is provided, set it to the compiler's usual
23 dnl name (eg. `g++', `cxx', `aCC', etc.).
25 dnl Based on work of Ludovic Courtès <ludo@chbouib.org>
26 AC_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],
35 LX_C_IFDEF([__INTEL_COMPILER],
36 [lx_cv_cxx_compiler_vendor=intel],
38 LX_C_IFDEF([__GNUG__],
39 [lx_cv_cxx_compiler_vendor=gnu],
40 [LX_C_IFDEF([__DECCXX],
41 [lx_cv_cxx_compiler_vendor=compaq],
43 LX_C_IFDEF([__HP_aCC],
44 [lx_cv_cxx_compiler_vendor=hp],
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.
52 LX_C_IFDEF([_MSC_VER],
53 [lx_cv_cxx_compiler_vendor=microsoft],
54 [lx_cv_cxx_compiler_vendor=unknown])
55 AC_LANG_POP()])])])])])
58 $1="$lx_cv_cxx_compiler_vendor"
60 dnl The compiler nickname
62 [case "$lx_cv_cxx_compiler_vendor" in
73 dnl Set some debugging and error reporting related compiler flags.
74 dnl uses lx_user_cxxflags
75 AC_DEFUN([LX_SET_CXXFLAGS],
76 [AC_ARG_ENABLE([debug],
77 AS_HELP_STRING([--enable-debug@<:@=yes|no|full@:>@], [Build with debugging support])
78 AS_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])
85 lx_gnu_cxxflags="-ansi -pedantic -Wall -Wextra"
86 lx_intel_cxxflags="-g"
87 lx_unknown_cxxflags="-g"
89 if test x"$enable_debug" = x"yes"; then
90 lx_gnu_cxxflags="-g $lx_gnu_cxxflags"
93 lx_gnu_cxxflags="-g3 --no-inline $lx_gnu_cxxflags"
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"
102 CXXFLAGS="$lx_user_cxxflags $lx_unknown_cxxflags"
108 AC_ARG_ENABLE([extra-warnings],
109 AS_HELP_STRING([--enable-extra-warnings], [Enable extra warning messages])
110 AS_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"