Commit | Line | Data |
---|---|---|
d8875586 MBT |
1 | ?RCS: $Id: Prefixit.U 1 2006-08-24 12:32:52Z rmanfredi $ |
2 | ?RCS: | |
3 | ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi | |
4 | ?RCS: | |
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. | |
10 | ?RCS: | |
11 | ?RCS: $Log: Prefixit.U,v $ | |
12 | ?RCS: Revision 3.0.1.1 1995/01/30 14:29:22 ram | |
13 | ?RCS: patch49: created | |
14 | ?RCS: | |
15 | ?X: | |
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 | |
18 | ?X: conditions: | |
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. | |
25 | ?X: | |
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. | |
29 | ?X: | |
30 | ?MAKE:Prefixit: prefix oldprefix | |
31 | ?MAKE: -pick add $@ %< | |
32 | ?LINT:define prefixit | |
33 | ?S:prefixit: | |
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] | |
37 | ?S: eval $prefixit | |
38 | ?S: That will set $dflt to $var or $prefix/dir depending on the | |
39 | ?S: value of $var and $oldprefix. | |
40 | ?S:. | |
41 | ?V:prefixit | |
42 | ?T:tp | |
43 | : set the prefixit variable, to compute a suitable default value | |
44 | prefixit='case "$3" in | |
45 | ""|none) | |
46 | case "$oldprefix" in | |
47 | "") eval "$1=\"\$$2\"";; | |
48 | *) | |
49 | case "$3" in | |
50 | "") eval "$1=";; | |
51 | none) | |
52 | eval "tp=\"\$$2\""; | |
53 | case "$tp" in | |
54 | ""|" ") eval "$1=\"\$$2\"";; | |
55 | *) eval "$1=";; | |
56 | esac;; | |
57 | esac;; | |
58 | esac;; | |
59 | *) | |
60 | eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\""; | |
61 | case "$tp" in | |
62 | --|/*--|\~*--) eval "$1=\"$prefix/$3\"";; | |
63 | /*-$oldprefix/*|\~*-$oldprefix/*) | |
64 | eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";; | |
65 | *) eval "$1=\"\$$2\"";; | |
66 | esac;; | |
67 | esac' | |
68 |