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

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

 



Stefano Sabatini <stefano.sabatini-lala@xxxxxxxx> 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, schwab@xxxxxxx
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."


_______________________________________________
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