This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RE: [perl #26136] localtime(3) calls tzset(3), but localtime_r(3) may not.
[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
f12ad395 82?LINT:extern _exe
9f542ee7
JH
83?LINT:change _egrep
84?LINT:change _ln
85?LINT:change _make
959f3c4c
JH
86: find out where common programs are
87echo " "
88echo "Locating common programs..." >&4
89cat <<EOSC >loc
90$startsh
91case \$# in
920) exit 1;;
93esac
94thing=\$1
95shift
96dflt=\$1
97shift
98for dir in \$*; do
99 case "\$thing" in
100 .)
101 if test -d \$dir/\$thing; then
102 echo \$dir
103 exit 0
104 fi
105 ;;
106 *)
107?X: Be careful in case thing includes wildcards that might expand to multiple
108?X: files. Choose the last one. This happens when searching for shared
109?X: libraries with version numbers. How to choose which one we want is
110?X: probably an insoluble problem, in general.
111?X: Some folks leave things like libc.so.orig around w/o read
112?X: permission. A -r test would handle that, but since ./loc is
113?X: also used to find executables (which are installed w/o read
114?X: permission on SCO ODT 3.0, we can't include the -r test.
e12336c5
JH
115?X: If you need to use an _exe that is different from .exe
116?X: you need to set it in Head.U.
959f3c4c
JH
117 for thisthing in \$dir/\$thing; do
118 : just loop through to pick last item
119 done
120 if test -f \$thisthing; then
121 echo \$thisthing
122 exit 0
c98a3161
JH
123 elif test "X$_exe" != X -a -f \$thisthing$_exe; then
124 echo \$thisthing
125 exit 0
959f3c4c
JH
126 elif test -f \$dir/\$thing.exe; then
127 if test -n "$DJGPP"; then
128 echo \$dir/\$thing.exe
0c8cc30a 129 elif test "$eunicefix" != ":"; then
959f3c4c
JH
130 : on Eunice apparently
131 echo \$dir/\$thing
0c8cc30a 132 exit 0
959f3c4c
JH
133 fi
134 exit 0
135 fi
136 ;;
137 esac
138done
139echo \$dflt
140exit 1
141EOSC
142chmod +x loc
143$eunicefix loc
144loclist="
145?awk:awk
146?cat:cat
147?chgrp:chgrp
148?chmod:chmod
149?chown:chown
150?comm:comm
151?cp:cp
152?echo:echo
153?expr:expr
154?find:find
155?grep:grep
156?ls:ls
959f3c4c
JH
157?mkdir:mkdir
158?mv:mv
159?rm:rm
160?sed:sed
161?sleep:sleep
162?sort:sort
163?tail:tail
164?touch:touch
165?tr:tr
166?uniq:uniq
167"
168trylist="
169?Mcc:Mcc
170?ar:ar
171?bash:bash
172?bison:bison
173?byacc:byacc
174?compress:compress
175?cpio:cpio
176?cpp:cpp
177?csh:csh
178?date:date
179?egrep:egrep
180?emacs:emacs
181?flex:flex
1ef69357 182?gmake:gmake
959f3c4c
JH
183?gzip:gzip
184?inews:inews
185?ksh:ksh
186?less:less
187?line:line
188?lint:lint
189?ln:ln
190?lp:lp
191?lpr:lpr
192?mail:mail
1ef69357 193?make:make
959f3c4c
JH
194?mailx:mailx
195?more:more
196?nm:nm
197?nroff:nroff
198?perl:perl
199?pg:pg
200?pmake:pmake
201?pr:pr
202?rmail:rmail
203?sendmail:sendmail
204?shar:shar
205?smail:smail
206?submit:submit
207?tar:tar
208?tbl:tbl
209?tee:tee
210?test:test
211?troff:troff
212?uname:uname
213?uuname:uuname
214?vi:vi
215?zcat:zcat
216?zip:zip
217"
218?LINT:set Loc Mcc awk ar bash bison byacc cat chgrp chmod chown \
219 comm compress cp cpio cpp csh date echo egrep emacs expr find flex \
1ef69357 220 gmake gzip grep inews ksh less line lint ln lp lpr ls mail mailx \
959f3c4c
JH
221 make mkdir more mv nm nroff perl pg pmake pr rm rmail sed sendmail \
222 shar sleep smail sort submit tail tar tbl tee test touch tr troff \
223 uname uniq uuname vi zcat zip
224pth=`echo $PATH | sed -e "s/$p_/ /g"`
225pth="$pth /lib /usr/lib"
226for file in $loclist; do
227?X:
228?X: Allow them to -Dmake=pmake on the command line for instance...
229?X: If the file is not fully qualified, as in -Dmake=pmake, then we
230?X: look the for the specified command (pmake here). If they say
231?X: -Dmake=/sbin/make for instance, then we make sure the file
232?X: exists, or we die...
233?X:
234 eval xxx=\$$file
235 case "$xxx" in
236 /*|?:[\\/]*)
237 if test -f "$xxx"; then
238 : ok
239 else
240 echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
241 xxx=`./loc $file $file $pth`
242 fi
243 ;;
244 '') xxx=`./loc $file $file $pth`;;
245 *) xxx=`./loc $xxx $xxx $pth`;;
246 esac
c98a3161 247 eval $file=$xxx$_exe
959f3c4c
JH
248 eval _$file=$xxx
249 case "$xxx" in
250 /*)
251 echo $file is in $xxx.
252 ;;
253?X: Under OS/2, we have PC-like paths
254 ?:[\\/]*)
255 echo $file is in $xxx.
256 ;;
257 *)
258 echo "I don't know where '$file' is, and my life depends on it." >&4
259 echo "Go find a public domain implementation or fix your PATH setting!" >&4
260 exit 1
261 ;;
262 esac
263done
264echo " "
265echo "Don't worry if any of the following aren't found..."
266say=offhand
267for file in $trylist; do
268?X: Allow them to -Dmake=pmake on the command line for instance (see above)
269 eval xxx=\$$file
270 case "$xxx" in
271 /*|?:[\\/]*)
272 if test -f "$xxx"; then
273 : ok
274 else
275 echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
276 xxx=`./loc $file $file $pth`
277 fi
278 ;;
279 '') xxx=`./loc $file $file $pth`;;
280 *) xxx=`./loc $xxx $xxx $pth`;;
281 esac
962b21ca 282 eval $file=$xxx$_exe
959f3c4c
JH
283 eval _$file=$xxx
284 case "$xxx" in
285 /*)
286 echo $file is in $xxx.
287 ;;
288?X: Under OS/2, we have PC-like paths
289 ?:[\\/]*)
290 echo $file is in $xxx.
291 ;;
292 *)
293 echo "I don't see $file out there, $say."
294 say=either
295 ;;
296 esac
297done
298case "$egrep" in
f12ad395 299egrep)
959f3c4c
JH
300 echo "Substituting grep for egrep."
301 egrep=$grep
26470d78 302 _egrep=$grep
959f3c4c
JH
303 ;;
304esac
305@if ln
306case "$ln" in
f12ad395 307ln)
959f3c4c
JH
308 echo "Substituting cp for ln."
309 ln=$cp
26470d78 310 _ln=$cp
959f3c4c
JH
311 ;;
312esac
4c2f5bee 313@end
e12336c5
JH
314case "$make" in
315make)
316 case "$gmake" in
317 gmake)
318 echo "I can't find make or gmake, and my life depends on it." >&4
319 echo "Go find a public domain implementation or fix your PATH setting!" >&4
320 exit 1
321 ;;
322 esac
323 ;;
324esac
325case "$gmake" in
326gmake) ;;
327*) # We can't have osname yet.
f12ad395
JH
328 if test -f "/system/gnu_library/bin/ar.pm"; then # Stratus VOS
329 # Assume that gmake, if found, is definitely GNU make
330 # and prefer it over the system make.
331 echo "Substituting gmake for make."
332 make=$gmake
26470d78 333 _make=$gmake
f12ad395
JH
334 fi
335 ;;
c98a3161 336esac
959f3c4c
JH
337case "$test" in
338test)
339 echo "Hopefully test is built into your sh."
340 ;;
341*)
df0bcc5d 342 if `sh -c "PATH= test true" >/dev/null 2>&1`; then
959f3c4c
JH
343 echo "Using the test built into your sh."
344?X:
345?X: We need to set both test and _test, since Oldconfig.U will use the _test
346?X: value to systematically restore computed paths, which may be wrong if
347?X: we choose to load an old config.sh generated on another platform.
348?X:
349 test=test
350 _test=test
351 fi
352 ;;
353esac
354?LINT:change n c
355case "$echo" in
356echo)
357 echo "Hopefully echo is built into your sh."
358 ;;
359?X: For those rare cases where we don't need $echo...
360'') ;;
361*)
362 echo " "
363echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
364 $echo $n "hi there$c" >foo1
365 echo $n "hi there$c" >foo2
366 if cmp foo1 foo2 >/dev/null 2>&1; then
367 echo "They are compatible. In fact, they may be identical."
368 else
369 case "$n" in
370 '-n') n='' c='\c';;
371 *) n='-n' c='';;
372 esac
373 cat <<FOO
374They are not compatible! You are probably running ksh on a non-USG system.
375I'll have to use $echo instead of the builtin, since Bourne shell doesn't
376have echo built in and we may have to run some Bourne shell scripts. That
377means I'll have to use '$n$c' to suppress newlines now. Life is ridiculous.
378
379FOO
380 $echo $n "The star should be here-->$c"
381 $echo "*"
382 fi
383 $rm -f foo1 foo2
384 ;;
385esac
386