Salome HOME
Epuration des éléments obsolètes après analyse de la procédure de construction.
[modules/kernel.git] / salome_adm / unix / config_files / ac_cc_warnings.m4
1 dnl  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 dnl  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 dnl 
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. 
8 dnl 
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. 
13 dnl 
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 
17 dnl 
18 dnl  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19 dnl
20 dnl
21 dnl
22 dnl Synopsis :    AC_CC_WARNINGS([ANSI]) 
23 dnl 
24 dnl Version  :    1.1 (2000/12/31) 
25 dnl 
26 dnl Author   :    Ville Laurikari <vl@iki.fi> 
27 dnl 
28 dnl Description :
29 dnl 
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. 
34 dnl 
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.
38
39 AC_DEFUN([AC_CC_WARNINGS], [
40   ansi=$1
41   if test -z "$ansi"; then
42     msg="for C compiler warning flags"
43   else
44     msg="for C compiler warning and ANSI conformance flags"
45   fi
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; }
50 EOF
51
52       dnl GCC
53       if test "$GCC" = "yes"; then
54         if test -z "$ansi"; then
55           ac_cv_prog_cc_warnings="-Wall"
56         else
57           ac_cv_prog_cc_warnings="-Wall -ansi -pedantic"
58         fi
59
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"
66         else
67           ac_cv_prog_cc_warnings="-v -Xc"
68         fi
69
70       dnl HP-UX C compiler
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"
76         else
77           ac_cv_prog_cc_warnings="+w1 -Aa"
78         fi
79
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"
86         else
87           ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1"
88         fi
89
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"
96         else
97           ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi"
98         fi
99
100       dnl IRIX C compiler
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"
105         else
106           ac_cv_prog_cc_warnings="-fullwarn -ansi -ansiE"
107         fi
108
109       fi
110       rm -f conftest.*
111     fi
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"
115     else
116       ac_cv_prog_cc_warnings="unknown"
117     fi
118   ])
119 ])