perl 5.0 alpha 9
[p5sagit/p5-mst-13.2.git] / U / Loc.U
1 ?RCS: $Id: Loc.U,v 3.0.1.3 1994/01/24 14:01:44 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: $Log: Loc.U,v $
11 ?RCS: Revision 3.0.1.3  1994/01/24  14:01:44  ram
12 ?RCS: patch16: added metalint hint on changed PATH variable
13 ?RCS:
14 ?RCS: Revision 3.0.1.2  1993/12/15  08:16:52  ram
15 ?RCS: patch15: now set _test variable when test is built-in
16 ?RCS: patch15: fixed rare cases where echo is not needed
17 ?RCS:
18 ?RCS: Revision 3.0.1.1  1993/09/13  15:47:13  ram
19 ?RCS: patch10: test program not always in /bin/test (WAD)
20 ?RCS:
21 ?RCS: Revision 3.0  1993/08/18  12:05:05  ram
22 ?RCS: Baseline for dist 3.0 netwide release.
23 ?RCS:
24 ?X: 
25 ?X: This unit produces a shell script "loc" which can be used to find out
26 ?X: where in a list of directories something is.  It then uses loc to
27 ?X: determine the location of commonly used programs.  It leaves loc sitting
28 ?X: around for other Configure units to use, but arranges for its demise
29 ?X: at the end of Configure.
30 ?X: 
31 ?X: To add a new program to find, add it both to the ?MAKE: line and to either
32 ?X: the loclist or trylist variable.
33 ?X: 
34 ?X: I put startsh at the end of the dependency list, in order to avoid the
35 ?X: loading of the spitshell unit before the instructions.
36 ?X:
37 ?MAKE:Loc Mcc awk bash bison byacc cat chgrp chmod chown compress cp cpio \
38         cpp csh date echo egrep emacs expr find flex gcc grep inews ksh \
39         less line lint ln lp lpr ls mail mailx make mkdir more mv nroff \
40         perl pg pmake pr rm rmail sed sendmail sh shar sleep smail sort \
41         submit tail tar tbl test touch tr troff uname uniq uuname vi \
42         zcat: eunicefix n c Instruct Myread startsh
43 ?MAKE:  -pick weed $@ %<
44 ?LINT:describe Loc Mcc awk bash bison byacc cat chgrp chmod chown compress \
45         cp cpio cpp csh date echo egrep emacs expr find flex gcc grep \
46         inews ksh less line lint ln lp lpr ls mail mailx make mkdir more \
47         mv nroff perl pg pmake pr rm rmail sed sendmail sh shar sleep \
48         smail sort submit tail tar tbl test touch tr troff uname uniq \
49         uuname vi zcat
50 ?V::pth loclist trylist
51 ?T:thing xxx dir file say _test
52 ?LINT:change PATH
53 : find out where common programs are
54 echo " "
55 echo "Locating common programs..." >&4
56 cat <<EOSC >loc
57 $startsh
58 case \$# in
59 0) exit 1;;
60 esac
61 thing=\$1
62 shift
63 dflt=\$1
64 shift
65 for dir in \$*; do
66         case "\$thing" in
67         .)
68         if test -d \$dir/\$thing; then
69                 echo \$dir
70                 exit 0
71         fi
72         ;;
73         *)
74         if test -f \$dir/\$thing; then
75                 echo \$dir/\$thing
76                 exit 0
77         elif test -f \$dir/\$thing.exe; then
78                 : on Eunice apparently
79                 echo \$dir/\$thing
80                 exit 0
81         fi
82         ;;
83         esac
84 done
85 echo \$dflt
86 exit 1
87 EOSC
88 chmod +x loc
89 $eunicefix loc
90 loclist="
91 ?awk:awk
92 ?cat:cat
93 ?chgrp:chgrp
94 ?chmod:chmod
95 ?chown:chown
96 ?cp:cp
97 ?echo:echo
98 ?expr:expr
99 ?grep:grep
100 ?ln:ln
101 ?ls:ls
102 ?make:make
103 ?mkdir:mkdir
104 ?mv:mv
105 ?rm:rm
106 ?sed:sed
107 ?sleep:sleep
108 ?sort:sort
109 ?tail:tail
110 ?touch:touch
111 ?tr:tr
112 ?uniq:uniq
113 "
114 trylist="
115 ?Mcc:Mcc
116 ?bash:bash
117 ?bison:bison
118 ?byacc:byacc
119 ?compress:compress
120 ?cpio:cpio
121 ?cpp:cpp
122 ?csh:csh
123 ?date:date
124 ?egrep:egrep
125 ?emacs:emacs
126 ?find:find
127 ?flex:flex
128 ?gcc:gcc
129 ?inews:inews
130 ?ksh:ksh
131 ?less:less
132 ?line:line
133 ?lint:lint
134 ?lp:lp
135 ?lpr:lpr
136 ?mail:mail
137 ?mailx:mailx
138 ?more:more
139 ?nroff:nroff
140 ?perl:perl
141 ?pg:pg
142 ?pmake:pmake
143 ?pr:pr
144 ?rmail:rmail
145 ?sendmail:sendmail
146 ?sh:sh
147 ?shar:shar
148 ?smail:smail
149 ?submit:submit
150 ?tar:tar
151 ?tbl:tbl
152 ?test:test
153 ?troff:troff
154 ?uname:uname
155 ?uuname:uuname
156 ?vi:vi
157 ?zcat:zcat
158 "
159 ?LINT:set Loc Mcc awk bash bison byacc cat chgrp chmod chown compress cp \
160         cpio cpp csh date echo egrep emacs expr find flex gcc grep inews \
161         ksh less line lint ln lp lpr ls mail mailx make mkdir more mv \
162         nroff perl pg pmake pr rm rmail sed sendmail sh shar sleep \
163         smail sort submit tail tar tbl test touch tr troff uname uniq \
164         uuname vi zcat
165 pth=`echo $PATH | sed -e 's/:/ /g'`
166 pth="$pth /lib /usr/lib"
167 for file in $loclist; do
168         xxx=`./loc $file $file $pth`
169         eval $file=$xxx
170         eval _$file=$xxx
171         case "$xxx" in
172         /*)
173                 echo $file is in $xxx.
174                 ;;
175         *)
176                 echo "I don't know where $file is.  I hope it's in everyone's PATH."
177                 ;;
178         esac
179 done
180 echo " "
181 echo "Don't worry if any of the following aren't found..."
182 say=offhand
183 for file in $trylist; do
184         xxx=`./loc $file $file $pth`
185         eval $file=$xxx
186         eval _$file=$xxx
187         case "$xxx" in
188         /*)
189                 echo $file is in $xxx.
190                 ;;
191         *)
192                 echo "I don't see $file out there, $say."
193                 say=either
194                 ;;
195         esac
196 done
197 case "$egrep" in
198 egrep)
199         echo "Substituting grep for egrep."
200         egrep=$grep
201         ;;
202 esac
203 case "$test" in
204 test)
205         echo "Hopefully test is built into your sh."
206         ;;
207 *)
208         if sh -c "PATH= test true" >/dev/null 2>&1; then
209                 echo "Using the test built into your sh."
210 ?X:
211 ?X: We need to set both test and _test, since Oldconfig.U will use the _test
212 ?X: value to systematically restore computed paths, which may be wrong if
213 ?X: we choose to load an old config.sh generated on another platform.
214 ?X:
215                 test=test
216                 _test=test
217         fi
218         ;;
219 esac
220 ?LINT:change n c
221 case "$echo" in
222 echo)
223         echo "Hopefully echo is built into your sh."
224         ;;
225 ?X: For those rare cases where we don't need $echo...
226 '') ;;
227 *)
228         echo " "
229 echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
230         $echo $n "hi there$c" >foo1
231         echo $n "hi there$c" >foo2
232         if cmp foo1 foo2 >/dev/null 2>&1; then
233                 echo "They are compatible.  In fact, they may be identical."
234         else
235                 case "$n" in
236                 '-n') n='' c='\c';;
237                 *) n='-n' c='';;
238                 esac
239                 cat <<FOO
240 They are not compatible!  You are probably running ksh on a non-USG system.
241 I'll have to use $echo instead of the builtin, since Bourne shell doesn't
242 have echo built in and we may have to run some Bourne shell scripts.  That
243 means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
244
245 FOO
246                 $echo $n "The star should be here-->$c"
247                 $echo "*"
248         fi
249         $rm -f foo1 foo2
250         ;;
251 esac
252