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