af9e4acff1b606203be3881b81d2bb22e5b0f3cd
[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 2>/dev/null
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 4.0 91/03/20 00:58:54 lwall Locked $
29 #
30 # $Log: Makefile.SH,v $
31 # Revision 4.0  91/03/20  00:58:54  lwall
32 # 4.0 baseline.
33
34
35
36 CC = $cc
37 YACC = $yacc
38 bin = $installbin
39 scriptdir = $scriptdir
40 privlib = $installprivlib
41 mansrc = $mansrc
42 manext = $manext
43 CFLAGS = $ccflags $optimize
44 LDFLAGS = $ldflags
45 CLDFLAGS = $ldflags
46 SMALL = $small
47 LARGE = $large $split
48 mallocsrc = $mallocsrc
49 mallocobj = $mallocobj
50 SLN = $sln
51
52 libs = $libs $cryptlib
53
54 public = perl taintperl $suidperl
55
56 !GROK!THIS!
57
58 cat >>Makefile <<'!NO!SUBS!'
59 private = 
60
61 scripts = h2ph
62
63 MAKE = make
64
65 manpages = perl.man h2ph.man
66
67 util =
68
69 sh = Makefile.SH makedepend.SH h2ph.SH
70
71 h1 = EXTERN.h INTERN.h arg.h array.h cmd.h config.h form.h handy.h
72 h2 = hash.h perl.h regcomp.h regexp.h spat.h stab.h str.h util.h
73
74 h = $(h1) $(h2)
75
76 c1 = array.c cmd.c cons.c consarg.c doarg.c doio.c dolist.c dump.c
77 c2 = eval.c form.c hash.c $(mallocsrc) perl.c regcomp.c regexec.c
78 c3 = stab.c str.c toke.c util.c usersub.c
79
80 c = $(c1) $(c2) $(c3)
81
82 obj1 = array.o cmd.o cons.o consarg.o doarg.o doio.o dolist.o dump.o
83 obj2 = eval.o form.o hash.o $(mallocobj) perl.o regcomp.o regexec.o
84 obj3 = stab.o str.o toke.o util.o
85
86 obj = $(obj1) $(obj2) $(obj3)
87
88 tobj1 = tarray.o tcmd.o tcons.o tconsarg.o tdoarg.o tdoio.o tdolist.o tdump.o
89 tobj2 = teval.o tform.o thash.o $(mallocobj) tregcomp.o tregexec.o
90 tobj3 = tstab.o tstr.o ttoke.o tutil.o
91
92 tobj = $(tobj1) $(tobj2) $(tobj3)
93
94 lintflags = -hbvxac
95
96 addedbyconf = Makefile.old bsd eunice filexp loc pdp11 usg v7
97
98 # grrr
99 SHELL = /bin/sh
100
101 .c.o:
102         $(CC) -c $(CFLAGS) $(LARGE) $*.c
103
104 all: $(public) $(private) $(util) uperl.o $(scripts)
105         cd x2p; $(MAKE) all
106         touch all
107
108 # This is the standard version that contains no "taint" checks and is
109 # used for all scripts that aren't set-id or running under something set-id.
110
111 perl: $& perly.o $(obj) usersub.o
112         $(CC) $(LARGE) $(CLDFLAGS) $(obj) perly.o usersub.o $(libs) -o perl
113
114 uperl.o: $& perly.o $(obj)
115         -ld $(LARGE) $(LDFLAGS) -r $(obj) perly.o $(libs) -o uperl.o
116
117 saber: perly.c
118         # load $(c) perly.c
119
120 # This version, if specified in Configure, does ONLY those scripts which need
121 # set-id emulation.  Suidperl must be setuid root.  It contains the "taint"
122 # checks as well as the special code to validate that the script in question
123 # has been invoked correctly.
124
125 suidperl: $& tperly.o sperl.o $(tobj) usersub.o
126         $(CC) $(LARGE) $(CLDFLAGS) sperl.o $(tobj) tperly.o usersub.o $(libs) \
127             -o suidperl
128
129 # This version interprets scripts that are already set-id either via a wrapper
130 # or through the kernel allowing set-id scripts (bad idea).  Taintperl must
131 # NOT be setuid to root or anything else.  The only difference between it
132 # and normal perl is the presence of the "taint" checks.
133
134 taintperl: $& tperly.o tperl.o $(tobj) usersub.o
135         $(CC) $(LARGE) $(CLDFLAGS) tperl.o $(tobj) tperly.o usersub.o $(libs) \
136             -o taintperl
137
138 # Replicating all this junk is yucky, but I don't see a portable way to fix it.
139
140 tperly.o: perly.c perly.h $(h)
141         /bin/rm -f tperly.c
142         $(SLN) perly.c tperly.c
143         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tperly.c
144         /bin/rm -f tperly.c
145
146 tperl.o: perl.c perly.h patchlevel.h perl.h $(h)
147         /bin/rm -f tperl.c
148         $(SLN) perl.c tperl.c
149         $(CC) -c -DTAINT $(CFLAGS) $(LARGE) tperl.c
150         /bin/rm -f tperl.c
151
152 sperl.o: perl.c perly.h patchlevel.h $(h)
153         /bin/rm -f sperl.c
154         $(SLN) perl.c sperl.c
155         $(CC) -c -DTAINT -DIAMSUID $(CFLAGS) $(LARGE) sperl.c
156         /bin/rm -f sperl.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) perly.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) perly.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) perly.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 perly.h: perly.c
261         @ echo Dummy dependency for dumb parallel make
262         touch perly.h
263
264 perly.c: perly.y
265         @ echo 'Expect either' 29 shift/reduce and 59 reduce/reduce conflicts...
266         @ echo '           or' 27 shift/reduce and 61 reduce/reduce conflicts...
267         $(YACC) -d perly.y
268         sh perly.fixer y.tab.c perly.c
269         mv y.tab.h perly.h
270         echo 'extern YYSTYPE yylval;' >>perly.h
271
272 perly.o: perly.c perly.h $(h)
273         $(CC) -c $(CFLAGS) $(LARGE) perly.c
274
275 install: all
276         ./perl installperl
277         cd x2p; $(MAKE) install
278
279 clean:
280         rm -f *.o all perl taintperl suidperl
281         cd x2p; $(MAKE) clean
282
283 realclean: clean
284         cd x2p; $(MAKE) realclean
285         rm -f *.orig */*.orig *~ */*~ core $(addedbyconf) h2ph h2ph.man
286         rm -f perly.c perly.h t/perl Makefile config.h makedepend makedir
287         rm -f x2p/Makefile
288
289 # The following lint has practically everything turned on.  Unfortunately,
290 # you have to wade through a lot of mumbo jumbo that can't be suppressed.
291 # If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
292 # for that spot.
293
294 lint: perly.c $(c)
295         lint $(lintflags) $(defs) perly.c $(c) > perl.fuzz
296
297 depend: makedepend
298         - test -f perly.h || cp /dev/null perly.h
299         ./makedepend
300         - test -s perly.h || /bin/rm -f perly.h
301         cd x2p; $(MAKE) depend
302
303 test: perl
304         - cd t && chmod +x TEST */*.t
305         - cd t && (rm -f perl; $(SLN) ../perl .) && ./perl TEST </dev/tty
306
307 clist:
308         echo $(c) | tr ' ' '\012' >.clist
309
310 hlist:
311         echo $(h) | tr ' ' '\012' >.hlist
312
313 shlist:
314         echo $(sh) | tr ' ' '\012' >.shlist
315
316 # AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
317 $(obj):
318         @ echo "You haven't done a "'"make depend" yet!'; exit 1
319 makedepend: makedepend.SH
320         /bin/sh makedepend.SH
321 !NO!SUBS!
322 $eunicefix Makefile
323 case `pwd` in
324 *SH)
325     $rm -f ../Makefile
326     ln Makefile ../Makefile
327     ;;
328 esac