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