VMS patches.
[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
82 LDFLAGS = $ldflags
83 CLDFLAGS = $ldflags
84
85 SMALL = $small
86 LARGE = $large $split
87 mallocsrc = $mallocsrc
88 mallocobj = $mallocobj
89 LNS = $lns
90 RMS = rm -f
91 ranlib = $ranlib
92
93 # The following are mentioned only to make metaconfig include the
94 # appropriate questions in Configure.  If you want to change these,
95 # edit config.sh instead, or specify --man1dir=/wherever on
96 # installman commandline.
97 bin = $installbin
98 scriptdir = $scriptdir
99 privlib = $installprivlib
100 man1dir = $man1dir
101 man1ext = $man1ext
102 man3dir = $man3dir
103 man3ext = $man3ext
104
105 # The following are used to build and install shared libraries for
106 # dynamic loading.
107 LDDLFLAGS = $lddlflags
108 CCDLFLAGS = $ccdlflags
109 DLSUFFIX = .$dlext
110 PLDLFLAGS = $pldlflags
111 PLIBSUF = $plibsuf
112 SHRPENV = $shrpenv
113
114 dynamic_ext = $dynamic_list
115 static_ext = $static_list
116 ext = \$(dynamic_ext) \$(static_ext)
117 static_ext_autoinit = $static_ai_list
118 DYNALOADER = lib/auto/DynaLoader/DynaLoader.a
119
120
121 libs = $libs $cryptlib
122
123 public = perl $suidperl utilities translators
124
125 shellflags = $shellflags
126
127 ## To use an alternate make, set \$altmake in config.sh.
128 MAKE = ${altmake-make}
129
130 # These variables will be used in a future version to make
131 # the make file more portable to non-unix systems.
132 AR = $ar
133 EXE_EXT = $exe_ext
134 LIB_EXT = $lib_ext
135 OBJ_EXT = $obj_ext
136 PATH_SEP = $path_sep
137
138 FIRSTMAKEFILE = $firstmakefile
139
140 # Any special object files needed by this architecture, e.g. os2/os2.obj
141 ARCHOBJS = $archobjs
142
143 !GROK!THIS!
144
145 ## In the following dollars and backticks do not need the extra backslash.
146 $spitshell >>Makefile <<'!NO!SUBS!'
147
148 CCCMD = `sh $(shellflags) cflags $(perllib) $@`
149
150 private = preplibrary lib/ExtUtils/Miniperl.pm lib/Config.pm
151
152 # Files to be built with variable substitution before miniperl
153 # is available.
154 sh = Makefile.SH cflags.SH config_h.SH makeaperl.SH makedepend.SH \
155         makedir.SH perl_exp.SH writemain.SH
156
157 shextract = Makefile cflags config.h makeaperl makedepend \
158         makedir perl_exp writemain
159
160 # Files to be built with variable substitution after miniperl is
161 # available.  Dependencies handled manually below (for now).
162
163 pl = pod/pod2html.PL pod/pod2latex.PL pod/pod2man.PL pod/pod2text.PL
164
165 plextract = pod/pod2html pod/pod2latex pod/pod2man pod/pod2text
166
167 addedbyconf = UU $(shextract) $(plextract) pstruct
168
169 h1 = EXTERN.h INTERN.h XSUB.h av.h config.h cop.h cv.h dosish.h
170 h2 = embed.h form.h gv.h handy.h hv.h keywords.h mg.h op.h
171 h3 = opcode.h patchlevel.h perl.h perly.h pp.h proto.h regcomp.h
172 h4 = regexp.h scope.h sv.h unixish.h util.h
173 h = $(h1) $(h2) $(h3) $(h4)
174
175 c1 = $(mallocsrc) av.c scope.c op.c doop.c doio.c dump.c hv.c mg.c
176 c2 = perl.c perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c
177 c3 = gv.c sv.c taint.c toke.c util.c deb.c run.c globals.c
178
179 c = $(c1) $(c2) $(c3) miniperlmain.c perlmain.c
180
181 obj1 = $(mallocobj) gv.o toke.o perly.o op.o regcomp.o dump.o util.o mg.o
182 obj2 = hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o
183 obj3 = doop.o doio.o regexec.o taint.o deb.o globals.o
184
185
186 obj = $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
187
188 # Once perl has been Configure'd and built ok you build different
189 # perl variants (Debugging, Embedded, Multiplicity etc) by saying:
190 #       make clean; make perllib=libperl<type>.a
191 # where <type> is some combination of 'd' and(or) 'e' or 'm'.
192 # See cflags to understand how this works.
193 #
194 # Eventually some form of 'make-a-perl' script will automate this
195 # together with linking a perl executable with any desired
196 # static modules.
197 perllib = libperl$(PLIBSUF)
198
199 lintflags = -hbvxac
200
201 # grrr
202 SHELL = /bin/sh
203
204 .c.o:
205         $(CCCMD) $(PLDLFLAGS) $*.c
206
207 all: makefile miniperl $(private) $(plextract) $(public) $(dynamic_ext)
208         @echo " "; echo "       Everything is up to date."
209
210 translators:    miniperl lib/Config.pm FORCE
211         @echo " "; echo "       Making x2p stuff"; cd x2p; $(MAKE) all
212
213 utilities:      miniperl lib/Config.pm FORCE
214         @echo " "; echo "       Making utilities"; cd utils; $(MAKE) all
215
216
217 # This is now done by installman only if you actually want the man pages.
218 #       @echo " "; echo "       Making docs"; cd pod; $(MAKE) all;
219
220 # Phony target to force checking subdirectories.
221 # Apparently some makes require an action for the FORCE target.
222 FORCE:
223         @sh -c true
224
225 # The $& notation tells Sequent machines that it can do a parallel make,
226 # and is harmless otherwise.
227
228 miniperl: $& miniperlmain.o $(perllib)
229         $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain.o $(perllib) $(libs)
230
231 miniperlmain.o: miniperlmain.c
232         $(CCCMD) $(PLDLFLAGS) $*.c
233
234 perlmain.c: miniperlmain.c config.sh makefile $(static_ext_autoinit)
235         sh writemain $(DYNALOADER) $(static_ext) > tmp
236         sh mv-if-diff tmp perlmain.c
237
238 perlmain.o: perlmain.c
239         $(CCCMD) $(PLDLFLAGS) $*.c
240
241 # The file ext.libs is a list of libraries that must be linked in
242 # for static extensions, e.g. -lm -lgdbm, etc.  The individual
243 # static extension Makefile's add to it.
244 ext.libs: $(static_ext)
245         -@test -f ext.libs || touch ext.libs
246
247 perl: $& perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
248         $(SHRPENV) $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
249
250 pureperl: $& perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
251         purify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
252
253 quantperl: $& perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
254         quantify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
255
256 $(perllib): $& perl.o $(obj)
257 !NO!SUBS!
258
259 case "$d_shrplib" in
260 *define*)
261 $spitshell >>Makefile <<'!NO!SUBS!'
262         $(LD) $(LDDLFLAGS) -o $@ perl.o $(obj)
263 !NO!SUBS!
264 ;;
265 *)
266 $spitshell >>Makefile <<'!NO!SUBS!'
267         rm -f $(perllib)
268         $(AR) rcu $(perllib) perl.o $(obj)
269         @$(ranlib) $(perllib)
270 !NO!SUBS!
271 ;;
272 esac
273
274 $spitshell >>Makefile <<'!NO!SUBS!'
275
276 # This version, if specified in Configure, does ONLY those scripts which need
277 # set-id emulation.  Suidperl must be setuid root.  It contains the "taint"
278 # checks as well as the special code to validate that the script in question
279 # has been invoked correctly.
280
281 suidperl: $& sperl.o perlmain.o $(perllib) $(DYNALOADER) $(static_ext) ext.libs
282         $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o suidperl perlmain.o sperl.o $(perllib) $(DYNALOADER) $(static_ext) `cat ext.libs` $(libs)
283
284 sperl.o: perl.c perly.h patchlevel.h $(h)
285         $(RMS) sperl.c
286         $(LNS) perl.c sperl.c
287         $(CCCMD) -DIAMSUID sperl.c
288         $(RMS) sperl.c
289
290 # We have to call our ./makedir because Ultrix 4.3 make can't handle the line
291 #       test -d lib/auto || mkdir lib/auto
292 #
293 preplibrary: miniperl lib/Config.pm $(plextract)
294         @./makedir lib/auto
295         @echo " AutoSplitting perl library"
296         @./miniperl -Ilib -e 'use AutoSplit; \
297                 autosplit_lib_modules(@ARGV)' lib/*.pm lib/*/*.pm
298
299 # Take care to avoid modifying lib/Config.pm without reason
300 lib/Config.pm: config.sh miniperl
301         ./miniperl configpm tmp
302         sh mv-if-diff tmp lib/Config.pm
303
304 lib/ExtUtils/Miniperl.pm: miniperlmain.c miniperl minimod.pl lib/Config.pm
305         ./miniperl minimod.pl > tmp && mv tmp $@
306
307 $(plextract):   miniperl lib/Config.pm
308         ./miniperl -Ilib $@.PL
309
310 install: all install.perl install.man
311
312 install.perl:   all
313         ./perl installperl
314
315 install.man:    all
316         ./perl installman
317
318 # Not implemented yet.
319 #install.html:  all
320 #       ./perl installhtml
321
322 # I now supply perly.c with the kits, so the following section is
323 # used only if you force byacc to run by saying
324 #       make run_byacc
325 # Since we patch up the byacc output, the perly.fixer script needs
326 # to run with precisely the same version of byacc as I use.  You
327 # normally shouldn't remake perly.[ch].
328
329 run_byacc:      FORCE
330         @ echo 'Expect' 129 shift/reduce and 1 reduce/reduce conflict
331         $(BYACC) -d perly.y
332         sh $(shellflags) ./perly.fixer y.tab.c perly.c
333         mv y.tab.h perly.h
334         echo 'extern YYSTYPE yylval;' >>perly.h
335         - perl vms/vms_yfix.pl perly.c perly.h vms/perly_c.vms vms/perly_h.vms
336
337 # We don't want to regenerate perly.c and perly.h, but they might
338 # appear out-of-date after a patch is applied or a new distribution is
339 # made.
340 perly.c: perly.y
341         -@touch perly.c
342
343 perly.h: perly.y
344         -@touch perly.h
345
346 # The following three header files are generated automatically
347 #       keywords.h:     keywords.pl
348 #       opcode.h:       opcode.pl
349 #       embed.h:        embed.pl global.sym interp.sym
350 # The correct versions should be already supplied with the perl kit,
351 # in case you don't have perl available.
352 # To force them to run, type
353 #       make regen_headers
354 regen_headers:  FORCE
355         perl keywords.pl
356         perl opcode.pl
357         perl embed.pl
358
359 # Extensions:
360 # Names added to $(dynamic_ext) or $(static_ext) will automatically
361 # get built.  There should ordinarily be no need to change any of
362 # this part of makefile.
363 #
364 # The dummy dependency is a place holder in case $(dynamic_ext) or
365 # $(static_ext) is empty.
366 #
367 # DynaLoader may be needed for extensions that use Makefile.PL.
368
369 $(DYNALOADER):  miniperl preplibrary FORCE
370         @sh ext/util/make_ext static $@ LIBPERL_A=$(perllib)
371
372 d_dummy $(dynamic_ext): miniperl preplibrary $(DYNALOADER) FORCE
373         @sh ext/util/make_ext dynamic $@ LIBPERL_A=$(perllib)
374
375 s_dummy $(static_ext):  miniperl preplibrary $(DYNALOADER) FORCE
376         @sh ext/util/make_ext static $@ LIBPERL_A=$(perllib)
377
378 clean:
379         rm -f *.o *.a all perlmain.c
380         rm -f perl.exp ext.libs
381         -cd pod; $(MAKE) clean
382         -cd utils; $(MAKE) clean
383         -cd x2p; $(MAKE) clean
384         -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) ; do \
385         sh ext/util/make_ext clean $$x ; \
386         done
387         rm -f perl suidperl miniperl $(perllib)
388
389 realclean: clean
390         -cd os2; rm -f Makefile
391         -cd pod; $(MAKE) realclean
392         -cd utils; $(MAKE) realclean
393         -cd x2p; $(MAKE) realclean
394         -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) ; do \
395         sh ext/util/make_ext realclean $$x ; \
396         done
397         rm -f *.orig */*.orig *~ */*~ core t/core t/c t/perl
398         rm -rf $(addedbyconf)
399         rm -f makefile makefile.old
400         rm -f $(private)
401         rm -rf lib/auto
402         rm -f lib/.exists
403         rm -f h2ph.man pstruct
404         rm -rf .config
405         @echo "Note that make realclean does not delete config.sh"
406
407 clobber:        realclean
408         rm -f config.sh cppstdin
409
410 distclean:      clobber
411
412 # The following lint has practically everything turned on.  Unfortunately,
413 # you have to wade through a lot of mumbo jumbo that can't be suppressed.
414 # If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
415 # for that spot.
416
417 lint: perly.c $(c)
418         lint $(lintflags) $(defs) perly.c $(c) > perl.fuzz
419
420 makefile:       Makefile
421         $(MAKE) depend
422
423 config.h: config.sh
424         /bin/sh config_h.SH
425
426 # When done, touch perlmain.c so that it doesn't get remade each time.
427 depend: makedepend
428         ./makedepend
429         - test -s perlmain.c && touch perlmain.c
430         cd x2p; $(MAKE) depend
431
432 test: miniperl perl preplibrary $(dynamic_ext)
433         - cd t && chmod +x TEST */*.t
434         - cd t && (rm -f perl; $(LNS) ../perl perl) && ./perl TEST </dev/tty
435
436 minitest: miniperl
437         - cd t && chmod +x TEST */*.t
438         - cd t && (rm -f perl; $(LNS) ../miniperl perl) \
439                 && ./perl TEST base/*.t comp/*.t cmd/*.t io/*.t op/*.t </dev/tty
440
441 clist:  $(c)
442         echo $(c) | tr ' ' '\012' >.clist
443
444 hlist:  $(h)
445         echo $(h) | tr ' ' '\012' >.hlist
446
447 shlist: $(sh)
448         echo $(sh) | tr ' ' '\012' >.shlist
449
450 pllist: $(pl)
451         echo $(pl) | tr ' ' '\012' >.pllist
452
453 # AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
454 # If this runs make out of memory, delete /usr/include lines.
455 !NO!SUBS!
456
457 $eunicefix Makefile
458 case `pwd` in
459 *SH)
460     $rm -f ../Makefile
461     ln Makefile ../Makefile
462     ;;
463 esac
464 rm -f makefile