This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Silence metalint
[metaconfig.git] / U / modified / Loc.U
CommitLineData
9b04e79a 1?RCS: $Id: Loc.U 14 2006-08-28 16:51:14Z rmanfredi $
959f3c4c 2?RCS:
9b04e79a 3?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
4c42341b 4?RCS:
959f3c4c
JH
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
9b04e79a 9?RCS: of the source tree for dist 4.0.
959f3c4c
JH
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:
4c42341b 51?X:
959f3c4c
JH
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.
4c42341b 57?X:
959f3c4c
JH
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.
4c42341b 60?X:
959f3c4c
JH
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:
9b04e79a 64?MAKE:Loc awk ar bash bison byacc cat chgrp chmod chown \
959f3c4c 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 \
9b04e79a 69 uname uniq uuname vi zcat zip: eunicefix n c startsh Instruct
959f3c4c 70?MAKE: -pick weed $@ %<
9b04e79a 71?LINT:describe awk ar bash bison byacc cat chgrp chmod chown \
959f3c4c 72 comm compress cp cpio cpp csh date echo egrep emacs expr find flex \
1ef69357 73 gmake gzip grep inews ksh less line lint ln lp lpr ls mail mailx \
959f3c4c
JH
74 make mkdir more mv nm nroff perl pg pmake pr rm rmail sed sendmail \
75 shar sleep smail sort submit tail tar tbl tee test touch tr troff \
76 uname uniq uuname vi zcat zip
77?V::pth loclist trylist
12e20a24 78?F:./loc test_h
959f3c4c 79?T:thisthing thing xxx dir file say _test DJGPP
9b04e79a 80?LINT:change PATH _egrep _ln _make
f12ad395 81?LINT:extern _exe
959f3c4c
JH
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.
e12336c5
JH
111?X: If you need to use an _exe that is different from .exe
112?X: you need to set it in Head.U.
959f3c4c
JH
113 for thisthing in \$dir/\$thing; do
114 : just loop through to pick last item
115 done
116 if test -f \$thisthing; then
117 echo \$thisthing
118 exit 0
c98a3161
JH
119 elif test "X$_exe" != X -a -f \$thisthing$_exe; then
120 echo \$thisthing
9b04e79a 121 exit 0
959f3c4c
JH
122 elif test -f \$dir/\$thing.exe; then
123 if test -n "$DJGPP"; then
124 echo \$dir/\$thing.exe
0c8cc30a 125 elif test "$eunicefix" != ":"; then
959f3c4c
JH
126 : on Eunice apparently
127 echo \$dir/\$thing
128 fi
129 exit 0
130 fi
131 ;;
132 esac
133done
134echo \$dflt
135exit 1
136EOSC
137chmod +x loc
138$eunicefix loc
139loclist="
140?awk:awk
141?cat:cat
142?chgrp:chgrp
143?chmod:chmod
144?chown:chown
145?comm:comm
146?cp:cp
147?echo:echo
148?expr:expr
149?find:find
150?grep:grep
151?ls:ls
959f3c4c
JH
152?mkdir:mkdir
153?mv:mv
154?rm:rm
155?sed:sed
156?sleep:sleep
157?sort:sort
158?tail:tail
159?touch:touch
160?tr:tr
161?uniq:uniq
162"
163trylist="
164?Mcc:Mcc
165?ar:ar
166?bash:bash
167?bison:bison
168?byacc:byacc
169?compress:compress
170?cpio:cpio
171?cpp:cpp
172?csh:csh
173?date:date
174?egrep:egrep
175?emacs:emacs
176?flex:flex
1ef69357 177?gmake:gmake
959f3c4c
JH
178?gzip:gzip
179?inews:inews
180?ksh:ksh
181?less:less
182?line:line
183?lint:lint
184?ln:ln
185?lp:lp
186?lpr:lpr
187?mail:mail
188?mailx:mailx
9b04e79a 189?make:make
959f3c4c
JH
190?more:more
191?nm:nm
192?nroff:nroff
193?perl:perl
194?pg:pg
195?pmake:pmake
196?pr:pr
197?rmail:rmail
198?sendmail:sendmail
199?shar:shar
200?smail:smail
201?submit:submit
202?tar:tar
203?tbl:tbl
204?tee:tee
205?test:test
206?troff:troff
207?uname:uname
208?uuname:uuname
209?vi:vi
210?zcat:zcat
211?zip:zip
212"
9b04e79a
MB
213?LINT:set awk ar bash bison byacc cat chgrp chmod chown \
214 comm compress cp cpio cpp csh date echo emacs expr find flex \
215 gmake gzip grep inews ksh less line lint lp lpr ls mail mailx \
216 mkdir more mv nm nroff perl pg pmake pr rm rmail sed sendmail \
217 shar sleep smail sort submit tail tar tbl tee touch tr troff \
959f3c4c
JH
218 uname uniq uuname vi zcat zip
219pth=`echo $PATH | sed -e "s/$p_/ /g"`
220pth="$pth /lib /usr/lib"
221for file in $loclist; do
222?X:
223?X: Allow them to -Dmake=pmake on the command line for instance...
224?X: If the file is not fully qualified, as in -Dmake=pmake, then we
225?X: look the for the specified command (pmake here). If they say
226?X: -Dmake=/sbin/make for instance, then we make sure the file
227?X: exists, or we die...
228?X:
229 eval xxx=\$$file
230 case "$xxx" in
231 /*|?:[\\/]*)
232 if test -f "$xxx"; then
233 : ok
234 else
235 echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
236 xxx=`./loc $file $file $pth`
237 fi
238 ;;
239 '') xxx=`./loc $file $file $pth`;;
240 *) xxx=`./loc $xxx $xxx $pth`;;
241 esac
c98a3161 242 eval $file=$xxx$_exe
959f3c4c
JH
243 eval _$file=$xxx
244 case "$xxx" in
245 /*)
246 echo $file is in $xxx.
247 ;;
248?X: Under OS/2, we have PC-like paths
249 ?:[\\/]*)
250 echo $file is in $xxx.
251 ;;
252 *)
253 echo "I don't know where '$file' is, and my life depends on it." >&4
254 echo "Go find a public domain implementation or fix your PATH setting!" >&4
255 exit 1
256 ;;
257 esac
258done
259echo " "
260echo "Don't worry if any of the following aren't found..."
261say=offhand
262for file in $trylist; do
263?X: Allow them to -Dmake=pmake on the command line for instance (see above)
264 eval xxx=\$$file
265 case "$xxx" in
266 /*|?:[\\/]*)
267 if test -f "$xxx"; then
268 : ok
269 else
270 echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
271 xxx=`./loc $file $file $pth`
272 fi
273 ;;
274 '') xxx=`./loc $file $file $pth`;;
275 *) xxx=`./loc $xxx $xxx $pth`;;
276 esac
962b21ca 277 eval $file=$xxx$_exe
959f3c4c
JH
278 eval _$file=$xxx
279 case "$xxx" in
280 /*)
281 echo $file is in $xxx.
282 ;;
283?X: Under OS/2, we have PC-like paths
284 ?:[\\/]*)
285 echo $file is in $xxx.
286 ;;
287 *)
288 echo "I don't see $file out there, $say."
289 say=either
290 ;;
291 esac
292done
293case "$egrep" in
f12ad395 294egrep)
959f3c4c
JH
295 echo "Substituting grep for egrep."
296 egrep=$grep
26470d78 297 _egrep=$grep
959f3c4c
JH
298 ;;
299esac
300@if ln
301case "$ln" in
f12ad395 302ln)
959f3c4c
JH
303 echo "Substituting cp for ln."
304 ln=$cp
26470d78 305 _ln=$cp
959f3c4c
JH
306 ;;
307esac
4c2f5bee 308@end
9b04e79a 309@if make || gmake
e12336c5 310case "$make" in
4c42341b 311make)
e12336c5
JH
312 case "$gmake" in
313 gmake)
314 echo "I can't find make or gmake, and my life depends on it." >&4
315 echo "Go find a public domain implementation or fix your PATH setting!" >&4
316 exit 1
317 ;;
318 esac
319 ;;
4c42341b 320esac
e12336c5
JH
321case "$gmake" in
322gmake) ;;
323*) # We can't have osname yet.
f12ad395
JH
324 if test -f "/system/gnu_library/bin/ar.pm"; then # Stratus VOS
325 # Assume that gmake, if found, is definitely GNU make
326 # and prefer it over the system make.
327 echo "Substituting gmake for make."
328 make=$gmake
26470d78 329 _make=$gmake
f12ad395
JH
330 fi
331 ;;
c98a3161 332esac
9b04e79a 333@end
959f3c4c
JH
334case "$test" in
335test)
336 echo "Hopefully test is built into your sh."
337 ;;
338*)
df0bcc5d 339 if `sh -c "PATH= test true" >/dev/null 2>&1`; then
959f3c4c
JH
340 echo "Using the test built into your sh."
341?X:
342?X: We need to set both test and _test, since Oldconfig.U will use the _test
343?X: value to systematically restore computed paths, which may be wrong if
344?X: we choose to load an old config.sh generated on another platform.
345?X:
346 test=test
347 _test=test
348 fi
349 ;;
350esac
351?LINT:change n c
352case "$echo" in
353echo)
354 echo "Hopefully echo is built into your sh."
355 ;;
356?X: For those rare cases where we don't need $echo...
357'') ;;
358*)
359 echo " "
360echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
361 $echo $n "hi there$c" >foo1
362 echo $n "hi there$c" >foo2
363 if cmp foo1 foo2 >/dev/null 2>&1; then
364 echo "They are compatible. In fact, they may be identical."
365 else
366 case "$n" in
367 '-n') n='' c='\c';;
368 *) n='-n' c='';;
369 esac
370 cat <<FOO
371They are not compatible! You are probably running ksh on a non-USG system.
372I'll have to use $echo instead of the builtin, since Bourne shell doesn't
373have echo built in and we may have to run some Bourne shell scripts. That
374means I'll have to use '$n$c' to suppress newlines now. Life is ridiculous.
375
376FOO
377 $echo $n "The star should be here-->$c"
378 $echo "*"
379 fi
380 $rm -f foo1 foo2
381 ;;
382esac
383
4d826ee1
MB
384?X: The next part is irrelevant to the real process
385# This question was auctioned at YAPC::Europe-2007 in Vienna
386# I never promised you could answer it. I only auctioned the question.
387cat <<FOO
388The following message is sponsored by
389
390 Dresden.pm<--The stars should be here.
391
392Dear Perl user, system administrator or package
393maintainer, the Perl community sends greetings to
394you. Do you (emblematical) greet back [Y/n]? n
395
396FOO
397