> I'm trying to write a pair of macros to enable strict ansi conformance mode > and all vaguely useful warnings for at least my target platforms: > > * AIX with Visualage for C++ C compiler (xlc_r) > * Solaris with Sun's ANSI C compiler (cc) > * HP-UX with HP's C compiler (cc) > * Linux with GCC
I am far from being expert in autoconf/automake. But I just tackled that same problem not too terribly long ago. This is what I came up with. It is probably wrong for a number of reasons. I would welcome a critique from the list. Note that I am using autoconf and automake together and so do have the automake macros available. AM_PROG_CC_STDC if test "$am_cv_prog_cc_stdc" = "no" then echo "Error: Compiler is not ANSI." 1>&2 exit 1 fi if test -z "$CC" then echo "Error: No Compiler found." 1>&2 exit 1 fi I don't like the above because I reached into the internals of the automake macros to get am_prog_cc_stdc. But I found no other way. But since I am generating the confiure script I can guarentee that they are consistent. And the failure mode is not too terrible regardless. As you can see this is not looking for maximal portability to pre-ANSI systems. It just wants to correctly diagnose a non-ANSI system and state it right up front. This is drift. But then if the compiler found is gcc I can turn on more specific gcc warnings. But if not then do nothing. AC_MSG_CHECKING(for maximum warning verbosity options) if test "$GCC" = "yes" then ac_compile_warnings_opt='-Wall -Wmissing-prototypes -Wstrict-prototypes' CFLAGS="$CFLAGS $ac_compile_warnings_opt" fi ac_compile_warnings_msg="$ac_compile_warnings_msg $ac_compile_warnings_opt for C" AC_MSG_RESULT($ac_compile_warnings_msg) unset ac_compile_warnings_msg unset ac_compile_warnings_opt > The problem is what to do to differentiate between the Sun and HP cc's. The above fragment works fine on the HP systems. Not with the bundled crippled compiler but an ANSI C compiler installed. But I have not tested it in the case that neither the HP ANSI C compiler nor the gcc compilers are installed. I assume it would work on a Sun as well. As you can see nothing in the code says anything particular about either system. > I haven't even considered looking at uname and relying on the kernel > architecture since that breaks the philosophy of autoconf. Good. I hate it when people do that. I am now compiling for ia64 and even if only the config.guess and config.sub files need to be updated it is still a pain. But when I have to dig through configure scripts to tweak the architecture checks around then I am really in a world of hurt. Because usually then I need a specific version of autoconf to regenerate. In which case I usually just bypass and edit the generated configure. The programs that avoid those architecture checks usually work out of the box without modification. Bob