automake
[Top][All Lists]
Advanced

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

Re: Specifying AM_CPPFLAGS from within configure.ac


From: Ralf Wildenhues
Subject: Re: Specifying AM_CPPFLAGS from within configure.ac
Date: Fri, 3 Jun 2005 10:10:44 +0200
User-agent: Mutt/1.4.1i

Hi Jirko, Stepan,

* Stepan Kasal wrote on Fri, Jun 03, 2005 at 08:44:48AM CEST:
> 
> Regarding your macro MY_CXX_OPTION, if you want to be really portable,
> things can get even more scary.

This thread[1] contains a couple more hints.  :)

> I think the definition of your macro can be improved.
> Here is the new version:
> 
> AC_DEFUN([MY_CXX_OPTION],
> [AC_CACHE_CHECK([for $2], [epos_cv_cxx_opt_$1],
> [cat > conftest.cc <<EOF
> #include <stdio.h>
> int main(int argc, char **argv)
> {
> argc=argc; argv=argv; return 0;
> }

If what you want is to avoid warnings, then Libtool experience tells:
It's impossible.  There will always be a compiler which warns about your
code.  Your assignments, for example, won't keep some compilers from
recognizing that the values of `argc' and `argv' are never used.

Some (esp. commercial) compilers have the habit of outputting a boiler
plate each time they are called.  With some there even is no option to
turn this off!  Also please note that generally, you cannot try
compilation when omitting the user-specified CXXFLAGS and CPPFLAGS..

> EOF
> epos_cv_cxx_opt_$1=unknown
> for opt in $3; do
>     ${CXX} ${opt} -o conftest conftest.cc 2>conftest2 1>&5 || continue

as you do here.  For example, on some Solaris system, omitting -xarch=v9
(which the user will have put in CXXFLAGS) will produce warnings and may
cause compilation to fail even.  Surely one could argue such flags
belong in $CXX proper, but that's not the nicest treatment of users.

Also, the options may depend on each other (and on options given in
CXXFLAGS/CPPFLAGS), so you should document your macro to not use the
ones given in $1 in sequence.

>     msg=`cat conftest2`
>     if test -z "$msg"; then
>         epos_cv_cxx_opt_$1=$opt
>       break
>     fi
> done
> rm -f conftest conftest2 conftest.cc])
> if test "x${epos_cv_cxx_opt_$1}" = xunknown; then
>         $1=
> else
>         $1=$epos_cv_cxx_opt_$1
> fi])

Regards,
Ralf

[1] http://lists.gnu.org/archive/html/libtool-patches/2005-04/msg00080.html




reply via email to

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