perl 3.0 patch #7 (combined patch)
[p5sagit/p5-mst-13.2.git] / Makefile.SH
1 case $CONFIG in
2 '')
3     if test ! -f config.sh; then
4         ln ../config.sh . || \
5         ln ../../config.sh . || \
6         ln ../../../config.sh . || \
7         (echo "Can't find config.sh."; exit 1)
8     fi
9     . ./config.sh
10     ;;
11 esac
12 case "$0" in
13 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
14 esac
15
16 case "$d_symlink" in
17 *define*) sln='ln -s' ;;
18 *) sln='ln';;
19 esac
20
21 case "$d_dosuid" in
22 *define*) suidperl='suidperl' ;;
23 *) suidperl='';;
24 esac
25
26 echo "Extracting Makefile (with variable substitutions)"
27 cat >Makefile <<!GROK!THIS!
28 # $Header: Makefile.SH,v 3.0.1.3 89/12/21 19:09:26 lwall Locked $
29 #
30 # $Log: Makefile.SH,v $
31 # Revision 3.0.1.3  89/12/21  19:09:26  lwall
32 # patch7: Configure now lets you pick between yacc or bison
33
34 # Revision 3.0.1.2  89/11/11  04:07:30  lwall
35 # patch2: $sockethdr incorporated into $ccflags
36 # patch2: $libs now has most of the -l libraries
37
38 # Revision 3.0.1.1  89/10/26  23:00:38  lwall
39 # patch1: Makefile.SH needed some more .h dependecies
40
41 # Revision 3.0  89/10/18  15:06:43  lwall
42 # 3.0 baseline
43
44
45 CC = $cc
46 YACC = $yacc
47 bin = $bin
48 privlib = $privlib
49 mansrc = $mansrc
50 manext = $manext
51 CFLAGS = $ccflags $optimize
52 LDFLAGS = $ldflags
53 SMALL = $small
54 LARGE = $large $split
55 mallocsrc = $mallocsrc
56 mallocobj = $mallocobj
57 SLN = $sln
58
59 libs = $libs -lm
60
61 public = perl taintperl $suidperl
62
63 !GROK!THIS!
64
65 cat >>Makefile <<'!NO!SUBS!'
66 private = 
67
68 MAKE = make
69
70 manpages = perl.man
71
72 util =
73
74 sh = Makefile.SH makedepend.SH
75
76 h1 = EXTERN.h INTERN.h arg.h array.h cmd.h config.h form.h handy.h
77 h2 = hash.h perl.h regcomp.h regexp.h spat.h stab.h str.h util.h
78
79 h = $(h1) $(h2)
80
81 c1 = array.c cmd.c cons.c consarg.c doarg.c doio.c dolist.c dump.c
82 c2 = eval.c form.c hash.c $(mallocsrc) perly.c regcomp.c regexec.c
83 c3 = stab.c str.c toke.c util.c
84
85 c = $(c1) $(c2) $(c3)
86
87 obj1 = array.o cmd.o cons.o consarg.o doarg.o doio.o dolist.o dump.o
88 obj2 = eval.o form.o hash.o $(mallocobj) perly.o regcomp.o regexec.o
89 obj3 = stab.o str.o toke.o util.o
90
91 obj = $(obj1) $(obj2) $(obj3)
92
93 tobj1 = tarray.o tcmd.o tcons.o tconsarg.o tdoarg.o tdoio.o tdolist.o tdump.o
94 tobj2 = teval.o tform.o thash.o $(mallocobj) tregcomp.o tregexec.o
95 tobj3 = tstab.o tstr.o ttoke.o tutil.o
96
97 tobj = $(tobj1) $(tobj2) $(tobj3)
98
99 lintflags = -hbvxac
100
101 addedbyconf = Makefile.old bsd eunice filexp loc pdp11 usg v7
102
103 # grrr
104 SHELL = /bin/sh
105
106 .c.o:
107         $(CC) -c $(CFLAGS) $(LARGE) $*.c
108
109 all: $(public) $(private) $(util) perl.man
110         cd x2p; $(MAKE) all
111         touch all
112
113 # This is the standard version that contains no "taint" checks and is
114 # used for all scripts that aren't set-id or running under something set-id.
115
116 perl: perl.o $(obj)
117         $(CC) $(LARGE) $(LDFLAGS) $(obj) perl.o $(libs) -o perl
118
119 # This version, if specified in Configure, does ONLY those scripts which need
120 # set-id emulation.  Suidperl must be setuid root.  It contains the "taint"
121 # checks as well as the special code to validate that the script in question
122 # has been invoked correctly.
123
124 suidperl: tperl.o sperly.o $(tobj)
125         $(CC) $(LARGE) $(LDFLAGS) sperly.o $(tobj) tperl.o $(libs) -o suidperl
126
127 # This version interprets scripts that are already set-id either via a wrapper
128 # or through the kernel allowing set-id scripts (bad idea).  Taintperl must
129 # NOT be setuid to root or anything else.  The only difference between it
130 # and normal perl is the presence of the "taint" checks.
131
132 taintperl: tperl.o tperly.o $(tobj)
133         $(CC) $(LARGE) $(LDFLAGS) tperly.o $(tobj) tperl.o $(libs) -o taintperl
134
135 # Replicating all this junk is yucky, but I don't see a portable way to fix it.
136
137 tperl.o: perl.c perly.h $(h)
138         /bin/rm -f tperl.c
139         $(SLN) perl.c tperl.c
140         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tperl.c
141         /bin/rm -f tperl.c
142
143 tperly.o: perly.c perly.h $(h)
144         /bin/rm -f tperly.c
145         $(SLN) perly.c tperly.c
146         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tperly.c
147         /bin/rm -f tperly.c
148
149 sperly.o: perly.c perly.h patchlevel.h $(h)
150         /bin/rm -f sperly.c
151         $(SLN) perly.c sperly.c
152         $(CC) -c -DTAINT -DIAMSUID $(CFLAGS) $(LARGE) sperly.c
153         /bin/rm -f sperly.c
154
155 tarray.o: array.c $(h)
156         /bin/rm -f tarray.c
157         $(SLN) array.c tarray.c
158         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tarray.c
159         /bin/rm -f tarray.c
160
161 tcmd.o: cmd.c $(h)
162         /bin/rm -f tcmd.c
163         $(SLN) cmd.c tcmd.c
164         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tcmd.c
165         /bin/rm -f tcmd.c
166
167 tcons.o: cons.c $(h)
168         /bin/rm -f tcons.c
169         $(SLN) cons.c tcons.c
170         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tcons.c
171         /bin/rm -f tcons.c
172
173 tconsarg.o: consarg.c $(h)
174         /bin/rm -f tconsarg.c
175         $(SLN) consarg.c tconsarg.c
176         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tconsarg.c
177         /bin/rm -f tconsarg.c
178
179 tdoarg.o: doarg.c $(h)
180         /bin/rm -f tdoarg.c
181         $(SLN) doarg.c tdoarg.c
182         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tdoarg.c
183         /bin/rm -f tdoarg.c
184
185 tdoio.o: doio.c $(h)
186         /bin/rm -f tdoio.c
187         $(SLN) doio.c tdoio.c
188         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tdoio.c
189         /bin/rm -f tdoio.c
190
191 tdolist.o: dolist.c $(h)
192         /bin/rm -f tdolist.c
193         $(SLN) dolist.c tdolist.c
194         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tdolist.c
195         /bin/rm -f tdolist.c
196
197 tdump.o: dump.c $(h)
198         /bin/rm -f tdump.c
199         $(SLN) dump.c tdump.c
200         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tdump.c
201         /bin/rm -f tdump.c
202
203 teval.o: eval.c $(h)
204         /bin/rm -f teval.c
205         $(SLN) eval.c teval.c
206         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) teval.c
207         /bin/rm -f teval.c
208
209 tform.o: form.c $(h)
210         /bin/rm -f tform.c
211         $(SLN) form.c tform.c
212         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tform.c
213         /bin/rm -f tform.c
214
215 thash.o: hash.c $(h)
216         /bin/rm -f thash.c
217         $(SLN) hash.c thash.c
218         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) thash.c
219         /bin/rm -f thash.c
220
221 tregcomp.o: regcomp.c $(h)
222         /bin/rm -f tregcomp.c
223         $(SLN) regcomp.c tregcomp.c
224         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tregcomp.c
225         /bin/rm -f tregcomp.c
226
227 tregexec.o: regexec.c $(h)
228         /bin/rm -f tregexec.c
229         $(SLN) regexec.c tregexec.c
230         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tregexec.c
231         /bin/rm -f tregexec.c
232
233 tstab.o: stab.c $(h)
234         /bin/rm -f tstab.c
235         $(SLN) stab.c tstab.c
236         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tstab.c
237         /bin/rm -f tstab.c
238
239 tstr.o: str.c $(h)
240         /bin/rm -f tstr.c
241         $(SLN) str.c tstr.c
242         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tstr.c
243         /bin/rm -f tstr.c
244
245 ttoke.o: toke.c $(h)
246         /bin/rm -f ttoke.c
247         $(SLN) toke.c ttoke.c
248         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) ttoke.c
249         /bin/rm -f ttoke.c
250
251 tutil.o: util.c $(h)
252         /bin/rm -f tutil.c
253         $(SLN) util.c tutil.c
254         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tutil.c
255         /bin/rm -f tutil.c
256
257 perl.c perly.h: perl.y
258         @ echo Expect 25 shift/reduce errors...
259         $(YACC) -d perl.y
260         mv y.tab.c perl.c
261         mv y.tab.h perly.h
262
263 perl.o: perl.c perly.h $(h)
264         $(CC) -c $(CFLAGS) $(LARGE) perl.c
265
266 perl.man: perl.man.1 perl.man.2 perl.man.3 perl.man.4 patchlevel.h perl
267         ./perl  -e '($$r,$$p)=$$]=~/(\d+\.\d+).*\n\D*(\d+)/;' \
268                 -e 'print ".ds RP Release $$r Patchlevel $$p\n";' >perl.man
269         cat perl.man.[1-4] >>perl.man
270
271 install: all
272 # won't work with csh
273         export PATH || exit 1
274         - rm -f $(bin)/perl.old $(bin)/suidperl $(bin)/taintperl
275         - mv $(bin)/perl $(bin)/perl.old 2>/dev/null
276         - if test `pwd` != $(bin); then cp $(public) $(bin); fi
277         - cd $(bin); \
278 for pub in $(public); do \
279 chmod +x `basename $$pub`; \
280 done
281         - chmod 755 $(bin)/taintperl 2>/dev/null
282 !NO!SUBS!
283
284 case "$d_dosuid" in
285 *define*)
286     cat >>Makefile <<'!NO!SUBS!'
287         - chmod 4711 $(bin)/suidperl 2>/dev/null
288 !NO!SUBS!
289     ;;
290 esac
291
292 cat >>Makefile <<'!NO!SUBS!'
293         - test $(bin) = /usr/bin || rm -f /usr/bin/perl
294         - test $(bin) = /usr/bin || $(SLN) $(bin)/perl /usr/bin || cp $(bin)/perl /usr/bin
295         - sh ./makedir $(privlib)
296         - \
297 if test `pwd` != $(privlib); then \
298 cp $(private) lib/*.pl $(privlib); \
299 fi
300 #       cd $(privlib); \
301 #for priv in $(private); do \
302 #chmod +x `basename $$priv`; \
303 #done
304         - if test `pwd` != $(mansrc); then \
305 for page in $(manpages); do \
306 cp $$page $(mansrc)/`basename $$page .man`.$(manext); \
307 done; \
308 fi
309         cd x2p; $(MAKE) install
310
311 clean:
312         rm -f *.o all perl taintperl $suidperl perl.man
313         cd x2p; $(MAKE) clean
314
315 realclean:
316         cd x2p; $(MAKE) realclean
317         rm -f perl *.orig */*.orig *~ */*~ *.o core $(addedbyconf) perl.man
318         rm -f perl.c perly.h t/perl Makefile config.h makedepend makedir
319         rm -f x2p/Makefile
320
321 # The following lint has practically everything turned on.  Unfortunately,
322 # you have to wade through a lot of mumbo jumbo that can't be suppressed.
323 # If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
324 # for that spot.
325
326 lint: perl.c $(c)
327         lint $(lintflags) $(defs) perl.c $(c) > perl.fuzz
328
329 depend: makedepend
330         - test -f perly.h || cp /dev/null perly.h
331         ./makedepend
332         - test -s perly.h || /bin/rm -f perly.h
333         cd x2p; $(MAKE) depend
334
335 test: perl
336         - chmod +x t/TEST t/base.* t/comp.* t/cmd.* t/io.* t/op.*; \
337         cd t && (rm -f perl; $(SLN) ../perl .) && ./perl TEST
338
339 clist:
340         echo $(c) | tr ' ' '\012' >.clist
341
342 hlist:
343         echo $(h) | tr ' ' '\012' >.hlist
344
345 shlist:
346         echo $(sh) | tr ' ' '\012' >.shlist
347
348 # AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
349 $(obj):
350         @ echo "You haven't done a "'"make depend" yet!'; exit 1
351 makedepend: makedepend.SH
352         /bin/sh makedepend.SH
353 !NO!SUBS!
354 $eunicefix Makefile
355 case `pwd` in
356 *SH)
357     $rm -f ../Makefile
358     ln Makefile ../Makefile
359     ;;
360 esac