AC-Archive
Autoconf Macro Archive

ac-archive.sf.net: - Project CVS - Download
Macro Index
- AM Support
- C++ Support
- C Support
- Fortran Support
- Java Support
- Cross Compilation
- Installed Packages
- Miscellaneous
- LaTeX Support
- Uncategorized
- archive macros
- adl's macros
- bkorb's macros
- guidod's macros
- latex's macros
- other's macros
- rleigh's macros
- obsoleted macros
- released macros
- search index

Documentation
- Contribute!
- History
- acincludedir m4
- acinclude (tool)
- macro howto
- ax tricks
- maintainers
- License
- Topics

generated...
2007-08-05

(C) 2007 guidod
Download the M4 Source.

vl_prog_cc_warnings

Back to the Main Page.

Synopsis
VL_PROG_CC_WARNINGS([ANSI])
, 
Version

2002-04-04

Author

Ville Laurikari <vl@iki.fi>

License

AllPermissive
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. Users of this software should generally follow the principles of the MIT License includings its disclaimer.

Category

cryp.to ac-archive's C Support (released)

Documentation

Enables a reasonable set of warnings for the C compiler. Optionally, if the first argument is nonempty, turns on flags which enforce and/or enable proper ANSI C if such are known with the compiler used.

Currently this macro knows about GCC, Solaris C compiler, Digital Unix C compiler, C for AIX Compiler, HP-UX C compiler, IRIX C compiler, NEC SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos 10.0.0.8) C compiler.

M4 Source Code
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 &gt; conftest.c &lt;&lt;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&gt;&amp;1 | grep -i "WorkShop" &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           $CC -c -v -Xc conftest.c &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           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&gt;&amp;1 | grep -i "Digital UNIX Compiler" &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           $CC -c -verbose -w0 -warnprotos -std1 conftest.c &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           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&gt;&amp;1 | grep -i "C for AIX Compiler" &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           $CC -c -qlanglvl=ansi -qinfo=all conftest.c &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           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&gt;&amp;1 | grep -i "MIPSpro Compilers" &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           $CC -c -fullwarn -ansi -ansiE conftest.c &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           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&gt;&amp;1 | grep -i "HP C Compiler" &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           $CC -c -Aa +w1 conftest.c &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           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&gt;&amp;1 | grep "/SX" &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           $CC -c -pvctl[,]fullmsg -Xc conftest.c &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           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&gt;&amp;1 | grep -i "Cray" &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           $CC -c -h msglevel 2 conftest.c &gt; /dev/null 2&gt;&amp;1 &amp;&amp;
           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