Re: ${prefix} expansion in configure.ac ?

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

 



Stepan Kasal wrote:

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 ?


here is something I have noticed, exec_prefix is set to NONE until the end of the config script... now I am thinking to see if it is set at NONE and if it is then set exec_prefix to ${prefix}, and put it back to NONE afterward ... does that make any sense ?

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.


Ok good, for later trouble finding ---

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.


I am more or less trying to find the evil in this, so I got really verbose...

Thank you very much for the help here !

Philippe


_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux