Salome HOME
NRI : Merge from V1_2.
[modules/kernel.git] / salome_adm / unix / config_files / ac_cc_warnings.m4
1 dnl Synopsis
2 dnl 
3 dnl         AC_CC_WARNINGS([ANSI]) 
4 dnl 
5 dnl Version
6 dnl 
7 dnl         1.1 (2000/12/31) 
8 dnl 
9 dnl Author
10 dnl 
11 dnl         Ville Laurikari <vl@iki.fi> 
12 dnl 
13 dnl Description
14 dnl 
15 dnl         Enables a reasonable set of warnings for the C compiler. 
16 dnl         Optionally, if the first argument is nonempty, turns on 
17 dnl         flags which enforce and/or enable proper ANSI C if such 
18 dnl         flags are known to the compiler used. 
19 dnl 
20 dnl         Currently this macro knows about GCC, Solaris C compiler, 
21 dnl         Digital Unix C compiler, C for AIX Compiler, HP-UX C
22 dnl         compiler, and IRIX C compiler.
23
24 AC_DEFUN([AC_CC_WARNINGS], [
25   ansi=$1
26   if test -z "$ansi"; then
27     msg="for C compiler warning flags"
28   else
29     msg="for C compiler warning and ANSI conformance flags"
30   fi
31   AC_CACHE_CHECK($msg, ac_cv_prog_cc_warnings, [
32     if test -n "$CC"; then
33       cat > conftest.c <<EOF
34 int main(int argc, char **argv) { return 0; }
35 EOF
36
37       dnl GCC
38       if test "$GCC" = "yes"; then
39         if test -z "$ansi"; then
40           ac_cv_prog_cc_warnings="-Wall"
41         else
42           ac_cv_prog_cc_warnings="-Wall -ansi -pedantic"
43         fi
44
45       dnl Solaris C compiler
46       elif $CC -flags 2>&1 | grep "Xc.*strict ANSI C" > /dev/null 2>&1 &&
47            $CC -c -v -Xc conftest.c > /dev/null 2>&1 &&
48            test -f conftest.o; then
49         if test -z "$ansi"; then
50           ac_cv_prog_cc_warnings="-v"
51         else
52           ac_cv_prog_cc_warnings="-v -Xc"
53         fi
54
55       dnl HP-UX C compiler
56       elif $CC > /dev/null 2>&1 &&
57            $CC -c -Aa +w1 conftest.c > /dev/null 2>&1 &&
58            test -f conftest.o; then
59         if test -z "$ansi"; then
60           ac_cv_prog_cc_warnings="+w1"
61         else
62           ac_cv_prog_cc_warnings="+w1 -Aa"
63         fi
64
65       dnl Digital Unix C compiler
66       elif ! $CC > /dev/null 2>&1 &&
67            $CC -c -verbose -w0 -warnprotos -std1 conftest.c > /dev/null 2>&1 &&
68            test -f conftest.o; then
69         if test -z "$ansi"; then
70           ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos"
71         else
72           ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1"
73         fi
74
75       dnl C for AIX Compiler
76       elif $CC > /dev/null 2>&1 | grep AIX > /dev/null 2>&1 &&
77            $CC -c -qlanglvl=ansi -qinfo=all conftest.c > /dev/null 2>&1 &&
78            test -f conftest.o; then
79         if test -z "$ansi"; then
80           ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd"
81         else
82           ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi"
83         fi
84
85       dnl IRIX C compiler
86       elif $CC -fullwarn -ansi -ansiE > /dev/null 2>&1 &&
87            test -f conftest.o; then
88         if test -z "$ansi"; then
89           ac_cv_prog_cc_warnings="-fullwarn"
90         else
91           ac_cv_prog_cc_warnings="-fullwarn -ansi -ansiE"
92         fi
93
94       fi
95       rm -f conftest.*
96     fi
97     if test -n "$ac_cv_prog_cc_warnings"; then
98       CFLAGS="$CFLAGS $ac_cv_prog_cc_warnings"
99       CXXFLAGS="$CXXFLAGS $ac_cv_prog_cc_warnings"
100     else
101       ac_cv_prog_cc_warnings="unknown"
102     fi
103   ])
104 ])