77b38938898d06dc56b8fa08fa4c2a461e1ddd41
[p5sagit/p5-mst-13.2.git] / Makefile.SH
1 case $CONFIG in
2 '')
3         if test -f config.sh; then TOP=.;
4         elif test -f ../config.sh; then TOP=..;
5         elif test -f ../../config.sh; then TOP=../..;
6         elif test -f ../../../config.sh; then TOP=../../..;
7         elif test -f ../../../../config.sh; then TOP=../../../..;
8         else
9                 echo "Can't find config.sh."; exit 1
10         fi
11         . $TOP/config.sh
12         ;;
13 esac
14 : This forces SH files to create target in same directory as SH file.
15 : This is so that make depend always knows where to find SH derivatives.
16 case "$0" in
17 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
18 esac
19
20 case "$d_dosuid" in
21 *define*) suidperl='suidperl' ;;
22 *) suidperl='';;
23 esac
24
25 shrpenv=""
26 case "$d_shrplib" in
27 *define*)
28     patchlevel=`egrep '^#define[        ]+PATCHLEVEL' patchlevel.h \
29         | awk '{print $3}'`
30     case "$patchlevel" in
31      *[0-9]) plibsuf=.$so.$patchlevel;;
32      *)     plibsuf=.$so;;
33     esac
34     case "$shrpdir" in
35      /usr/lib)  ;;
36      "")        ;;
37      *)         shrpenv="env LD_RUN_PATH=$shrpdir";;
38     esac
39     pldlflags="$cccdlflags";;
40 *)  plibsuf=.a
41     pldlflags="";;
42 esac
43
44 : Prepare dependency lists for Makefile.
45 dynamic_list=' '
46 for f in $dynamic_ext; do
47     : the dependency named here will never exist
48       base=`echo "$f" | sed 's/.*\///'`
49     dynamic_list="$dynamic_list lib/auto/$f/$base.$dlext"
50 done
51
52 static_list=' '
53 static_ai_list=' '
54 for f in $static_ext; do
55         base=`echo "$f" | sed 's/.*\///'`
56         static_list="$static_list lib/auto/$f/$base.a"
57         if test -f ext/$f/AutoInit.c; then
58             static_ai_list="$static_ai_list ext/$f/AutoInit.c"
59         fi
60         if test -f ext/$f/AutoInit.pl; then
61             static_ai_list="$static_ai_list ext/$f/AutoInit.pl"
62         fi
63 done
64
65 echo "Extracting Makefile (with variable substitutions)"
66 $spitshell >Makefile <<'!NO!SUBS!'
67 # Makefile.SH
68 # This file is derived from Makefile.SH.  Any changes made here will
69 # be lost the next time you run Configure.
70 #  Makefile is used to generate makefile.  The only difference
71 #  is that makefile has the dependencies filled in at the end.
72 #
73 #
74 !NO!SUBS!
75
76 $spitshell >>Makefile <<!GROK!THIS!
77 # I now supply perly.c with the kits, so don't remake perly.c without byacc
78 BYACC = $byacc
79 CC = $cc
80 LD = $ld
81 bin = $installbin
82 scriptdir = $scriptdir
83 privlib = $installprivlib
84 mansrc = $mansrc
85 manext = $manext
86 LDFLAGS = $ldflags
87 CLDFLAGS = $ldflags
88
89 SMALL = $small
90 LARGE = $large $split
91 mallocsrc = $mallocsrc
92 mallocobj = $mallocobj
93 LNS = $lns
94 RMS = rm -f
95 ranlib = $ranlib
96
97 # The following are used to build and install shared libraries for
98 # dynamic loading.
99 LDDLFLAGS = $lddlflags
100 CCDLFLAGS = $ccdlflags
101 DLSUFFIX = .$dlext
102 PLDLFLAGS = $pldlflags
103 PLIBSUF = $plibsuf
104 SHRPENV = $shrpenv
105
106 dynamic_ext = $dynamic_list
107 static_ext = $static_list
108 ext = \$(dynamic_ext) \$(static_ext)
109 static_ext_autoinit = $static_ai_list
110 DYNALOADER = lib/auto/DynaLoader/DynaLoader.a
111
112
113 libs = $libs $cryptlib
114
115 public = perl $suidperl
116
117 shellflags = $shellflags
118
119 ## To use an alternate make, set \$altmake in config.sh.
120 MAKE = ${altmake-make}
121 !GROK!THIS!
122
123 ## In the following dollars and backticks do not need the extra backslash.
124 $spitshell >>Makefile <<'!NO!SUBS!'
125
126 CCCMD = `sh $(shellflags) cflags $(perllib) $@`
127
128 private = preplibrary lib/ExtUtils/Miniperl.pm lib/Config.pm
129
130 scripts =
131
132 manpages = perl.man
133
134 util =
135
136 sh = Makefile.SH cflags.SH makedepend.SH makedir.SH writemain.SH
137
138 h1 = EXTERN.h INTERN.h XSUB.h av.h config.h cop.h cv.h dosish.h
139 h2 = embed.h form.h gv.h handy.h hv.h keywords.h mg.h op.h
140 h3 = opcode.h patchlevel.h perl.h perly.h pp.h proto.h regcomp.h
141 h4 = regexp.h scope.h sv.h unixish.h util.h
142 h = $(h1) $(h2) $(h3) $(h4)
143
144 c1 = $(mallocsrc) av.c scope.c op.c doop.c doio.c dump.c hv.c mg.c
145 c2 = perl.c perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c
146 c3 = gv.c sv.c taint.c toke.c util.c deb.c run.c globals.c
147
148 c = $(c1) $(c2) $(c3) miniperlmain.c perlmain.c
149
150 obj1 = $(mallocobj) gv.o toke.o perly.o op.o regcomp.o dump.o util.o mg.o
151 obj2 = hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o
152 obj3 = doop.o doio.o regexec.o taint.o deb.o globals.o
153
154 obj = $(obj1) $(obj2) $(obj3)
155
156 # Once perl has been Configure'd and built ok you build different
157 # perl variants (Debugging, Embedded, Multiplicity etc) by saying:
158 #       make clean; make perllib=libperl<type>.a
159 # where <type> is some combination of 'd' and(or) 'e' or 'm'.
160 # See cflags to understand how this works.
161 #
162 # Eventually some form of 'make-a-perl' script will automate this
163 # together with linking a perl executable with any desired
164 # static modules.
165 perllib = libperl$(PLIBSUF)
166
167 lintflags = -hbvxac
168
169 addedbyconf = UU
170
171 # grrr
172 SHELL = /bin/sh
173
174 .c.o:
175         $(CCCMD) $(PLDLFLAGS) $*.c
176
177 all: makefile miniperl $(private) $(public) $(dynamic_ext)
178         @echo " "; echo "       Making x2p stuff"; cd x2p; $(MAKE) all
179         @echo " "; echo "       Making docs"; cd pod; $(MAKE) all;
180
181 # Phony target to force checking subdirectories.
182 FORCE:
183
184 !NO!SUBS!
185
186 : Now on to the rest of the Makefile.
187 $spitshell >>Makefile <<'!NO!SUBS!'
188 # The $& notation tells Sequent machines that it can do a parallel make,
189 # and is harmless otherwise.
190
191 miniperl: $& miniperlmain.o $(perllib)
192         $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain.o $(perllib) $(libs)
193
194 miniperlmain.o: miniperlmain.c
195         $(CCCMD) $(PLDLFLAGS) $*.c
196
197 perlmain.c: miniperlmain.c config.sh makefile $(static_ext_autoinit)
198         sh writemain $(DYNALOADER) $(static_ext) > tmp
199         sh mv-if-diff tmp perlmain.c
200
201 perlmain.o: perlmain.c
202         $(CCCMD) $(PLDLFLAGS) $*.c
203
204 # The file ext.libs is a list of libraries that must be linked in
205 # for static extensions, e.g. -lm -lgdbm, etc.  The individual
206 # static extension Makefile's add to it.
207 ext.libs: $(static_ext)
208         -@test -f ext.libs || touch ext.libs
209
210 perl: $& perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
211         $(SHRPENV) $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
212
213 pureperl: $& perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
214         purify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
215
216 quantperl: $& perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
217         quantify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
218
219 $(perllib): $& perl.o $(obj)
220 !NO!SUBS!
221
222 case "$d_shrplib" in
223 *define*)
224 $spitshell >>Makefile <<'!NO!SUBS!'
225         $(LD) $(LDDLFLAGS) -o $@ perl.o $(obj)
226 !NO!SUBS!
227 ;;
228 *)
229 $spitshell >>Makefile <<'!NO!SUBS!'
230         ar rcu $(perllib) perl.o $(obj)
231         @$(ranlib) $(perllib)
232 !NO!SUBS!
233 ;;
234 esac
235
236 $spitshell >>Makefile <<'!NO!SUBS!'
237
238 # This version, if specified in Configure, does ONLY those scripts which need
239 # set-id emulation.  Suidperl must be setuid root.  It contains the "taint"
240 # checks as well as the special code to validate that the script in question
241 # has been invoked correctly.
242
243 suidperl: $& sperl.o perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
244         $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o suidperl perlmain.o sperl.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
245
246 sperl.o: perl.c perly.h patchlevel.h $(h)
247         $(RMS) sperl.c
248         $(LNS) perl.c sperl.c
249         $(CCCMD) -DIAMSUID sperl.c
250         $(RMS) sperl.c
251
252 opcode.h: opcode.pl
253         - perl opcode.pl
254
255 embed.h: embed_h.sh global.sym interp.sym
256         sh embed_h.sh
257
258 # We have to call our ./makedir because Ultrix 4.3 make can't handle the line
259 #       test -d lib/auto || mkdir lib/auto
260 #
261 preplibrary: miniperl lib/Config.pm
262         @./makedir lib/auto
263         @echo " AutoSplitting perl library"
264         @./miniperl -Ilib -e 'use AutoSplit; \
265                 autosplit_lib_modules(@ARGV)' lib/*.pm lib/*/*.pm
266
267 # Take care to avoid modifying lib/Config.pm without reason
268 lib/Config.pm: config.sh miniperl
269         ./miniperl configpm tmp
270         sh mv-if-diff tmp lib/Config.pm
271
272 lib/ExtUtils/Miniperl.pm: miniperlmain.c miniperl minimod.PL lib/Config.pm
273         ./miniperl minimod.PL > tmp && mv tmp $@
274
275 install: all
276         ./perl installperl
277
278 # I now supply perly.c with the kits, so the following section is
279 # used only if you force byacc to run by saying
280 #       make run_byacc
281 # Since we patch up the byacc output, the perly.fixer script needs
282 # to run with precisely the same version of byacc as I use.  You
283 # normally shouldn't remake perly.[ch].
284
285 run_byacc:      FORCE
286         @ echo 'Expect' 109 shift/reduce and 1 reduce/reduce conflict
287         $(BYACC) -d perly.y
288         sh $(shellflags) ./perly.fixer y.tab.c perly.c
289         mv y.tab.h perly.h
290         echo 'extern YYSTYPE yylval;' >>perly.h
291
292 # We don't want to regenerate perly.c and perly.h, but they might
293 # appear out-of-date after a patch is applied or a new distribution is
294 # made.
295 perly.c: perly.y
296         -@touch perly.c
297
298 perly.h: perly.y
299         -@touch perly.h
300
301 # Extensions:
302 # Names added to $(dynamic_ext) or $(static_ext) will automatically
303 # get built.  There should ordinarily be no need to change any of
304 # this part of makefile.
305 #
306 # The dummy dependency is a place holder in case $(dynamic_ext) or
307 # $(static_ext) is empty.
308 #
309 # DynaLoader may be needed for extensions that use Makefile.PL.
310
311 $(DYNALOADER):  miniperl preplibrary FORCE
312         @sh ext/util/make_ext static $@ LIBPERL_A=$(perllib)
313
314 d_dummy $(dynamic_ext): miniperl preplibrary $(DYNALOADER) FORCE
315         @sh ext/util/make_ext dynamic $@ LIBPERL_A=$(perllib)
316
317 s_dummy $(static_ext):  miniperl preplibrary $(DYNALOADER) FORCE
318         @sh ext/util/make_ext static $@ LIBPERL_A=$(perllib)
319
320 clean:
321         rm -f *.o *.a all perlmain.c
322         rm -f perl.exp ext.libs
323         -cd x2p; $(MAKE) clean
324         -cd pod; $(MAKE) clean
325         -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) ; do \
326         sh ext/util/make_ext clean $$x ; \
327         done
328         rm -f perl suidperl miniperl $(perllib)
329
330 realclean: clean
331         -cd x2p; $(MAKE) realclean
332         @for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) ; do \
333         sh ext/util/make_ext realclean $$x ; \
334         done
335         rm -f *.orig */*.orig *~ */*~ core t/core t/c t/perl
336         rm -rf $(addedbyconf)
337         rm -f Makefile cflags makedepend makedir writemain
338         rm -f config.h makefile makefile.old
339         rm -f $(private)
340         rm -rf lib/auto
341         rm -f lib/.exists
342         rm -f h2ph h2ph.man c2ph pstruct h2xs makeaperl
343         rm -rf .config
344         @echo "Note that make realclean does not delete config.sh"
345
346 clobber:        realclean
347         rm -f config.sh cppstdin
348
349 distclean:      clobber
350
351 # The following lint has practically everything turned on.  Unfortunately,
352 # you have to wade through a lot of mumbo jumbo that can't be suppressed.
353 # If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
354 # for that spot.
355
356 lint: perly.c $(c)
357         lint $(lintflags) $(defs) perly.c $(c) > perl.fuzz
358
359 makefile:       Makefile
360         $(MAKE) depend
361
362 config.h: config.sh
363         /bin/sh config_h.SH
364
365 # When done, touch perlmain.c so that it doesn't get remade each time.
366 depend: makedepend
367         ./makedepend
368         - test -s perlmain.c && touch perlmain.c
369         cd x2p; $(MAKE) depend
370
371 test: miniperl perl preplibrary $(dynamic_ext)
372         - cd t && chmod +x TEST */*.t
373         - cd t && (rm -f perl; $(LNS) ../perl perl) && ./perl TEST </dev/tty
374
375 clist:  $(c)
376         echo $(c) | tr ' ' '\012' >.clist
377
378 hlist:  $(h)
379         echo $(h) | tr ' ' '\012' >.hlist
380
381 shlist: $(sh)
382         echo $(sh) | tr ' ' '\012' >.shlist
383
384 # AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
385 # If this runs make out of memory, delete /usr/include lines.
386 !NO!SUBS!
387
388 $eunicefix Makefile
389 case `pwd` in
390 *SH)
391     $rm -f ../Makefile
392     ln Makefile ../Makefile
393     ;;
394 esac
395 rm -f makefile