1 ?RCS: $Id: Prefixit.U 1 2006-08-24 12:32:52Z rmanfredi $
3 ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 4.0.
11 ?RCS: $Log: Prefixit.U,v $
12 ?RCS: Revision 3.0.1.1 1995/01/30 14:29:22 ram
13 ?RCS: patch49: created
16 ?X: Used as: "set dflt var dir; eval $prefixit" to set $dflt to be
17 ?X: $prefix/dir by default, or the previous $var depending on certain
19 ?X: - If the $oldprefix variable is empty, then $prefix holds the same
20 ?X: value as on previous runs. Therefore, reuse $var if set, otherwise
21 ?X: set $dflt to $prefix/dir.
22 ?X: - If $oldprefix is not empty, then set $dflt to $prefix/dir if $var
23 ?X: is empty (first run). Otherwise, if $var is $oldprefix/dir, then
24 ?X: change it to $prefix/dir. If none of the above, reuse the old $var.
26 ?X: When dir is omitted, the dflt variable is set to $var if prefix did not
27 ?X: change, to an empty value otherwise. If dir=none, then a single space
28 ?X: in var is kept as-is, even if the prefix changes.
30 ?MAKE:Prefixit: prefix oldprefix
31 ?MAKE: -pick add $@ %<
34 ?S: This shell variable is used internally by Configure to reset
35 ?S: the leading installation prefix correctly when it is changed.
36 ?S: set dflt var [dir]
38 ?S: That will set $dflt to $var or $prefix/dir depending on the
39 ?S: value of $var and $oldprefix.
43 : set the prefixit variable, to compute a suitable default value
44 prefixit='case "$3" in
47 "") eval "$1=\"\$$2\"";;
54 ""|" ") eval "$1=\"\$$2\"";;
60 eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
62 --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
63 /*-$oldprefix/*|\~*-$oldprefix/*)
64 eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
65 *) eval "$1=\"\$$2\"";;