autoconf
[Top][All Lists]
Advanced

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

Re: How to substitute variables in script files? (Why is $prefix set to


From: Andreas Schwab
Subject: Re: How to substitute variables in script files? (Why is $prefix set to NONE?)
Date: Thu, 01 Mar 2007 23:15:30 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux)

Stefano Sabatini <address@hidden> writes:

> Follow a possible implementation of this suggestion:
>
> to put in the input Perl script "script.in" something as:
> my $prefix="@prefix@";
> ...
> my $system_config_file= "@SYSCONF_DIR@/script.conf"; 
>
> In the resulting "script" file, prefix will be expanded to something as
> "/usr/local", while the last line will appear as:
>
> my $system_config_file= "${prefix}/etc/script.conf"; 
>
> It happens that *accidentally* the ${prefix} notation is understood by
> Perl, so the script will perform *running time* the right
> substitution.

These substitutions are designed to be used in a makefile where the
variables are recursively expanded.

> Unfortunately it's rather ad-hoc solution and not very clear from the
> point of view of the script.in reader, and it's not applicable to
> other scripting languages that don't support that particular
> shell-like syntax (e.g. lisp).

For other languages besided makefiles it is recommended to do the
substitution not during configuration, but at build time using the
recursively expanded values in the makefile.

> 2) So the corresponding solution will be:
>
> to put in configure.ac:
>
> SYSCONF_DIR=`test "$prefix" = NONE && prefix=$ac_default_prefix; eval echo 
> "${sysconfdir}"`

The problem with this approach is that the value is not recursively
expanded.  The second level expansion could still refer to other
variables.  For example, a recent addition to autoconf is the datarootdir
variable, and datadir is now defined in terms of datarootdir, which in
turn is defined in terms of prefix.  A two level expansion of datadir will
no loger lead to a fully expanded value.

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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