bug-gnulib
[Top][All Lists]
Advanced

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

Re: Using gl_ABSOLUTE_HEADER after AC_CHECK_HEADER breaks CPPFLAGS


From: Bruno Haible
Subject: Re: Using gl_ABSOLUTE_HEADER after AC_CHECK_HEADER breaks CPPFLAGS
Date: Fri, 15 Aug 2008 00:08:58 +0200
User-agent: KMail/1.5.4

Hello,

Rhys Ulerich wrote:
> AC_INIT(recreate, 0.0.1, address@hidden)
> > AM_CONFIG_HEADER(config.h)
> > AM_INIT_AUTOMAKE(1.9 -Wall -Werror foreign)
> > AC_PREREQ([2.61])
> >
> > AC_DEFUN([AX_TRILINOS_BASE],[
> >     if test -n "${TRILINOS_HOME}"; then
> 
>        CPPFLAGS="-I${TRILINOS_HOME}/include $CPPFLAGS"
> >     fi
> >
> >     AC_MSG_NOTICE([DEBUG: CPPFLAGS=${CPPFLAGS}])
> >     AC_CHECK_HEADER([Trilinos_version.h],[found_header=yes])
> >
> >     if test "$found_header" = yes; then
> >         gl_ABSOLUTE_HEADER([Trilinos_version.h])
> >         AC_DEFINE(HAVE_TRILINOS,1,[Define if Trilinos is available])
> >     else
> >         AC_MSG_ERROR([Trilinos_version.h not found])
> >     fi
> > ])
> > AX_TRILINOS_BASE
> >
> > AC_CONFIG_FILES([
> >     Makefile
> > ])
> > AC_OUTPUT()

You need to bear in mind two things:
  - Even the most innocent looking macro invocation can expand into something
    that does an AC_REQUIRE([SOMETHING]). The SOMETHING macro then gets
    expanded before the _outermost_ autoconf macro invocation. In your case
    it's before the AX_TRILINOS_BASE macro.
  - Lots of tests use the value of CPPFLAGS. Therefore if want to modify
    CPPFLAGS, you need to do it as early as possible. In particular, before
    any gnulib macros. The best place to do that is in configure.ac, right
    after AC_PROG_CC.

> To workaround the issue, choose any of:
> 
>    1. Remove gl_ABSOLUTE_HEADER([Trilinos_version.h]) from AX_TRILINOS_BASE
>    2. Move the gl_ABSOLUTE_HEADER call outside of AX_TRILINOS_BASE into the
>    toplevel configure.ac.
>    3. Move the gl_ABSOLUTE_HEADER call into a separate function that isn't
>    AX_TRILINOS_BASE.  But, you cannot call the new, separate function from
>    within AX_TRILINOS_BASE otherwise you hit the same issue.

Not sufficient.

>    4. Remove the function AX_TRILINOS_BASE and just dump the function's code
>    into the main configure.ac file.

That's ok. A lighter solution is:

     4a. Move the CPPFLAGS modifying code into your configure.ac, early after
     AC_PROG_CC.

Bruno





reply via email to

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