1 dnl Copyright (C) 2006-2020 CEA/DEN, EDF R&D
3 dnl This library is free software; you can redistribute it and/or
4 dnl modify it under the terms of the GNU Lesser General Public
5 dnl License as published by the Free Software Foundation; either
6 dnl version 2.1 of the License, or (at your option) any later version.
8 dnl This library is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 dnl Lesser General Public License for more details.
13 dnl You should have received a copy of the GNU Lesser General Public
14 dnl License along with this library; if not, write to the Free Software
15 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 dnl Synopsis : AC_CC_WARNINGS([ANSI])
21 dnl Version : 1.1 (2000/12/31)
22 dnl Author : Ville Laurikari <vl@iki.fi>
24 dnl Enables a reasonable set of warnings for the C compiler.
25 dnl Optionally, if the first argument is nonempty, turns on
26 dnl flags which enforce and/or enable proper ANSI C if such
27 dnl flags are known to the compiler used.
28 dnl Currently this macro knows about GCC, Solaris C compiler,
29 dnl Digital Unix C compiler, C for AIX Compiler, HP-UX C
30 dnl compiler, and IRIX C compiler.
32 AC_DEFUN([AC_CC_WARNINGS], [
34 if test -z "$ansi"; then
35 msg="for C compiler warning flags"
37 msg="for C compiler warning and ANSI conformance flags"
39 AC_CACHE_CHECK($msg, ac_cv_prog_cc_warnings, [
40 if test -n "$CC"; then
41 cat > conftest.c <<EOF
42 int main(int argc, char **argv) { return 0; }
46 if test "$GCC" = "yes"; then
47 if test -z "$ansi"; then
48 ac_cv_prog_cc_warnings="-Wall"
50 ac_cv_prog_cc_warnings="-Wall -ansi -pedantic"
53 dnl Solaris C compiler
54 elif $CC -flags 2>&1 | grep "Xc.*strict ANSI C" > /dev/null 2>&1 &&
55 $CC -c -v -Xc conftest.c > /dev/null 2>&1 &&
56 test -f conftest.o; then
57 if test -z "$ansi"; then
58 ac_cv_prog_cc_warnings="-v"
60 ac_cv_prog_cc_warnings="-v -Xc"
64 elif $CC > /dev/null 2>&1 &&
65 $CC -c -Aa +w1 conftest.c > /dev/null 2>&1 &&
66 test -f conftest.o; then
67 if test -z "$ansi"; then
68 ac_cv_prog_cc_warnings="+w1"
70 ac_cv_prog_cc_warnings="+w1 -Aa"
73 dnl Digital Unix C compiler
74 elif ! $CC > /dev/null 2>&1 &&
75 $CC -c -verbose -w0 -warnprotos -std1 conftest.c > /dev/null 2>&1 &&
76 test -f conftest.o; then
77 if test -z "$ansi"; then
78 ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos"
80 ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1"
83 dnl C for AIX Compiler
84 elif $CC > /dev/null 2>&1 | grep AIX > /dev/null 2>&1 &&
85 $CC -c -qlanglvl=ansi -qinfo=all conftest.c > /dev/null 2>&1 &&
86 test -f conftest.o; then
87 if test -z "$ansi"; then
88 ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd"
90 ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi"
94 elif $CC -fullwarn -ansi -ansiE > /dev/null 2>&1 &&
95 test -f conftest.o; then
96 if test -z "$ansi"; then
97 ac_cv_prog_cc_warnings="-fullwarn"
99 ac_cv_prog_cc_warnings="-fullwarn -ansi -ansiE"
105 if test -n "$ac_cv_prog_cc_warnings"; then
106 CFLAGS="$CFLAGS $ac_cv_prog_cc_warnings"
107 CXXFLAGS="$CXXFLAGS $ac_cv_prog_cc_warnings"
109 ac_cv_prog_cc_warnings="unknown"