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