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