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