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