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