[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ac-archive: ax_cflags_<option> macros...
From: |
Guido Draheim |
Subject: |
ac-archive: ax_cflags_<option> macros... |
Date: |
Mon, 06 Jan 2003 02:37:41 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.1) Gecko/20020826 |
I did lately needed again extensions of the old scheme to add
compiler-specific options. The macros being most in usage
where
ac_prog_cc_warnings.m4 (renamed to) vl_prog_cc_warnings.m4
ac_prog_cc_no_writeable_strings.m4 (needed widely around, and)
ac_check_cc_opt.m4 (to add arbritrary long-options to gcc/others).
Looking at the implementation bits, we see quite different
approaches at detecting the correct option for the compiler
currently under test. An even different scheme can be seen
in the -ansi detection in the autoconf base macros for the
common AC_PROG_CC_STDC
From these, I did start to invent a different detection scheme
that is hopefully generic enough to add step-by-step more
ac-macros that can add compiler-specific options intended for
the same compile-scheme that the programmers want to have.
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)
"-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.
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_...)
http://ac-archive.sf.net/guidod/ax_cflags_warn_all.html
http://ac-archive.sf.net/guidod/ax_cflags_warn_all_ansi.html
http://ac-archive.sf.net/guidod/ax_cflags_strict_prototypes.html
http://ac-archive.sf.net/guidod/ax_cflags_no_writable_strings.html
hints? comments? objections? ;-)
-- cheers, guido http://ac-archive.sf.net
- ac-archive: ax_cflags_<option> macros...,
Guido Draheim <=