[Top][All Lists]

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

Re: Adding $includedir and $libdir in CPPFLAGS and LDFLAGS

From: John D. Burger
Subject: Re: Adding $includedir and $libdir in CPPFLAGS and LDFLAGS
Date: Fri, 28 Dec 2001 11:34:46 -0500

Alexandre Duret-Lutz wrote:

>  John> I've tried:

>  John> AC_INIT(libspec, 1.0, address@hidden)
>  John> CPPFLAGS="-I$includedir $CPPFLAGS"
>  John> LDFLAGS="-L$libdir $LDFLAGS"
>  John> ...

>  John> but this doesn't quite work - ac_cpp and friends end up with an
>  John> unexpanded ${prefix} or ${exec_prefix}, I believe.
> Appart from the `NONE' stuff, is that a problem?
> IIRC autoconf will `eval' any call to ac_cpp and friends.

You're right - I was confused.  I had earlier decided that
${exec_prefix} wasn't being expanded properly in the eval of ac_cpp,
because I didn't know about the default value of "NONE".

> Aside: you may want to protect your code against the following
> issue described in the GCC manual:
> |   * Use of `-I/usr/include' may cause trouble.

Yow - I would like to protect against that.

> You might also like

I do like that, although I will be dealing with pretty unsophisticated
users - I'd like to just tell them about -prefix.  Here's what I've come
up with:

  eval test -d $includedir && CPPFLAGS="-I$includedir $CPPFLAGS"

  eval jb_expanded_libdir=$libdir
  jb_expanded_libdir=`echo $jb_expanded_libdir | sed "s%^NONE%$prefix%"`
  eval test -d $jb_expanded_libdir && LDFLAGS="-L$libdir $LDFLAGS"

I decided not to simply replace NONE with the appropriate values, as in
the code I pointed to earlier:

I'm leaving NONE in for prefix in order to implicitly deal with the
issue described in the GCC manual.  I realize that if the user has a
NONE/include or NONE/lib subdirectory, I will be screwed, but barring
that, nothing will be added to the CPPFLAGS unless the user configures
with -includedir or -prefix, and similarly for LDFLAGS.  I guess I
really should check for NONE explicitly ...

The expanded_libdir business is because I =do= want to change NONE to
$prefix in the case of exec_prefix.

This is my first experience with configure hacking, and indeed my most
substantial sh code to date, believe it or not, so any criticisms are


- John Burger

reply via email to

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