[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: compiler specific cflags

From: Bob Proulx
Subject: Re: compiler specific cflags
Date: Sun, 20 Oct 2002 14:37:20 -0600
User-agent: Mutt/1.4i

Tom Tromey <address@hidden> [2002-10-20 12:29:03 -0600]:
> >>>>> "Sean" == Sean MacLennan <address@hidden> writes:
> Sean> I want to set the -Wall flags iff the compiler supports it
> Sean> (i.e. is gcc). How do I do this? Specifically checking for gcc
> Sean> is fine.
> In configure, if the compiler is gcc, then put the flags you want into
> AM_CFLAGS.  Then AC_SUBST this.
> Read about AC_PROG_CC to see how to check whether gcc is in use.
> There's a pre-existing variable.

Although this is an autoconf issue not an automake issue there is some
overlap.  This is what I have to solve this problem.

AFAIK the AM_PROG_CC_STDC test won't fail if it can't find an ansi
compiler.  It will just try to find one.  Since I do not desire to
support a non-ansi compiler with my project I do want to fail and
therefore force the issue at the earliest possible time.

The GCC is set if the compiler is GCC.  In that case I can add more
options to the list.  This does not seem as good as testing that a
found compiler supports an option such as -Wall and then using -Wall.
Any way to do that?

  if test "$am_cv_prog_cc_stdc" = "no"
    echo "Error: Compiler is not ANSI." 1>&2
    exit 1
  AC_MSG_CHECKING(for maximum warning verbosity options)
  if test "$GCC" = "yes"
    ac_compile_warnings_opt="-Wall -Wmissing-prototypes -Wstrict-prototypes"
    CFLAGS="$CFLAGS $ac_compile_warnings_opt"
  ac_compile_warnings_msg="$ac_compile_warnings_msg $ac_compile_warnings_opt 
for C"
  unset ac_compile_warnings_msg
  unset ac_compile_warnings_opt

Which produces lines like this on systems using GCC.

  checking whether we are using the GNU C compiler... yes
  checking whether gcc accepts -g... yes
  checking for style of include used by make... GNU
  checking dependency style of gcc... gcc
  checking for gcc option to accept ANSI C... none needed
  checking for maximum warning verbosity options...  -Wall -Wmissing-prototypes 
-Wstrict-prototypes for C
  checking for ranlib... ranlib

  configure:2144: checking for maximum warning verbosity options
  configure:2152: result:  -Wall -Wmissing-prototypes -Wstrict-prototypes for C

Any comments or improvements?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]