This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix the bugs in #13768..13776, and regen Configure.
[metaconfig.git] / U / modified / Loc.U
CommitLineData
959f3c4c
JH
1?RCS: $Id: Loc.U,v 3.0.1.10 1997/02/28 15:04:16 ram Exp $
2?RCS:
3?RCS: Copyright (c) 1991-1993, 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 3.0.
10?RCS:
11?RCS: $Log: Loc.U,v $
12?RCS: Revision 3.0.1.10 1997/02/28 15:04:16 ram
13?RCS: patch61: allow users to specify paths on the command line
14?RCS: patch61: will now substitute cp for ln if not supported
15?RCS:
16?RCS: Revision 3.0.1.9 1995/09/25 09:11:24 ram
17?RCS: patch59: commented the purpose of the #un-def directive
18?RCS: patch59: abort Configure run when mandatory command is missing
19?RCS:
20?RCS: Revision 3.0.1.8 1995/07/25 13:40:40 ram
21?RCS: patch56: now knows about OS/2 platforms
22?RCS:
23?RCS: Revision 3.0.1.7 1995/01/11 15:13:37 ram
24?RCS: patch45: protected "sh -c" within backquotes for Linux and SGI
25?RCS: patch45: added path lookup for the 'comm' program
26?RCS:
27?RCS: Revision 3.0.1.6 1994/10/29 15:56:14 ram
28?RCS: patch36: added ?F: line for metalint file checking
29?RCS: patch36: be careful and guard against wildcard searching (ADO)
30?RCS:
31?RCS: Revision 3.0.1.5 1994/06/20 06:54:55 ram
32?RCS: patch30: now locates find
33?RCS:
34?RCS: Revision 3.0.1.4 1994/05/13 15:18:15 ram
35?RCS: patch27: added byacc to the trylist (ADO)
36?RCS: patch27: lint lines reformatted (ADO)
37?RCS:
38?RCS: Revision 3.0.1.3 1994/01/24 14:01:44 ram
39?RCS: patch16: added metalint hint on changed PATH variable
40?RCS:
41?RCS: Revision 3.0.1.2 1993/12/15 08:16:52 ram
42?RCS: patch15: now set _test variable when test is built-in
43?RCS: patch15: fixed rare cases where echo is not needed
44?RCS:
45?RCS: Revision 3.0.1.1 1993/09/13 15:47:13 ram
46?RCS: patch10: test program not always in /bin/test (WAD)
47?RCS:
48?RCS: Revision 3.0 1993/08/18 12:05:05 ram
49?RCS: Baseline for dist 3.0 netwide release.
50?RCS:
51?X:
52?X: This unit produces a shell script "loc" which can be used to find out
53?X: where in a list of directories something is. It then uses loc to
54?X: determine the location of commonly used programs. It leaves loc sitting
55?X: around for other Configure units to use, but arranges for its demise
56?X: at the end of Configure.
57?X:
58?X: To add a new program to find, add it both to the ?MAKE: line and to either
59?X: the loclist or trylist variable.
60?X:
61?X: I put startsh at the end of the dependency list, in order to avoid the
62?X: loading of the spitshell unit before the instructions.
63?X:
64?MAKE:Loc Mcc awk ar bash bison byacc cat chgrp chmod chown \
65 comm compress cp cpio cpp csh date echo egrep emacs expr find flex \
1ef69357 66 gmake gzip grep inews ksh less line lint ln lp lpr ls mail mailx \
959f3c4c
JH
67 make mkdir more mv nm nroff perl pg pmake pr rm rmail sed sendmail \
68 shar sleep smail sort submit tail tar tbl tee test touch tr troff \
69 uname uniq uuname vi zcat zip: eunicefix n c Instruct Myread \
df0bcc5d 70 startsh
959f3c4c
JH
71?MAKE: -pick weed $@ %<
72?LINT:describe Loc Mcc awk ar bash bison byacc cat chgrp chmod chown \
73 comm compress cp cpio cpp csh date echo egrep emacs expr find flex \
1ef69357 74 gmake gzip grep inews ksh less line lint ln lp lpr ls mail mailx \
959f3c4c
JH
75 make mkdir more mv nm nroff perl pg pmake pr rm rmail sed sendmail \
76 shar sleep smail sort submit tail tar tbl tee test touch tr troff \
77 uname uniq uuname vi zcat zip
78?V::pth loclist trylist
12e20a24 79?F:./loc test_h
959f3c4c
JH
80?T:thisthing thing xxx dir file say _test DJGPP
81?LINT:change PATH
82: find out where common programs are
83echo " "
84echo "Locating common programs..." >&4
85cat <<EOSC >loc
86$startsh
87case \$# in
880) exit 1;;
89esac
90thing=\$1
91shift
92dflt=\$1
93shift
94for dir in \$*; do
95 case "\$thing" in
96 .)
97 if test -d \$dir/\$thing; then
98 echo \$dir
99 exit 0
100 fi
101 ;;
102 *)
103?X: Be careful in case thing includes wildcards that might expand to multiple
104?X: files. Choose the last one. This happens when searching for shared
105?X: libraries with version numbers. How to choose which one we want is
106?X: probably an insoluble problem, in general.
107?X: Some folks leave things like libc.so.orig around w/o read
108?X: permission. A -r test would handle that, but since ./loc is
109?X: also used to find executables (which are installed w/o read
110?X: permission on SCO ODT 3.0, we can't include the -r test.
111 for thisthing in \$dir/\$thing; do
112 : just loop through to pick last item
113 done
114 if test -f \$thisthing; then
115 echo \$thisthing
116 exit 0
117 elif test -f \$dir/\$thing.exe; then
118 if test -n "$DJGPP"; then
119 echo \$dir/\$thing.exe
120 else
121 : on Eunice apparently
122 echo \$dir/\$thing
123 fi
124 exit 0
125 fi
126 ;;
127 esac
128done
129echo \$dflt
130exit 1
131EOSC
132chmod +x loc
133$eunicefix loc
134loclist="
135?awk:awk
136?cat:cat
137?chgrp:chgrp
138?chmod:chmod
139?chown:chown
140?comm:comm
141?cp:cp
142?echo:echo
143?expr:expr
144?find:find
145?grep:grep
146?ls:ls
959f3c4c
JH
147?mkdir:mkdir
148?mv:mv
149?rm:rm
150?sed:sed
151?sleep:sleep
152?sort:sort
153?tail:tail
154?touch:touch
155?tr:tr
156?uniq:uniq
157"
158trylist="
159?Mcc:Mcc
160?ar:ar
161?bash:bash
162?bison:bison
163?byacc:byacc
164?compress:compress
165?cpio:cpio
166?cpp:cpp
167?csh:csh
168?date:date
169?egrep:egrep
170?emacs:emacs
171?flex:flex
1ef69357 172?gmake:gmake
959f3c4c
JH
173?gzip:gzip
174?inews:inews
175?ksh:ksh
176?less:less
177?line:line
178?lint:lint
179?ln:ln
180?lp:lp
181?lpr:lpr
182?mail:mail
1ef69357 183?make:make
959f3c4c
JH
184?mailx:mailx
185?more:more
186?nm:nm
187?nroff:nroff
188?perl:perl
189?pg:pg
190?pmake:pmake
191?pr:pr
192?rmail:rmail
193?sendmail:sendmail
194?shar:shar
195?smail:smail
196?submit:submit
197?tar:tar
198?tbl:tbl
199?tee:tee
200?test:test
201?troff:troff
202?uname:uname
203?uuname:uuname
204?vi:vi
205?zcat:zcat
206?zip:zip
207"
208?LINT:set Loc Mcc awk ar bash bison byacc cat chgrp chmod chown \
209 comm compress cp cpio cpp csh date echo egrep emacs expr find flex \
1ef69357 210 gmake gzip grep inews ksh less line lint ln lp lpr ls mail mailx \
959f3c4c
JH
211 make mkdir more mv nm nroff perl pg pmake pr rm rmail sed sendmail \
212 shar sleep smail sort submit tail tar tbl tee test touch tr troff \
213 uname uniq uuname vi zcat zip
214pth=`echo $PATH | sed -e "s/$p_/ /g"`
215pth="$pth /lib /usr/lib"
216for file in $loclist; do
217?X:
218?X: Allow them to -Dmake=pmake on the command line for instance...
219?X: If the file is not fully qualified, as in -Dmake=pmake, then we
220?X: look the for the specified command (pmake here). If they say
221?X: -Dmake=/sbin/make for instance, then we make sure the file
222?X: exists, or we die...
223?X:
224 eval xxx=\$$file
225 case "$xxx" in
226 /*|?:[\\/]*)
227 if test -f "$xxx"; then
228 : ok
229 else
230 echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
231 xxx=`./loc $file $file $pth`
232 fi
233 ;;
234 '') xxx=`./loc $file $file $pth`;;
235 *) xxx=`./loc $xxx $xxx $pth`;;
236 esac
237 eval $file=$xxx
238 eval _$file=$xxx
239 case "$xxx" in
240 /*)
241 echo $file is in $xxx.
242 ;;
243?X: Under OS/2, we have PC-like paths
244 ?:[\\/]*)
245 echo $file is in $xxx.
246 ;;
247 *)
248 echo "I don't know where '$file' is, and my life depends on it." >&4
249 echo "Go find a public domain implementation or fix your PATH setting!" >&4
250 exit 1
251 ;;
252 esac
253done
254echo " "
255echo "Don't worry if any of the following aren't found..."
256say=offhand
257for file in $trylist; do
258?X: Allow them to -Dmake=pmake on the command line for instance (see above)
259 eval xxx=\$$file
260 case "$xxx" in
261 /*|?:[\\/]*)
262 if test -f "$xxx"; then
263 : ok
264 else
265 echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
266 xxx=`./loc $file $file $pth`
267 fi
268 ;;
269 '') xxx=`./loc $file $file $pth`;;
270 *) xxx=`./loc $xxx $xxx $pth`;;
271 esac
272 eval $file=$xxx
273 eval _$file=$xxx
274 case "$xxx" in
275 /*)
276 echo $file is in $xxx.
277 ;;
278?X: Under OS/2, we have PC-like paths
279 ?:[\\/]*)
280 echo $file is in $xxx.
281 ;;
282 *)
283 echo "I don't see $file out there, $say."
284 say=either
285 ;;
286 esac
287done
288case "$egrep" in
289egrep)
290 echo "Substituting grep for egrep."
291 egrep=$grep
292 ;;
293esac
294@if ln
295case "$ln" in
296ln)
297 echo "Substituting cp for ln."
298 ln=$cp
299 ;;
300esac
301@end
302case "$test" in
303test)
304 echo "Hopefully test is built into your sh."
305 ;;
306*)
df0bcc5d 307 if `sh -c "PATH= test true" >/dev/null 2>&1`; then
959f3c4c
JH
308 echo "Using the test built into your sh."
309?X:
310?X: We need to set both test and _test, since Oldconfig.U will use the _test
311?X: value to systematically restore computed paths, which may be wrong if
312?X: we choose to load an old config.sh generated on another platform.
313?X:
314 test=test
315 _test=test
316 fi
317 ;;
318esac
319?LINT:change n c
320case "$echo" in
321echo)
322 echo "Hopefully echo is built into your sh."
323 ;;
324?X: For those rare cases where we don't need $echo...
325'') ;;
326*)
327 echo " "
328echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
329 $echo $n "hi there$c" >foo1
330 echo $n "hi there$c" >foo2
331 if cmp foo1 foo2 >/dev/null 2>&1; then
332 echo "They are compatible. In fact, they may be identical."
333 else
334 case "$n" in
335 '-n') n='' c='\c';;
336 *) n='-n' c='';;
337 esac
338 cat <<FOO
339They are not compatible! You are probably running ksh on a non-USG system.
340I'll have to use $echo instead of the builtin, since Bourne shell doesn't
341have echo built in and we may have to run some Bourne shell scripts. That
342means I'll have to use '$n$c' to suppress newlines now. Life is ridiculous.
343
344FOO
345 $echo $n "The star should be here-->$c"
346 $echo "*"
347 fi
348 $rm -f foo1 foo2
349 ;;
350esac
351