Salome HOME
Copyright update 2021
[modules/yacs.git] / src / wrappergen / src / HXX2SALOME_GENERIC_CLASS_NAME_SRC / adm_local / unix / config_files / ac_cc_warnings.m4
1 dnl Copyright (C) 2006-2021  CEA/DEN, EDF R&D
2 dnl
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.
7 dnl
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.
12 dnl
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
16 dnl
17 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 dnl
19
20 dnl Synopsis :    AC_CC_WARNINGS([ANSI]) 
21 dnl Version  :    1.1 (2000/12/31) 
22 dnl Author   :    Ville Laurikari <vl@iki.fi> 
23 dnl Description :
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.
31 dnl
32 AC_DEFUN([AC_CC_WARNINGS], [
33   ansi=$1
34   if test -z "$ansi"; then
35     msg="for C compiler warning flags"
36   else
37     msg="for C compiler warning and ANSI conformance flags"
38   fi
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; }
43 EOF
44
45       dnl GCC
46       if test "$GCC" = "yes"; then
47         if test -z "$ansi"; then
48           ac_cv_prog_cc_warnings="-Wall"
49         else
50           ac_cv_prog_cc_warnings="-Wall -ansi -pedantic"
51         fi
52
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"
59         else
60           ac_cv_prog_cc_warnings="-v -Xc"
61         fi
62
63       dnl HP-UX C compiler
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"
69         else
70           ac_cv_prog_cc_warnings="+w1 -Aa"
71         fi
72
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"
79         else
80           ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1"
81         fi
82
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"
89         else
90           ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi"
91         fi
92
93       dnl IRIX C compiler
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"
98         else
99           ac_cv_prog_cc_warnings="-fullwarn -ansi -ansiE"
100         fi
101
102       fi
103       rm -f conftest.*
104     fi
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"
108     else
109       ac_cv_prog_cc_warnings="unknown"
110     fi
111   ])
112 ])