1 dnl Synopsis : AC_CC_WARNINGS([ANSI])
2 dnl Version : 1.1 (2000/12/31)
3 dnl Author : Ville Laurikari <vl@iki.fi>
5 dnl Enables a reasonable set of warnings for the C compiler.
6 dnl Optionally, if the first argument is nonempty, turns on
7 dnl flags which enforce and/or enable proper ANSI C if such
8 dnl flags are known to the compiler used.
9 dnl Currently this macro knows about GCC, Solaris C compiler,
10 dnl Digital Unix C compiler, C for AIX Compiler, HP-UX C
11 dnl compiler, and IRIX C compiler.
13 AC_DEFUN([AC_CC_WARNINGS], [
15 if test -z "$ansi"; then
16 msg="for C compiler warning flags"
18 msg="for C compiler warning and ANSI conformance flags"
20 AC_CACHE_CHECK($msg, ac_cv_prog_cc_warnings, [
21 if test -n "$CC"; then
22 cat > conftest.c <<EOF
23 int main(int argc, char **argv) { return 0; }
27 if test "$GCC" = "yes"; then
28 if test -z "$ansi"; then
29 ac_cv_prog_cc_warnings="-Wall"
31 ac_cv_prog_cc_warnings="-Wall -ansi -pedantic"
34 dnl Solaris C compiler
35 elif $CC -flags 2>&1 | grep "Xc.*strict ANSI C" > /dev/null 2>&1 &&
36 $CC -c -v -Xc conftest.c > /dev/null 2>&1 &&
37 test -f conftest.o; then
38 if test -z "$ansi"; then
39 ac_cv_prog_cc_warnings="-v"
41 ac_cv_prog_cc_warnings="-v -Xc"
45 elif $CC > /dev/null 2>&1 &&
46 $CC -c -Aa +w1 conftest.c > /dev/null 2>&1 &&
47 test -f conftest.o; then
48 if test -z "$ansi"; then
49 ac_cv_prog_cc_warnings="+w1"
51 ac_cv_prog_cc_warnings="+w1 -Aa"
54 dnl Digital Unix C compiler
55 elif ! $CC > /dev/null 2>&1 &&
56 $CC -c -verbose -w0 -warnprotos -std1 conftest.c > /dev/null 2>&1 &&
57 test -f conftest.o; then
58 if test -z "$ansi"; then
59 ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos"
61 ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1"
64 dnl C for AIX Compiler
65 elif $CC > /dev/null 2>&1 | grep AIX > /dev/null 2>&1 &&
66 $CC -c -qlanglvl=ansi -qinfo=all conftest.c > /dev/null 2>&1 &&
67 test -f conftest.o; then
68 if test -z "$ansi"; then
69 ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd"
71 ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi"
75 elif $CC -fullwarn -ansi -ansiE > /dev/null 2>&1 &&
76 test -f conftest.o; then
77 if test -z "$ansi"; then
78 ac_cv_prog_cc_warnings="-fullwarn"
80 ac_cv_prog_cc_warnings="-fullwarn -ansi -ansiE"
86 if test -n "$ac_cv_prog_cc_warnings"; then
87 CFLAGS="$CFLAGS $ac_cv_prog_cc_warnings"
88 CXXFLAGS="$CXXFLAGS $ac_cv_prog_cc_warnings"
90 ac_cv_prog_cc_warnings="unknown"