summaryrefslogtreecommitdiff
path: root/mcon/U/Loc.U
blob: 6d6a5d0a897b4d0e0cf0efaf06f00bb7fb2e488a (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
?RCS: $Id$
?RCS:
?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
?RCS:
?RCS: You may redistribute only under the terms of the Artistic License,
?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 License; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?RCS: $Log: Loc.U,v $
?RCS: Revision 3.0.1.10  1997/02/28  15:04:16  ram
?RCS: patch61: allow users to specify paths on the command line
?RCS: patch61: will now substitute cp for ln if not supported
?RCS:
?RCS: Revision 3.0.1.9  1995/09/25  09:11:24  ram
?RCS: patch59: commented the purpose of the #un-def directive
?RCS: patch59: abort Configure run when mandatory command is missing
?RCS:
?RCS: Revision 3.0.1.8  1995/07/25  13:40:40  ram
?RCS: patch56: now knows about OS/2 platforms
?RCS:
?RCS: Revision 3.0.1.7  1995/01/11  15:13:37  ram
?RCS: patch45: protected "sh -c" within backquotes for Linux and SGI
?RCS: patch45: added path lookup for the 'comm' program
?RCS:
?RCS: Revision 3.0.1.6  1994/10/29  15:56:14  ram
?RCS: patch36: added ?F: line for metalint file checking
?RCS: patch36: be careful and guard against wildcard searching (ADO)
?RCS:
?RCS: Revision 3.0.1.5  1994/06/20  06:54:55  ram
?RCS: patch30: now locates find
?RCS:
?RCS: Revision 3.0.1.4  1994/05/13  15:18:15  ram
?RCS: patch27: added byacc to the trylist (ADO)
?RCS: patch27: lint lines reformatted (ADO)
?RCS:
?RCS: Revision 3.0.1.3  1994/01/24  14:01:44  ram
?RCS: patch16: added metalint hint on changed PATH variable
?RCS:
?RCS: Revision 3.0.1.2  1993/12/15  08:16:52  ram
?RCS: patch15: now set _test variable when test is built-in
?RCS: patch15: fixed rare cases where echo is not needed
?RCS:
?RCS: Revision 3.0.1.1  1993/09/13  15:47:13  ram
?RCS: patch10: test program not always in /bin/test (WAD)
?RCS:
?RCS: Revision 3.0  1993/08/18  12:05:05  ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
?X:
?X: This unit produces a shell script "loc" which can be used to find out
?X: where in a list of directories something is.  It then uses loc to
?X: determine the location of commonly used programs.  It leaves loc sitting
?X: around for other Configure units to use, but arranges for its demise
?X: at the end of Configure.
?X:
?X: To add a new program to find, add it both to the ?MAKE: line and to either
?X: the loclist or trylist variable.
?X:
?X: I put startsh at the end of the dependency list, in order to avoid the
?X: loading of the spitshell unit before the instructions.
?X:
?MAKE:Loc awk ar bash bison byacc cat chgrp chmod chown \
	comm compress cp cpio cpp csh date echo egrep emacs expr find flex \
	gcc gmake gzip grep inews ksh less line lint ln lp lpr ls mail mailx \
	make mkdir more mv nawk nm nroff perl pg pmake pr rm rmail sed sendmail \
	shar sleep smail sort submit tail tar tbl tee test touch tr troff \
	gmsgfmt msgfmt msgmerge xgettext \
	uname uniq uuname vi wc zcat zip:  eunicefix n c startsh Instruct Warn
?MAKE:	-pick weed $@ %<
?LINT: describe awk ar bash bison byacc cat chgrp chmod chown \
	comm compress cp cpio cpp csh date echo egrep emacs expr find flex \
	gcc gmake gzip grep inews ksh less line lint ln lp lpr ls mail mailx \
	make mkdir more mv nawk nm nroff perl pg pmake pr rm rmail sed sendmail \
	shar sleep smail sort submit tail tar tbl tee test touch tr troff \
	gmsgfmt msgfmt msgmerge xgettext \
	uname uniq uuname vi wc zcat zip
?V::pth loclist trylist
?F:./loc
?T:thisthing thing xxx dir file say DJGPP
?T:_echo _test _grep _cp _gmake _egrep _ln _make dflt
?LINT: change PATH
: find out where common programs are
echo " "
echo "Locating common programs..." >&4
cat <<EOSC >loc
$startsh
case \$# in
0) exit 1;;
esac
thing=\$1
shift
dflt=\$1
shift
for dir in \$*; do
	case "\$thing" in
	.)
	if test -d \$dir/\$thing; then
		echo \$dir
		exit 0
	fi
	;;
	*)
?X:	Be careful in case thing includes wildcards that might expand to multiple
?X:	files.  Choose the last one.  This happens when searching for shared
?X:	libraries with version numbers.  How to choose which one we want is
?X:	probably an insoluble problem, in general.
?X:	Some folks leave things like libc.so.orig around w/o read
?X:	permission.  A -r test would handle that, but since ./loc is
?X:	also used to find executables (which are installed w/o read
?X:	permission on SCO ODT 3.0, we can't include the -r test.
	for thisthing in \$dir/\$thing; do
		: just loop through to pick last item
	done
	if test -f \$thisthing; then
		echo \$thisthing
		exit 0
	elif test -f \$thisthing$_exe; then
		echo \$thisthing
		exit 0
	elif test -f \$dir/\$thing.exe; then
		if test -n "$DJGPP"; then
			echo \$dir/\$thing.exe
		else
			: on Eunice apparently
			echo \$dir/\$thing
		fi
		exit 0
	fi
	;;
	esac
done
echo \$dflt
exit 1
EOSC
chmod +x loc
$eunicefix loc
loclist="
?awk:awk
?cat:cat
?chgrp:chgrp
?chmod:chmod
?chown:chown
?comm:comm
?cp:cp
?echo:echo
?expr:expr
?find:find
?grep:grep
?ls:ls
?make:make
?mkdir:mkdir
?mv:mv
?rm:rm
?sed:sed
?sleep:sleep
?sort:sort
?tail:tail
?touch:touch
?tr:tr
?uniq:uniq
"
trylist="
?Mcc:Mcc
?ar:ar
?bash:bash
?bison:bison
?byacc:byacc
?compress:compress
?cpio:cpio
?cpp:cpp
?csh:csh
?date:date
?egrep:egrep
?emacs:emacs
?flex:flex
?gmake:gmake
?gcc:gcc
?gmsgfmt:gmsgfmt
?gzip:gzip
?inews:inews
?ksh:ksh
?less:less
?line:line
?lint:lint
?ln:ln
?lp:lp
?lpr:lpr
?mail:mail
?mailx:mailx
?more:more
?msgfmt:msgfmt
?msgmerge:msgmerge
?nawk:nawk
?nm:nm
?nroff:nroff
?perl:perl
?pg:pg
?pmake:pmake
?pr:pr
?rmail:rmail
?sendmail:sendmail
?shar:shar
?smail:smail
?submit:submit
?tar:tar
?tbl:tbl
?tee:tee
?test:test
?troff:troff
?uname:uname
?uuname:uuname
?vi:vi
?wc:wc
?xgettext:xgettext
?zcat:zcat
?zip:zip
"
?LINT: set awk ar bash bison byacc cat chgrp chmod chown \
	comm compress cp cpio cpp csh date emacs expr find flex \
	gcc gmake gzip grep inews ksh less line lint lp lpr ls mail mailx \
	mkdir more mv nawk nm nroff perl pg pmake pr rm rmail sed sendmail \
	shar sleep smail sort submit tail tar tbl tee touch tr troff \
	msgfmt msgmerge \
	uname uniq uuname vi wc zcat zip
pth=`echo $PATH | sed -e "s/$p_/ /g"`
pth="$pth /sbin /usr/sbin /lib /usr/lib /etc"
for file in $loclist; do
?X:
?X: Allow them to -Dmake=pmake on the command line for instance...
?X: If the file is not fully qualified, as in -Dmake=pmake, then we
?X: look the for the specified command (pmake here). If they say
?X: -Dmake=/sbin/make for instance, then we make sure the file
?X: exists, or we die...
?X:
	eval xxx=\$$file
	case "$xxx" in
	/*|?:[\\/]*)
		if test -f "$xxx"; then
			: ok
		else
			./warn "no $xxx -- ignoring your setting for $file." 4>&4
			xxx=`./loc $file $file $pth`
		fi
		;;
	'') xxx=`./loc $file $file $pth`;;
	*) xxx=`./loc $xxx $xxx $pth`;;
	esac
	eval $file=$xxx
	eval _$file=$xxx
	case "$xxx" in
	/*)
		echo $file is in $xxx.
		;;
?X: Under OS/2, we have PC-like paths
	?:[\\/]*)
		echo $file is in $xxx.
		;;
	*)
		echo "I don't know where '$file' is, and my life depends on it." >&4
		echo "Go find a public domain implementation or fix your PATH!" >&4
		exit 1
		;;
	esac
done
echo " "
echo "Don't worry if any of the following aren't found..."
say=offhand
for file in $trylist; do
?X: Allow them to -Dmake=pmake on the command line for instance (see above)
	eval xxx=\$$file
	case "$xxx" in
	/*|?:[\\/]*)
		if test -f "$xxx"; then
			: ok
		else
			./warn "no $xxx -- ignoring your setting for $file." 4>&4
			xxx=`./loc $file $file $pth`
		fi
		;;
	'') xxx=`./loc $file $file $pth`;;
	*) xxx=`./loc $xxx $xxx $pth`;;
	esac
	eval $file=$xxx
	eval _$file=$xxx
	case "$xxx" in
	/*)
		echo $file is in $xxx.
		;;
?X: Under OS/2, we have PC-like paths
	?:[\\/]*)
		echo $file is in $xxx.
		;;
	*)
		echo "I don't see $file out there, $say."
		say=either
		;;
	esac
done
case "$egrep" in
egrep$_exe|egrep)
	echo "Substituting grep for egrep."
	egrep=$grep
	_egrep=$_grep
	;;
esac
@if ln
case "$ln" in
ln$_exe|ln)
	echo "Substituting cp for ln."
	ln=$cp
	_ln=$_cp
	;;
esac
@end
@if make || gmake
case "$make" in
make$_exe|make)	
	case "$gmake" in
	gmake)
	echo "I can't find make or gmake, and my life depends on it." >&4
	echo "Go find a public domain implementation or fix your PATH setting!" >&4
	exit 1
	;;
	esac
	;;
esac	
case "$gmake" in
gmake$_exe|gmake)	;;
*)
?X: We can't have osname yet.
?X: On Stratus VOS, assume that gmake, if found, is definitely GNU make
?X: and prefer it over the system make.
	if test -f "/system/gnu_library/bin/ar.pm"; then
		: Stratus VOS
		echo "Substituting gmake for make."
		make=$gmake
		_make=$_gmake
	fi
	;;
esac
@end
@if gmsgfmt && msgfmt
?LINT: extern _msgfmt
?LINT: change _gmsgfmt
case "$gmsgfmt" in
gmsgfmt$_exe|gmsgfmt)
	echo "Substituting msgfmt for gmsgfmt."
	gmsgfmt=$msgfmt
	_gmsgfmt=$_msgfmt
	;;
*)
	if $gmsgfmt --statistics /dev/null >/dev/null 2>&1 &&
		(if $gmsgfmt --statistics /dev/null 2>&1 >/dev/null | \
			grep usage >/dev/null; then exit 0; else exit 1; fi)
	then
		echo "Your $gmsgfmt is not GNU msgfmt; substituting msgfmt."
		gmsgfmt=$msgfmt
		_gmsgfmt=$_msgfmt
	fi
	;;
esac
@end
@if xgettext
?LINT: change _xgettext
case "$xgettext" in
xgettext$_exe|xgettext)
	xgettext=":"
	_xgettext=":"
	;;
*)
	if $xgettext --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
		(if $xgettext --omit-header --copyright-holder= \
			/dev/null 2>&1 >/dev/null | \
			grep usage >/dev/null; then exit 0; else exit 1; fi)
	then
		echo "Your $xgettext is not GNU xgettext; ignoring it."
		xgettext=":"
		_xgettext=":"
	elif $xgettext --from-code=UTF-8 /dev/null >/dev/null 2>&1; then
		: ok
	else
		 echo "Your $xgettext does not support --from-code; ignoring it."
		 xgettext=":"
		 _xgettext=":"
	fi
	;;
esac
@end
case "$test" in
test|test$_exe)
	echo "Hopefully test is built into your sh."
	test=test
	;;
*)
	if `sh -c "PATH= test true" >/dev/null 2>&1`; then
		echo "Using the test built into your sh."
?X:
?X: We need to set both test and _test, since Oldconfig.U will use the _test
?X: value to systematically restore computed paths, which may be wrong if
?X: we choose to load an old config.sh generated on another platform.
?X:
		test=test
		_test=test
	fi
	;;
esac
?LINT:change n c
case "$echo" in
echo|echo$_exe)
	echo "Hopefully echo is built into your sh."
	echo=echo
	;;
?X: For those rare cases where we don't need $echo...
'') ;;
*)
	echo " "
echo "Checking compatibility between $_echo and builtin echo (if any)..." >&4
	$echo $n "hi there$c" >foo1
	echo $n "hi there$c" >foo2
	if cmp foo1 foo2 >/dev/null 2>&1; then
		echo "They are compatible.  In fact, they may be identical."
	else
		case "$n" in
		'-n') n='' c='\c';;
		*) n='-n' c='';;
		esac
		cat <<FOO
They are not compatible!  You are probably running ksh on a non-USG system.
I'll have to use $echo instead of the builtin, since Bourne shell doesn't
have echo built in and we may have to run some Bourne shell scripts.  That
means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.

FOO
		$echo $n "The star should be here-->$c"
		$echo "*"
	fi
	$rm -f foo1 foo2
	;;
esac