[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ${prefix} expansion in configure.ac ?
From: |
Stepan Kasal |
Subject: |
Re: ${prefix} expansion in configure.ac ? |
Date: |
Mon, 7 Feb 2005 11:28:59 +0100 |
User-agent: |
Mutt/1.4.1i |
Hi,
On Fri, Feb 04, 2005 at 03:58:51PM +0200, Philippe Trottier wrote:
> CPPFLAGS=-I${prefix}/include
> LDFLAGS=-L${exec_prefix}/lib
>
> Is there better way to expand ${prefix} other than using sed ?
yes, use the shell builtin `eval'. The following macro can serve as an
example:
http://www.gnu.org/software/ac-archive/ac_define_dir.html
So you can do this in your configure.ac:
m4_define([DIR_EXISTS],
[prefix_NONE= exec_prefix_NONE=
test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
eval ac_define_dir="\"$1\""
test "$prefix_NONE" && prefix=NONE
test "$exec_prefix_NONE" && exec_prefix=NONE
test -d "$ac_define_dir" dnl
])dnl
And call it as
DIR_EXISTS($includedir) && CPPFLAGS="-I$includedir $CPPFLAGS"
or
AC_MSG_CHECKING([for headers directory])
if DIR_EXISTS($includedir); then
CPPFLAGS="-I$includedir $CPPFLAGS"
AC_MSG_RESULT($includedir)
else
AC_MSG_RESULT(none)
fi
I noticed several slight problems in your code:
> enableval="yes"
...
> if test "$enableval" = "yes" ; then
You should use enable_search_prefix in both cases.
`enableval' is available only in the code given as arguments to
AC_ARG_ENABLE, and even if you set it, enable_search_prefix will
remain unset.
> AC_MSG_CHECKING([prefix for libraries and headers])
...
> AC_MSG_RESULT([yes])
I believe you are too verbose here. Determining the value of one variable,
moreless directly set by the user, doesn't qualify as a `check' in my eyes.
HTH,
Stepan Kasal