1 dnl Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 dnl This library is free software; you can redistribute it and/or
5 dnl modify it under the terms of the GNU Lesser General Public
6 dnl License as published by the Free Software Foundation; either
7 dnl version 2.1 of the License.
9 dnl This library is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 dnl Lesser General Public License for more details.
14 dnl You should have received a copy of the GNU Lesser General Public
15 dnl License along with this library; if not, write to the Free Software
16 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 dnl See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 dnl Synopsis : AC_CC_WARNINGS([ANSI])
24 dnl Version : 1.1 (2000/12/31)
26 dnl Author : Ville Laurikari <vl@iki.fi>
30 dnl Enables a reasonable set of warnings for the C compiler.
31 dnl Optionally, if the first argument is nonempty, turns on
32 dnl flags which enforce and/or enable proper ANSI C if such
33 dnl flags are known to the compiler used.
35 dnl Currently this macro knows about GCC, Solaris C compiler,
36 dnl Digital Unix C compiler, C for AIX Compiler, HP-UX C
37 dnl compiler, and IRIX C compiler.
39 AC_DEFUN([AC_CC_WARNINGS], [
41 if test -z "$ansi"; then
42 msg="for C compiler warning flags"
44 msg="for C compiler warning and ANSI conformance flags"
46 AC_CACHE_CHECK($msg, ac_cv_prog_cc_warnings, [
47 if test -n "$CC"; then
48 cat > conftest.c <<EOF
49 int main(int argc, char **argv) { return 0; }
53 if test "$GCC" = "yes"; then
54 if test -z "$ansi"; then
55 ac_cv_prog_cc_warnings="-Wall"
57 ac_cv_prog_cc_warnings="-Wall -ansi -pedantic"
60 dnl Solaris C compiler
61 elif $CC -flags 2>&1 | grep "Xc.*strict ANSI C" > /dev/null 2>&1 &&
62 $CC -c -v -Xc conftest.c > /dev/null 2>&1 &&
63 test -f conftest.o; then
64 if test -z "$ansi"; then
65 ac_cv_prog_cc_warnings="-v"
67 ac_cv_prog_cc_warnings="-v -Xc"
71 elif $CC > /dev/null 2>&1 &&
72 $CC -c -Aa +w1 conftest.c > /dev/null 2>&1 &&
73 test -f conftest.o; then
74 if test -z "$ansi"; then
75 ac_cv_prog_cc_warnings="+w1"
77 ac_cv_prog_cc_warnings="+w1 -Aa"
80 dnl Digital Unix C compiler
81 elif ! $CC > /dev/null 2>&1 &&
82 $CC -c -verbose -w0 -warnprotos -std1 conftest.c > /dev/null 2>&1 &&
83 test -f conftest.o; then
84 if test -z "$ansi"; then
85 ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos"
87 ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1"
90 dnl C for AIX Compiler
91 elif $CC > /dev/null 2>&1 | grep AIX > /dev/null 2>&1 &&
92 $CC -c -qlanglvl=ansi -qinfo=all conftest.c > /dev/null 2>&1 &&
93 test -f conftest.o; then
94 if test -z "$ansi"; then
95 ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd"
97 ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi"
101 elif $CC -fullwarn -ansi -ansiE > /dev/null 2>&1 &&
102 test -f conftest.o; then
103 if test -z "$ansi"; then
104 ac_cv_prog_cc_warnings="-fullwarn"
106 ac_cv_prog_cc_warnings="-fullwarn -ansi -ansiE"
112 if test -n "$ac_cv_prog_cc_warnings"; then
113 CFLAGS="$CFLAGS $ac_cv_prog_cc_warnings"
114 CXXFLAGS="$CXXFLAGS $ac_cv_prog_cc_warnings"
116 ac_cv_prog_cc_warnings="unknown"