summaryrefslogtreecommitdiff
path: root/mcon/U/Extract.U
blob: d01d3244b6df83c549cdd21e1fa56a1ca3abf191 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
?RCS: $Id$
?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: Extract.U,v $
?RCS: Revision 3.0.1.2  1997/02/28  14:58:52  ram
?RCS: patch61: added support for src.U
?RCS:
?RCS: Revision 3.0.1.1  1994/10/29  15:51:46  ram
?RCS: patch36: added ?F: line for metalint file checking
?RCS:
?RCS: Revision 3.0  1993/08/18  12:04:52  ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
?X: 
?X: This unit produces a shell script which can be doted in order to extract
?X: .SH files with variable substitutions.
?X:
?X: When running Configure from a remote directory ($src is not '.'),
?X: then the files will be created in that directory, so beware!
?X: 
?MAKE:Extract: Mkdirp src
?MAKE:	-pick add $@ %<
?F:./extract
?T:CONFIG SRC dir file
: script used to extract .SH files with variable substitutions
cat >extract <<EOS
CONFIG=true
SRC="$src"
EOS
cat >>extract <<'EOS'
echo "Doing variable substitutions on .SH files..."
if test -f "$SRC/MANIFEST"; then
	set x `awk '{print $1}' <$SRC/MANIFEST | grep '\.SH'`
else
	echo "(Looking for .SH files under the source directory.)"
	set x `(cd "$SRC"; find . -name "*.SH" -print)`
fi
shift
case $# in
0) set x `(cd "$SRC"; echo *.SH)`; shift;;
esac
if test ! -f "$SRC/$1"; then
	shift
fi
for file in $*; do
	case "$SRC" in
	".")
		case "$file" in
		*/*)
			dir=`expr X$file : 'X\(.*\)/'`
			file=`expr X$file : 'X.*/\(.*\)'`
			(cd $dir && . ./$file)
			;;
		*)
			. ./$file
			;;
		esac
		;;
	*)
?X:
?X: When running Configure remotely ($src is not '.'), we cannot source
?X: the files directly, since that would wrongly cause the extraction
?X: where the source lie instead of withing the current directory. Therefore,
?X: we need to 'sh <file' then, which is okay since they will source the
?X: existing config.sh file. It's not possible to use:
?X:		../src/Configure -S -O -Dsomething
?X: unfortunately since no new config.sh with the -Dsomething override
?X: will be created before running the .SH files. A minor buglet.
?X:
?X: Note that we must create the directory hierarchy ourselves if it does
?X: not exist already, and that is done through a shell emulation of the
?X: 'mkdir -p' command. We don't want to use the $installdir metaconfig
?X: symbol here since that would require too much to be configured for
?X: this simple extraction task that may happen quickly with 'Configure -S'.
?X:		-- RAM, 18/03/96
?X:
		case "$file" in
		*/*)
			dir=`expr X$file : 'X\(.*\)/'`
			file=`expr X$file : 'X.*/\(.*\)'`
			./mkdirp $dir
			sh <"$SRC/$dir/$file"
			;;
		*)
			sh <"$SRC/$file"
			;;
		esac
		;;
	esac
done
if test -f "$SRC/config_h.SH"; then
	if test ! -f config.h; then
?X: oops, they left it out of MANIFEST, probably, so do it anyway.
		sh <"$SRC/config_h.SH"
	fi
fi
EOS