autoconf
[Top][All Lists]
Advanced

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

Re: ac-archive: ax_cflags_<option> macros...


From: Ville Laurikari
Subject: Re: ac-archive: ax_cflags_<option> macros...
Date: Mon, 6 Jan 2003 11:45:28 +0200
User-agent: Mutt/1.4i

I'm not on the autoconf list so excuse me for possibly repeating stuff
that has been on the list already.  Also, if you want me to reply, CC
your list replies to me as well.

On Mon, Jan 06, 2003 at 02:37:41AM +0100, Guido Draheim wrote:

> It basically picks up the for-list scheme from AC_PROG_CC_STDC
> and extends it - the list items contain "%" separator marks
> that will mark breaks in the option strings. Each option to
> be tested has a _selector test_ - in other words, all compilers
> but one shall error-out on these selectors. The selector
> options however will not be part of the resulting option
> string for the feature that is wished for.
> 
> These selector-tests are usually derived from the different
> schemes that enable ansi-constraints for the compilers, now
> just have a look at the following example take up from
> ax_cflags_warn_all.m4
> 
>  AC_LANG_SAVE
>  AC_LANG_C
>  ac_save_CFLAGS="$CFLAGS"
> for ac_arg dnl
> in "-pedantic  % -Wall"       dnl   GCC
>    "-xstrconst % -v"          dnl Solaris C
>    "-std1      % -verbose -w0 -warnprotos" dnl Digital Unix
>    "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
>    "-ansi -ansiE % -fullwarn" dnl IRIX
>    "+ESlit     % +w1"         dnl HP-UX C
>    "-Xc        % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)

The comma was quoted in my macro against m4 confusing it for a macro
argument separator.  So this line should likely read:
     "-Xc        % -pvctl,fullmsg" dnl NEC SX-5 (Super-UX 10)

>    "-h conform % -h msglevel 2" dnl Cray C (Unicos)
>    #
> do CFLAGS="$ac_save_CFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
>    AC_TRY_COMPILE([],[return 0;],
>    [ac_cv_cflags_warn_all=`echo $ac_arg | sed -e 's,.*% *,,'`
>    break])
> done
>  CFLAGS="$ac_save_CFLAGS"
>  AC_LANG_RESTORE
> 
> The reason: some compilers will happily accept "-v" or "+w1" for
> something not intended - they are valid but they do not do what
> we want, to just enable additional warning-options.

Have there been problems with the way vl_prog_cc_warnings works?  At
least I haven't heard about it... :)

I'm not 100% sure now but I remember seeing a compiler somewhere that
basically ignored any options it didn't recognize (gave a warning
message about them though) and went ahead with whatever options it
found.  So even with selector tests we cannot be sure that some
compiler somewhere doesn't do something weird when being tested for
options.  This is why I decided to go with grepping version strings
first to avoid trouble since there are less chances of getting "cc -v"
to do something drastic than "cc -some -option -for -some -compiler".


> With this scheme, I have reworked the existing macros that I do
> use widely to pick up this detection, and furthermore I did change
> them all to a common result-scheme - they add to CFLAGS or CXXFLAGS
> when no output-variable has been given as an argument. Note that
> each of the following files contains two macros, one for adding to
> CFLAGS (AX_CFLAGS_...) and one for C++ flags (AX_CXXFLAGS_...)

Seems good to me.  Maybe we could go one step further and just
generate some generic compiler identifier string which could then be
used for anything, be it compiler options or something else...
AX_PROG_CC_FLAVOR or something, sort of like config.guess but for
compilers.   This could then be used in other macros to do the dirty
work, and there would be only one place to update when compilers
change.

It's good that your macro names are prefixed with ax_ instead of ac_
or a personal prefix (like guido_).  People feel that ax_ or ac_ -macros
are "more official" than macros prefixed with just some guy's
initials, and are more likely to use them.  But the ac_ prefix is
reserved for official autoconf macros, right?

Some of my original macros have the ac_ prefix, and I later renamed
them to have the vl_ prefix so as not to pollute the official macro
namespace with my silly inventions.  I was flamed for this of course
(I wasn't aware of just how widely used some of the macros had become
and I made life a little harder for some people).   


-- 
http://www.iki.fi/vl/





reply via email to

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