1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
dnl @synopsis VL_PROG_CC_WARNINGS([ANSI])
dnl
dnl Enables a reasonable set of warnings for the C compiler.
dnl Optionally, if the first argument is nonempty, turns on flags which
dnl enforce and/or enable proper ANSI C if such are known with the
dnl compiler used.
dnl
dnl Currently this macro knows about GCC, Solaris C compiler, Digital
dnl Unix C compiler, C for AIX Compiler, HP-UX C compiler, IRIX C
dnl compiler, NEC SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos
dnl 10.0.0.8) C compiler.
dnl
dnl @category C
dnl @author Ville Laurikari <vl@iki.fi>
dnl @version 2002-04-04
dnl @license AllPermissive
AC_DEFUN([VL_PROG_CC_WARNINGS], [
ansi=$1
if test -z "$ansi"; then
msg="for C compiler warning flags"
else
msg="for C compiler warning and ANSI conformance flags"
fi
AC_CACHE_CHECK($msg, vl_cv_prog_cc_warnings, [
if test -n "$CC"; then
cat > conftest.c <<EOF
int main(int argc, char **argv) { return 0; }
EOF
dnl GCC
if test "$GCC" = "yes"; then
if test -z "$ansi"; then
vl_cv_prog_cc_warnings="-Wall"
else
vl_cv_prog_cc_warnings="-Wall -ansi -pedantic"
fi
dnl Most compilers print some kind of a version string with some command
dnl line options (often "-V"). The version string should be checked
dnl before doing a test compilation run with compiler-specific flags.
dnl This is because some compilers (like the Cray compiler) only
dnl produce a warning message for unknown flags instead of returning
dnl an error, resulting in a false positive. Also, compilers may do
dnl erratic things when invoked with flags meant for a different
dnl compiler.
dnl Solaris C compiler
elif $CC -V 2>&1 | grep -i "WorkShop" > /dev/null 2>&1 &&
$CC -c -v -Xc conftest.c > /dev/null 2>&1 &&
test -f conftest.o; then
if test -z "$ansi"; then
vl_cv_prog_cc_warnings="-v"
else
vl_cv_prog_cc_warnings="-v -Xc"
fi
dnl Digital Unix C compiler
elif $CC -V 2>&1 | grep -i "Digital UNIX Compiler" > /dev/null 2>&1 &&
$CC -c -verbose -w0 -warnprotos -std1 conftest.c > /dev/null 2>&1 &&
test -f conftest.o; then
if test -z "$ansi"; then
vl_cv_prog_cc_warnings="-verbose -w0 -warnprotos"
else
vl_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1"
fi
dnl C for AIX Compiler
elif $CC 2>&1 | grep -i "C for AIX Compiler" > /dev/null 2>&1 &&
$CC -c -qlanglvl=ansi -qinfo=all conftest.c > /dev/null 2>&1 &&
test -f conftest.o; then
if test -z "$ansi"; then
vl_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd"
else
vl_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi"
fi
dnl IRIX C compiler
elif $CC -version 2>&1 | grep -i "MIPSpro Compilers" > /dev/null 2>&1 &&
$CC -c -fullwarn -ansi -ansiE conftest.c > /dev/null 2>&1 &&
test -f conftest.o; then
if test -z "$ansi"; then
vl_cv_prog_cc_warnings="-fullwarn"
else
vl_cv_prog_cc_warnings="-fullwarn -ansi -ansiE"
fi
dnl HP-UX C compiler
elif what $CC 2>&1 | grep -i "HP C Compiler" > /dev/null 2>&1 &&
$CC -c -Aa +w1 conftest.c > /dev/null 2>&1 &&
test -f conftest.o; then
if test -z "$ansi"; then
vl_cv_prog_cc_warnings="+w1"
else
vl_cv_prog_cc_warnings="+w1 -Aa"
fi
dnl The NEC SX-5 (Super-UX 10) C compiler
elif $CC -V 2>&1 | grep "/SX" > /dev/null 2>&1 &&
$CC -c -pvctl[,]fullmsg -Xc conftest.c > /dev/null 2>&1 &&
test -f conftest.o; then
if test -z "$ansi"; then
vl_cv_prog_cc_warnings="-pvctl[,]fullmsg"
else
vl_cv_prog_cc_warnings="-pvctl[,]fullmsg -Xc"
fi
dnl The Cray C compiler (Unicos)
elif $CC -V 2>&1 | grep -i "Cray" > /dev/null 2>&1 &&
$CC -c -h msglevel 2 conftest.c > /dev/null 2>&1 &&
test -f conftest.o; then
if test -z "$ansi"; then
vl_cv_prog_cc_warnings="-h msglevel 2"
else
vl_cv_prog_cc_warnings="-h msglevel 2 -h conform"
fi
fi
rm -f conftest.*
fi
if test -n "$vl_cv_prog_cc_warnings"; then
CFLAGS="$CFLAGS $vl_cv_prog_cc_warnings"
else
vl_cv_prog_cc_warnings="unknown"
fi
])
])dnl
|