(Retracted by #9078.)
[p5sagit/p5-mst-13.2.git] / Makefile.SH
1 #! /bin/sh
2 case $CONFIGDOTSH in
3 '')
4         if 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         elif test -f ../../../../config.sh; then TOP=../../../..;
9         else
10                 echo "Can't find config.sh."; exit 1
11         fi
12         . $TOP/config.sh
13         ;;
14 esac
15 : This forces SH files to create target in same directory as SH file.
16 : This is so that make depend always knows where to find SH derivatives.
17 case "$0" in
18 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
19 esac
20
21 case "$d_dosuid" in
22 *define*) suidperl='suidperl' ;;
23 *) suidperl='';;
24 esac
25
26 linklibperl='$(LIBPERL)'
27 shrpldflags='$(LDDLFLAGS)'
28 ldlibpth=''
29 DPERL_EXTERNAL_GLOB='-DPERL_EXTERNAL_GLOB'
30 case "$useshrplib" in
31 true)
32         # Prefix all runs of 'miniperl' and 'perl' with 
33         # $ldlibpth so that ./perl finds *this* shared libperl.
34         case "$LD_LIBRARY_PATH" in
35         '')
36                 ldlibpth="LD_LIBRARY_PATH=`pwd`";;
37         *)
38                 ldlibpth="LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}";;
39         esac
40
41         pldlflags="$cccdlflags"
42         case "${osname}${osvers}" in
43         next4*)
44                 ld=libtool
45                 lddlflags="-dynamic -undefined warning -framework System \
46                 -compatibility_version 1 -current_version $patchlevel \
47                 -prebind -seg1addr 0x27000000 -install_name \$(shrpdir)/\$@"
48                 ;;
49         rhapsody*|darwin*)
50                 shrpldflags="${ldflags} -dynamiclib \
51                              -compatibility_version 1 \
52                              -current_version \
53                                 ${api_version}.${api_subversion} \
54                              -image_base 0x4be00000 \
55                              -install_name \$(shrpdir)/\$@"
56                 ;;
57         cygwin*)
58                 linklibperl="-lperl"
59                 ;;
60         sunos*)
61                 linklibperl="-lperl"
62                 ;;
63         netbsd*|freebsd[234]*|openbsd*)
64                 linklibperl="-L. -lperl"
65                 ;;
66         aix*)
67                 shrpldflags="-H512 -T512 -bhalt:4 -bM:SRE -bE:perl.exp"
68                 case "$osvers" in
69                 3*)     shrpldflags="$shrpldflags -e _nostart"
70                         ;;
71                 *)      shrpldflags="$shrpldflags -b noentry"
72                         ;;
73                 esac
74                 shrpldflags="$shrpldflags $ldflags $perllibs $cryptlib"
75                 linklibperl="-L $archlibexp/CORE -L `pwd | sed 's/\/UU$//'` -lperl"
76                 ;;
77         hpux*)
78                 linklibperl="-L `pwd | sed 's/\/UU$//'` -Wl,+s -Wl,+b$archlibexp/CORE -lperl"
79                 ;;
80         os390*)
81             shrpldflags='-W l,dll'
82             linklibperl='libperl.x'
83             DPERL_EXTERNAL_GLOB=''
84             ;;
85         esac
86         case "$ldlibpthname" in
87         '') ;;
88         *)
89             case "$osname" in
90             os2)
91                 ldlibpth=''
92                 ;;
93             *)
94                 eval "ldlibpth=\"$ldlibpthname=`pwd`:\$$ldlibpthname\""
95                 ;;
96             esac
97             # Strip off any trailing :'s
98             ldlibpth=`echo $ldlibpth | sed 's/:*$//'`
99             ;;
100         esac
101         ;;
102 *)      pldlflags=''
103         ;;
104 esac
105
106 : Prepare dependency lists for Makefile.
107 dynamic_list=' '
108 for f in $dynamic_ext; do
109     : the dependency named here will never exist
110       base=`echo "$f" | sed 's/.*\///'`
111     dynamic_list="$dynamic_list lib/auto/$f/$base.$dlext"
112 done
113
114 static_list=' '
115 for f in $static_ext; do
116         base=`echo "$f" | sed 's/.*\///'`
117         static_list="$static_list lib/auto/$f/$base\$(LIB_EXT)"
118 done
119
120 nonxs_list=' '
121 for f in $nonxs_ext; do
122     base=`echo "$f" | sed 's/.*\///'`
123     nonxs_list="$nonxs_list ext/$f/pm_to_blib"
124 done
125
126 # Handle the usage of different yaccs in posix-bc (During Configure we
127 # us yacc for perly.y and byacc for a2p.y.  The makefiles must use the
128 # same configuration for run_byacc!):
129 case "$osname" in
130     posix-bc)
131         byacc=$yacc
132         ;;
133 esac
134
135 # Handle the usage of different yaccs in posix-bc (During Configure we
136 # us yacc for perly.y and byacc for a2p.y.  The makefiles must use the
137 # same configuration for run_byacc!):
138 case "$osname" in
139     posix-bc)
140         byacc=$yacc
141         ;;
142 esac
143
144 echo "Extracting Makefile (with variable substitutions)"
145 $spitshell >Makefile <<!GROK!THIS!
146 # Makefile.SH
147 # This file is derived from Makefile.SH.  Any changes made here will
148 # be lost the next time you run Configure.
149 #  Makefile is used to generate $firstmakefile.  The only difference
150 #  is that $firstmakefile has the dependencies filled in at the end.
151 #
152 #
153 # I now supply perly.c with the kits, so don't remake perly.c without byacc
154 BYACC = $byacc
155 CC = $cc
156 LD = $ld
157
158 LDFLAGS = $ldflags
159 CLDFLAGS = $ldflags
160
161 mallocsrc = $mallocsrc
162 mallocobj = $mallocobj
163 LNS = $lns
164 CPS = $cp -f
165 RMS = rm -f
166 ranlib = $ranlib
167
168 # The following are mentioned only to make metaconfig include the
169 # appropriate questions in Configure.  If you want to change these,
170 # edit config.sh instead, or specify --man1dir=/wherever on
171 # installman commandline.
172 bin = $installbin
173 scriptdir = $scriptdir
174 shrpdir = $archlibexp/CORE
175 privlib = $installprivlib
176 man1dir = $man1dir
177 man1ext = $man1ext
178 man3dir = $man3dir
179 man3ext = $man3ext
180
181 # The following are used to build and install shared libraries for
182 # dynamic loading.
183 LDDLFLAGS = $lddlflags
184 SHRPLDFLAGS = $shrpldflags
185 CCDLFLAGS = $ccdlflags
186 DLSUFFIX = .$dlext
187 PLDLFLAGS = $pldlflags
188 LIBPERL = $libperl
189 LLIBPERL= $linklibperl
190 SHRPENV = $shrpenv
191
192 # The following is used to include the current directory in
193 # the dynamic loader path you are building a shared libperl.
194 LDLIBPTH = $ldlibpth
195
196 dynamic_ext = $dynamic_list
197 static_ext = $static_list
198 nonxs_ext = $nonxs_list
199 ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
200 DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
201
202 libs = $perllibs $cryptlib
203
204 public = perl $suidperl utilities translators
205
206 shellflags = $shellflags
207
208 # This is set to  MAKE=$make if your $make command doesn't
209 # do it for you.
210 $make_set_make
211
212 # These variables may need to be manually set for non-Unix systems.
213 AR = $full_ar
214 EXE_EXT = $_exe
215 LIB_EXT = $_a
216 OBJ_EXT = $_o
217 PATH_SEP = $p_
218
219 FIRSTMAKEFILE = $firstmakefile
220
221 # Any special object files needed by this architecture, e.g. os2/os2.obj
222 ARCHOBJS = $archobjs
223
224 .SUFFIXES: .c \$(OBJ_EXT)
225
226 # grrr
227 SHELL = $sh
228
229 # how to tr(anslate) newlines
230 TRNL = '$trnl'
231
232 !GROK!THIS!
233 # not used by Makefile but by installperl;
234 # mentioned here so that metaconfig picks these up
235 # $installusrbinperl
236 # $versiononly
237
238
239 ## In the following dollars and backticks do not need the extra backslash.
240 $spitshell >>Makefile <<'!NO!SUBS!'
241
242 CCCMD = `sh $(shellflags) cflags $(LIBPERL) $@`
243
244 private = preplibrary lib/ExtUtils/Miniperl.pm lib/Config.pm
245
246 # Files to be built with variable substitution before miniperl
247 # is available.
248 sh = Makefile.SH cflags.SH config_h.SH makeaperl.SH makedepend.SH \
249         makedir.SH myconfig.SH writemain.SH pod/Makefile.SH
250
251 shextract = Makefile cflags config.h makeaperl makedepend \
252         makedir myconfig writemain pod/Makefile
253
254 # Files to be built with variable substitution after miniperl is
255 # available.  Dependencies handled manually below (for now).
256
257 pl = pod/pod2html.PL pod/pod2latex.PL pod/pod2man.PL pod/pod2text.PL \
258         pod/pod2usage.PL pod/podchecker.PL pod/podselect.PL \
259         pod/buildtoc.PL
260
261 # lib/lib.pm is not listed here because it has a rule of its own.
262 plextract = pod/pod2html pod/pod2latex pod/pod2man pod/pod2text \
263         pod/pod2usage pod/podchecker pod/podselect \
264         pod/buildtoc
265
266 addedbyconf = UU $(shextract) $(plextract) lib/lib.pm pstruct
267
268 h1 = EXTERN.h INTERN.h XSUB.h av.h config.h cop.h cv.h dosish.h
269 h2 = embed.h form.h gv.h handy.h hv.h keywords.h mg.h op.h
270 h3 = opcode.h patchlevel.h perl.h perlapi.h perly.h pp.h proto.h regcomp.h
271 h4 = regexp.h scope.h sv.h unixish.h util.h iperlsys.h thread.h
272 h5 = utf8.h warnings.h
273 h = $(h1) $(h2) $(h3) $(h4) $(h5)
274
275 c1 = $(mallocsrc) av.c scope.c op.c doop.c doio.c dump.c hv.c mg.c
276 c2 = perl.c perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c utf8.c
277 c3 = gv.c sv.c taint.c toke.c util.c deb.c run.c universal.c xsutils.c
278 c4 = globals.c perlio.c perlapi.c
279
280 c = $(c1) $(c2) $(c3) $(c4) miniperlmain.c perlmain.c
281
282 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)
283 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)
284 obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) utf8$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) universal$(OBJ_EXT) xsutils$(OBJ_EXT) globals$(OBJ_EXT) perlio$(OBJ_EXT) perlapi$(OBJ_EXT)
285
286 obj = $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
287
288 # Once perl has been Configure'd and built ok you build different
289 # perl variants (Debugging, Embedded, Multiplicity etc) by saying:
290 #       make clean; make LIBPERL=libperl<type>.a
291 # where <type> is some combination of 'd' and(or) 'e' or 'm'.
292 # See cflags to understand how this works.
293 #
294 # This mechanism is getting clunky and might not even work any more.
295 # EMBEDDING is on by default, and MULTIPLICITY doesn't work.
296 #
297
298 lintflags = -hbvxac
299
300 .c$(OBJ_EXT):
301         $(CCCMD) $(PLDLFLAGS) $*.c
302
303 all: $(FIRSTMAKEFILE) miniperl extra.pods $(private) $(public) $(dynamic_ext) $(nonxs_ext)
304         @echo " ";
305         @echo " Everything is up to date. 'make test' to run test suite."
306
307 compile: all
308         echo "testing compilation" > testcompile;
309         cd utils;  $(MAKE) compile;
310         cd x2p; $(MAKE) compile; 
311         cd pod; $(MAKE) compile;
312
313 translators:    miniperl lib/Config.pm FORCE
314         @echo " "; echo "       Making x2p stuff"; cd x2p; $(LDLIBPTH) $(MAKE) all
315
316 utilities:      miniperl lib/Config.pm $(plextract) lib/lib.pm FORCE
317         @echo " "; echo "       Making utilities"; cd utils; $(LDLIBPTH) $(MAKE) all
318
319
320 # This is now done by installman only if you actually want the man pages.
321 #       @echo " "; echo "       Making docs"; cd pod; $(MAKE) all;
322
323 # Phony target to force checking subdirectories.
324 # Apparently some makes require an action for the FORCE target.
325 FORCE:
326         @sh -c true
327 !NO!SUBS!
328 $spitshell >>Makefile <<!GROK!THIS!
329
330 # We do a copy of the op.c instead of a symlink because gcc gets huffy
331 # if we have a symlink forest to another disk (it complains about too many
332 # levels of symbolic links, even if we have only two)
333
334 opmini\$(OBJ_EXT): op.c config.h
335         \$(RMS) opmini.c
336         \$(CPS) op.c opmini.c
337         \$(CCCMD) \$(PLDLFLAGS) $DPERL_EXTERNAL_GLOB opmini.c
338         \$(RMS) opmini.c
339
340 !GROK!THIS!
341 $spitshell >>Makefile <<'!NO!SUBS!'
342 miniperlmain$(OBJ_EXT): miniperlmain.c patchlevel.h
343         $(CCCMD) $(PLDLFLAGS) $*.c
344
345 perlmain.c: miniperlmain.c config.sh $(FIRSTMAKEFILE)
346         sh writemain $(DYNALOADER) $(static_ext) > writemain.tmp
347         sh mv-if-diff writemain.tmp perlmain.c
348
349 perlmain$(OBJ_EXT): perlmain.c
350         $(CCCMD) $(PLDLFLAGS) $*.c
351
352 # The file ext.libs is a list of libraries that must be linked in
353 # for static extensions, e.g. -lm -lgdbm, etc.  The individual
354 # static extension Makefile's add to it.
355 ext.libs: $(static_ext)
356         -@test -f ext.libs || touch ext.libs
357
358 !NO!SUBS!
359
360 # How to build libperl.  This is still rather convoluted.
361 # Load up custom Makefile.SH fragment for shared loading and executables:
362 case "$osname" in
363 *)
364         Makefile_s="$osname/Makefile.SHs"
365         ;;
366 esac
367
368 case "$osname" in
369 aix)
370         $spitshell >>Makefile <<!GROK!THIS!
371 LIBS                    = $perllibs
372 # In AIX we need to change this for building Perl itself from
373 # its earlier definition (which is for building external
374 # extensions *after* Perl has been built and installed)
375 CCDLFLAGS               = `echo $ccdlflags|sed -e 's@-bE:.*/perl\.exp@-bE:perl.exp@'`
376
377 !GROK!THIS!
378         case "$useshrplib" in
379         define|true|[yY]*)
380                 $spitshell >>Makefile <<'!NO!SUBS!'
381
382 LIBPERL_NONSHR          = libperl_nonshr$(LIB_EXT)
383 MINIPERL_NONSHR         = miniperl_nonshr$(EXE_EXT)
384
385 $(LIBPERL_NONSHR): perl$(OBJ_EXT) $(obj)
386         $(RMS) $(LIBPERL_NONSHR)
387         $(AR) rcu $(LIBPERL_NONSHR) perl$(OBJ_EXT) $(obj)
388
389 $(MINIPERL_NONSHR): $(LIBPERL_NONSHR) miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT)
390         $(CC) $(LDFLAGS) -o $(MINIPERL_NONSHR) miniperlmain$(OBJ_EXT) \
391             opmini$(OBJ_EXT) $(LIBPERL_NONSHR) $(LIBS)
392
393 MINIPERLEXP             = $(MINIPERL_NONSHR)
394
395 LIBPERLEXPORT           = perl.exp
396
397 !NO!SUBS!
398                 
399                 ;;
400         *)      
401                 $spitshell >>Makefile <<'!NO!SUBS!'
402 MINIPERLEXP             = miniperl$(EXE_EXT)
403
404 PERLEXPORT              = perl.exp
405
406 !NO!SUBS!
407         ;;
408         esac
409         $spitshell >>Makefile <<'!NO!SUBS!'
410 perl.exp: $(MINIPERLEXP) makedef.pl config.sh $(SYM) $(SYMH)
411         ./$(MINIPERLEXP) makedef.pl PLATFORM=aix | sort -u | sort -f > perl.exp.tmp
412         sh mv-if-diff perl.exp.tmp perl.exp
413
414 !NO!SUBS!
415         ;;
416 os2)
417         $spitshell >>Makefile <<'!NO!SUBS!'
418 MINIPERLEXP             = miniperl
419
420 perl5.def: $(MINIPERLEXP) makedef.pl config.sh $(SYM) $(SYMH) miniperl.map
421         ./$(MINIPERLEXP) makedef.pl PLATFORM=os2 -DPERL_DLL=$(PERL_DLL) > perl.exp.tmp
422         sh mv-if-diff perl.exp.tmp perl5.def
423
424 !NO!SUBS!
425         ;;
426 esac
427
428 if test -r $Makefile_s ; then
429         . $Makefile_s
430         $spitshell >>Makefile <<!GROK!THIS!
431
432 Makefile: $Makefile_s
433 !GROK!THIS!
434 else
435         $spitshell >>Makefile <<'!NO!SUBS!'
436 $(LIBPERL): $& perl$(OBJ_EXT) $(obj) $(LIBPERLEXPORT)
437 !NO!SUBS!
438         case "$useshrplib" in
439         true)
440                 $spitshell >>Makefile <<'!NO!SUBS!'
441         $(LD) -o $@ $(SHRPLDFLAGS) perl$(OBJ_EXT) $(obj)
442 !NO!SUBS!
443                 case "$osname" in
444                 aix)
445                         $spitshell >>Makefile <<'!NO!SUBS!'
446         rm -f libperl$(OBJ_EXT)
447         mv $@ libperl$(OBJ_EXT)
448         $(AR) qv $(LIBPERL) libperl$(OBJ_EXT)
449 !NO!SUBS!
450                         ;;
451                 esac
452                 ;;
453         *)
454                 $spitshell >>Makefile <<'!NO!SUBS!'
455         rm -f $(LIBPERL)
456         $(AR) rcu $(LIBPERL) perl$(OBJ_EXT) $(obj)
457         @$(ranlib) $(LIBPERL)
458 !NO!SUBS!
459                 ;;
460         esac
461         $spitshell >>Makefile <<'!NO!SUBS!'
462
463 # How to build executables.
464
465 # The $& notation tells Sequent machines that it can do a parallel make,
466 # and is harmless otherwise.
467 # The miniperl -w -MExporter line is a basic cheap test to catch errors
468 # before make goes on to run preplibrary and then MakeMaker on extensions.
469 # This is very handy because later errors are often caused by miniperl
470 # build problems but that's not obvious to the novice.
471 # The Module used here must not depend on Config or any extensions.
472
473 !NO!SUBS!
474
475         case "${osname}${osvers}" in
476         next4*)
477                 $spitshell >>Makefile <<'!NO!SUBS!'
478 miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL) opmini$(OBJ_EXT)
479         $(CC) -o miniperl `echo $(obj) | sed 's/ op$(OBJ_EXT) / /'` \
480             miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) perl$(OBJ_EXT) $(libs)
481         $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
482 !NO!SUBS!
483                 ;;
484         aix*)
485                 $spitshell >>Makefile <<'!NO!SUBS!'
486 miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL) opmini$(OBJ_EXT)
487         $(CC) -o miniperl $(CLDFLAGS) \
488             `echo $(obj) | sed 's/ op$(OBJ_EXT) / /'` \
489             miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) perl$(OBJ_EXT) $(libs)
490         $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
491 !NO!SUBS!
492                 ;;
493         *)
494                 $spitshell >>Makefile <<'!NO!SUBS!'
495 miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL) opmini$(OBJ_EXT)
496         $(LDLIBPTH) $(CC) $(CLDFLAGS) -o miniperl \
497             miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(LLIBPERL) $(libs)
498         $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
499 !NO!SUBS!
500                 ;;
501         esac
502
503         $spitshell >>Makefile <<'!NO!SUBS!'
504
505 perl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
506         $(SHRPENV) $(LDLIBPTH) $(CC) -o perl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
507
508 pureperl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
509         $(SHRPENV) $(LDLIBPTH) purify $(CC) -o pureperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
510
511 purecovperl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
512         $(SHRPENV) $(LDLIBPTH) purecov $(CC) -o purecovperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
513
514 quantperl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
515         $(SHRPENV) $(LDLIBPTH) quantify $(CC) -o quantperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
516
517 # This version, if specified in Configure, does ONLY those scripts which need
518 # set-id emulation.  Suidperl must be setuid root.  It contains the "taint"
519 # checks as well as the special code to validate that the script in question
520 # has been invoked correctly.
521
522 suidperl: $& sperl$(OBJ_EXT) perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
523         $(SHRPENV) $(LDLIBPTH) $(CC) -o suidperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) sperl$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
524
525 !NO!SUBS!
526
527 fi
528
529 $spitshell >>Makefile <<'!NO!SUBS!'
530
531 sperl$(OBJ_EXT): perl.c $(h)
532         $(RMS) sperl.c
533         $(LNS) perl.c sperl.c
534         $(CCCMD) -DIAMSUID sperl.c
535         $(RMS) sperl.c
536
537 # We have to call our ./makedir because Ultrix 4.3 make can't handle the line
538 #       test -d lib/auto || mkdir lib/auto
539 #
540 preplibrary: miniperl lib/Config.pm
541         @sh ./makedir lib/auto
542         @echo " AutoSplitting perl library"
543         $(LDLIBPTH) ./miniperl -Ilib -e 'use AutoSplit; \
544                 autosplit_lib_modules(@ARGV)' lib/*.pm lib/*/*.pm
545
546 # Take care to avoid modifying lib/Config.pm without reason
547 # (If trying to create a new port and having problems with the configpm script, 
548 # try 'make minitest' and/or commenting out the tests at the end of configpm.)
549 lib/Config.pm: config.sh miniperl configpm lib/re.pm
550         $(LDLIBPTH) ./miniperl configpm configpm.tmp
551         sh mv-if-diff configpm.tmp $@
552
553 lib/ExtUtils/Miniperl.pm: miniperlmain.c miniperl minimod.pl lib/Config.pm
554         $(LDLIBPTH) ./miniperl minimod.pl > minimod.tmp
555         sh mv-if-diff minimod.tmp $@
556
557 lib/re.pm: ext/re/re.pm
558         rm -f $@
559         cat ext/re/re.pm > $@
560
561 $(plextract):   miniperl lib/Config.pm
562         $(LDLIBPTH) ./miniperl -Ilib $@.PL
563
564 lib/lib.pm:     miniperl lib/Config.pm
565         $(LDLIBPTH) ./miniperl -Ilib lib/lib_pm.PL
566
567 extra.pods: miniperl
568         -@test -f extra.pods && rm -f `cat extra.pods`
569         -@rm -f extra.pods
570         -@for x in `grep -l '^=[a-z]' README.* | grep -v README.vms` ; do \
571             nx=`echo $$x | sed -e "s/README\.//"`; \
572             cd pod ; $(LNS) ../$$x "perl"$$nx".pod" ; cd .. ; \
573             echo "pod/perl"$$nx".pod" >> extra.pods ; \
574         done
575         -@test -f vms/perlvms.pod && cd pod && $(LNS) ../vms/perlvms.pod perlvms.pod && cd .. && echo "pod/perlvms.pod" >> extra.pods
576
577 install-strip:
578         $(MAKE) STRIPFLAGS=-s install
579
580 install:
581         $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS)
582
583 install-verbose:
584         $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-V
585
586 install-silent:
587         $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-S
588
589 no-install:
590         $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-n
591
592 install.perl:   all installperl
593         if [ -n "$(COMPILE)" ]; \
594         then \
595                 cd utils; $(MAKE) compile; \
596                 cd ../x2p; $(MAKE) compile; \
597                 cd ../pod; $(MAKE) compile; \
598         else :; \
599         fi
600         $(LDLIBPTH) ./perl installperl $(INSTALLFLAGS) $(STRIPFLAGS)
601
602 install.man:    all installman
603         $(LDLIBPTH) ./perl installman $(INSTALLFLAGS)
604
605 # XXX Experimental. Hardwired values, but useful for testing.
606 # Eventually Configure could ask for some of these values.
607 install.html: all installhtml
608         -@test -f README.vms && cd vms && $(LNS) ../README.vms README_vms.pod && cd ..
609         $(LDLIBPTH) ./perl installhtml                   \
610       --podroot=. --podpath=. --recurse  \
611       --htmldir=$(privlib)/html     \
612       --htmlroot=$(privlib)/html    \
613       --splithead=pod/perlipc     \
614       --splititem=pod/perlfunc    \
615       --libpods=perlfunc:perlguts:perlvar:perlrun:perlop \
616       --verbose
617
618
619 # I now supply perly.c with the kits, so the following section is
620 # used only if you force byacc to run by saying
621 #       make run_byacc
622 # Since we patch up the byacc output, the perly.fixer script needs
623 # to run with precisely the same version of byacc as I use.  You
624 # normally shouldn't remake perly.[ch].
625
626 run_byacc:      FORCE
627         $(BYACC) -d perly.y
628         -chmod 664 perly.c perly.h
629         sh $(shellflags) ./perly.fixer y.tab.c perly.c
630         sed -e 's/fprintf *( *stderr *,/PerlIO_printf(Perl_debug_log,/g' \
631             -e 's/y\.tab/perly/g' perly.c >perly.tmp && mv perly.tmp perly.c
632         sed -e '/^extern YYSTYPE yy/D' y.tab.h >yh.tmp && mv yh.tmp y.tab.h
633         cmp -s y.tab.h perly.h && rm -f y.tab.h || mv y.tab.h perly.h
634         chmod 664 vms/perly_c.vms vms/perly_h.vms
635         perl vms/vms_yfix.pl perly.c perly.h vms/perly_c.vms vms/perly_h.vms
636
637 # We don't want to regenerate perly.c and perly.h, but they might
638 # appear out-of-date after a patch is applied or a new distribution is
639 # made.
640 perly.c: perly.y
641         -@sh -c true
642
643 perly.h: perly.y
644         -@sh -c true
645
646 PERLYVMS = vms/perly_c.vms vms/perly_h.vms
647
648 $(PERLYVMS):    perly.c perly.h vms/vms_yfix.pl
649         perl vms/vms_yfix.pl perly.c perly.h vms/perly_c.vms vms/perly_h.vms
650
651 # No compat3.sym here since and including the 5.004_50.
652 # No interp.sym since 5.005_03.
653 SYM  = global.sym globvar.sym perlio.sym pp.sym
654
655 SYMH = perlvars.h intrpvar.h thrdvar.h
656
657 CHMOD_W = chmod +w
658
659 # The following files are generated automatically
660 #       keywords.pl:    keywords.h
661 #       opcode.pl:      opcode.h opnames.h pp_proto.h pp.sym
662 # [* embed.pl needs pp.sym generated by opcode.pl! *]
663 #       embed.pl:       proto.h embed.h embedvar.h global.sym objXSUB.h
664 #                       perlapi.h perlapi.c pod/perlintern.pod
665 #                       pod/perlapi.pod
666 #       bytecode.pl:    ext/ByteLoader/byterun.h ext/ByteLoader/byterun.c
667 #                       ext/B/B/Asmdata.pm
668 #       regcomp.pl:     regnodes.h
669 #       warnings.pl:    warnings.h lib/warnings.pm
670 # The correct versions should be already supplied with the perl kit,
671 # in case you don't have perl available.
672 # To force them to be regenerated, type
673 #       make regen_headers
674
675 keywords.h:     keywords.pl
676         -perl keywords.pl
677
678 OPCODE_PL_OUTPUT = opcode.h opnames.h pp_proto.h pp.sym
679
680 $(OPCODE_PL_OUTPUT): opcode.pl
681         -perl opcode.pl
682
683 # Really the prerequisites for the next rule  should only be "embed.pl pp.sym"
684 # Writing it this way gives make a big hint to always run opcode.pl before
685 # embed.pl. The alternative - running embed.pl then opcode.pl causes embed.pl
686 # to be re-run next make invocation, and then all object files get recompiled.
687
688 proto.h embed.h embedvar.h global.sym objXSUB.h perlapi.h perlapi.c pod/perlintern.pod pod/perlapi.pod: embed.pl $(OPCODE_PL_OUTPUT)
689         -perl embed.pl
690
691 ext/ByteLoader/byterun.h ext/ByteLoader/byterun.c ext/B/B/Asmdata.pm: bytecode.pl
692         -perl bytecode.pl
693
694 regnodes.h:     regcomp.pl
695         -perl regcomp.pl
696
697 warnings.h lib/warnings.pm: warnings.pl
698         -perl warnings.pl
699
700 AUTOGEN_FILES = keywords.h opcode.h opnames.h pp_proto.h pp.sym proto.h \
701                 embed.h embedvar.h global.sym \
702                 pod/perlintern.pod pod/perlapi.pod \
703                 objXSUB.h perlapi.h perlapi.c ext/ByteLoader/byterun.h \
704                 ext/ByteLoader/byterun.c ext/B/B/Asmdata.pm regnodes.h \
705                 warnings.h lib/warnings.pm
706
707 regen_headers:  FORCE
708         -$(CHMOD_W) $(AUTOGEN_FILES)
709         -perl keywords.pl
710         -perl opcode.pl
711         -perl embed.pl
712         -perl bytecode.pl
713         -perl regcomp.pl
714         -perl warnings.pl
715
716 regen_pods:     FORCE
717         -cd pod; $(LDLIBPTH) make regen_pods
718
719 regen_all: $(PERLYVMS) regen_headers regen_pods
720
721 # Extensions:
722 # Names added to $(dynamic_ext) or $(static_ext) or $(nonxs_ext) will
723 # automatically get built.  There should ordinarily be no need to change
724 # any of this part of makefile.
725 #
726 # The dummy dependency is a place holder in case $(dynamic_ext) or
727 # $(static_ext) is empty.
728 #
729 # DynaLoader may be needed for extensions that use Makefile.PL.
730
731 $(DYNALOADER):  miniperl preplibrary FORCE
732         @$(LDLIBPTH) sh ext/util/make_ext static $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
733
734 d_dummy $(dynamic_ext): miniperl preplibrary $(DYNALOADER) FORCE
735         @$(LDLIBPTH) sh ext/util/make_ext dynamic $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
736
737 s_dummy $(static_ext):  miniperl preplibrary $(DYNALOADER) FORCE
738         @$(LDLIBPTH) sh ext/util/make_ext static $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
739
740 n_dummy $(nonxs_ext):   miniperl preplibrary $(DYNALOADER) FORCE
741         @$(LDLIBPTH) sh ext/util/make_ext nonxs $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
742
743 clean:          _tidy _mopup
744
745 realclean:      _realcleaner _mopup
746         @echo "Note that make realclean does not delete config.sh or Policy.sh"
747
748 _clobber:
749         rm -f config.sh cppstdin Policy.sh
750
751 clobber:        _realcleaner _mopup _clobber
752
753 distclean:      clobber
754
755 # Like distclean but also removes emacs backups and *.orig.
756 veryclean:      _verycleaner _mopup _clobber
757         -@rm -f Obsolete Wanted
758
759 # Do not 'make _mopup' directly.
760 _mopup:
761         rm -f *$(OBJ_EXT) *$(LIB_EXT) all perlmain.c
762         -@test -f extra.pods && rm -f `cat extra.pods`
763         -@test -f vms/README_vms.pod && rm -f vms/README_vms.pod
764         -rm -f perl.exp ext.libs extra.pods opmini.o
765         -rm -f perl.export perl.dll perl.libexp perl.map perl.def
766         -rm -f perl.loadmap miniperl.loadmap perl.prelmap miniperl.prelmap
767         rm -f perl suidperl miniperl $(LIBPERL) libperl.* microperl
768
769 # Do not 'make _tidy' directly.
770 _tidy:
771         -cd pod; $(LDLIBPTH) $(MAKE) clean
772         -cd utils; $(LDLIBPTH) $(MAKE) clean
773         -cd x2p; $(LDLIBPTH) $(MAKE) clean
774         -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
775         $(LDLIBPTH) sh ext/util/make_ext clean $$x MAKE=$(MAKE) ; \
776         done
777         rm -f testcompile compilelog
778
779 _cleaner1:
780         -cd os2; rm -f Makefile
781         -cd pod; $(LDLIBPTH) $(MAKE) $(CLEAN)
782         -cd utils; $(LDLIBPTH) $(MAKE) $(CLEAN)
783         -cd x2p; $(LDLIBPTH) $(MAKE) $(CLEAN)
784         -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
785         $(LDLIBPTH) sh ext/util/make_ext $(CLEAN) $$x MAKE=$(MAKE) ; \
786         done
787
788 _cleaner2:
789         rm -f core core.*perl.*.? *perl.core t/core t/core.perl.*.? t/*perl.core t/misctmp* t/forktmp* t/tmp* t/c t/perl t/rantests .?*.c so_locations $(LIBPERL_NONSHR) $(MINIPERL_NONSHR)
790         rm -rf $(addedbyconf)
791         rm -f $(FIRSTMAKEFILE) $(FIRSTMAKEFILE).old
792         rm -f $(private)
793         rm -rf lib/auto
794         rm -f lib/.exists lib/*/.exists lib/*/*/.exists
795         rm -f h2ph.man pstruct
796         rm -rf .config
797         rm -f testcompile compilelog
798         -rmdir lib/B lib/Data lib/Encode lib/IO/Socket lib/IO lib/Filter/Util lib/Sys lib/Thread
799
800 _realcleaner: 
801         @$(LDLIBPTH) $(MAKE) _cleaner1 CLEAN=realclean
802         @$(LDLIBPTH) $(MAKE) _cleaner2
803
804 _verycleaner: 
805         @$(LDLIBPTH) $(MAKE) _cleaner1 CLEAN=veryclean
806         @$(LDLIBPTH) $(MAKE) _cleaner2
807         -rm -f *~ *.orig */*~ */*.orig */*/*~ */*/*.orig
808
809 # The following lint has practically everything turned on.  Unfortunately,
810 # you have to wade through a lot of mumbo jumbo that can't be suppressed.
811 # If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
812 # for that spot.
813
814 lint: $(c)
815         lint $(lintflags) $(defs) perly.c $(c) > perl.fuzz
816
817 # Need to unset during recursion to go out of loop.
818 # The README below ensures that the dependency list is never empty and
819 # that when MAKEDEPEND is empty $(FIRSTMAKEFILE) doesn't need rebuilding.
820
821 MAKEDEPEND = Makefile makedepend
822
823 $(FIRSTMAKEFILE):       README $(MAKEDEPEND)
824         $(MAKE) depend MAKEDEPEND=
825
826 config.h: config_h.SH config.sh
827         $(SHELL) config_h.SH
828
829 # When done, touch perlmain.c so that it doesn't get remade each time.
830 depend: makedepend
831         sh ./makedepend MAKE=$(MAKE)
832         - test -s perlmain.c && touch perlmain.c
833         cd x2p; $(MAKE) depend
834
835 # Cannot postpone this until $firstmakefile is ready ;-)
836 makedepend: makedepend.SH config.sh
837         sh ./makedepend.SH
838
839 # Cannot delegate rebuilding of t/perl to make to allow interlaced
840 # test and minitest
841 test-prep: miniperl perl preplibrary utilities $(dynamic_ext) $(nonxs_ext) $(TEST_PERL_DLL)
842         cd t && (rm -f perl$(EXE_EXT); $(LNS) ../perl$(EXE_EXT) perl$(EXE_EXT))
843
844 # Second branch is for testing without a tty or controling terminal.
845 # See t/op/stat.t
846 test check: test-prep
847         if (true </dev/tty) >/dev/null 2>&1; then \
848           cd t && $(LDLIBPTH) ./perl TEST </dev/tty; \
849         else \
850           cd t && PERL_SKIP_TTY_TEST=1 $(LDLIBPTH) ./perl TEST; \
851         fi
852         @echo "Ran tests" > t/rantests
853
854 utest ucheck: test-prep
855         if (true </dev/tty) >/dev/null 2>&1; then \
856           cd t && $(LDLIBPTH) ./perl TEST -utf8 </dev/tty; \
857         else \
858           cd t && PERL_SKIP_TTY_TEST=1 $(LDLIBPTH) ./perl TEST -utf8; \
859         fi
860
861 # For testing without a tty or controling terminal. See t/op/stat.t
862 test-notty: test-prep
863         cd t && PERL_SKIP_TTY_TEST=1 $(LDLIBPTH) ./perl TEST
864
865 # Can't depend on lib/Config.pm because that might be where miniperl
866 # is crashing.
867 minitest: miniperl lib/re.pm
868         @echo "You may see some irrelevant test failures if you have been unable"
869         @echo "to build lib/Config.pm."
870         - cd t && (rm -f perl$(EXE_EXT); $(LNS) ../miniperl$(EXE_EXT) perl$(EXE_EXT)) \
871                 && $(LDLIBPTH) ./perl TEST base/*.t comp/*.t cmd/*.t run/*.t io/*.t op/*.t pragma/*.t </dev/tty
872
873 # Handy way to run perlbug -ok without having to install and run the
874 # installed perlbug. We don't re-run the tests here - we trust the user.
875 # Please *don't* use this unless all tests pass.
876 # If you want to report test failures, use "make nok" instead.
877 ok:     utilities
878         $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)'
879
880 okfile: utilities
881         $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok
882
883 oknack: utilities
884         $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -A
885
886 okfilenack:     utilities
887         $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok -A
888
889 nok:    utilities
890         $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)'
891
892 nokfile:        utilities
893         $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -F perl.nok
894
895 noknack:        utilities
896         $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -A
897
898 nokfilenack:    utilities
899         $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -F perl.nok -A
900
901 clist:  $(c)
902         echo $(c) | tr ' ' $(TRNL) >.clist
903
904 hlist:  $(h)
905         echo $(h) | tr ' ' $(TRNL) >.hlist
906
907 shlist: $(sh)
908         echo $(sh) | tr ' ' $(TRNL) >.shlist
909
910 pllist: $(pl)
911         echo $(pl) | tr ' ' $(TRNL) >.pllist
912
913 Makefile: Makefile.SH ./config.sh
914         $(SHELL) Makefile.SH
915
916 distcheck: FORCE
917         perl '-MExtUtils::Manifest=&fullcheck' -e 'fullcheck()'
918
919 elc:    emacs/cperl-mode.elc
920
921 emacs/cperl-mode.elc: emacs/cperl-mode.el
922         -cd emacs; emacs -batch -q -no-site-file -f batch-byte-compile cperl-mode.el
923
924 etags:  TAGS
925
926 TAGS: emacs/cperl-mode.elc
927         sh emacs/ptags
928
929 ctags:  tags
930
931 # Let's hope make will not go into an infinite loop on case-unsensitive systems
932 # This may also fail if . is in the head of the path, since perl will
933 # require -Ilib
934 tags:   TAGS
935         perl emacs/e2ctags.pl TAGS > tags
936
937 # AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
938 # If this runs make out of memory, delete /usr/include lines.
939 !NO!SUBS!
940
941 $eunicefix Makefile
942 case `pwd` in
943 *SH)
944     $rm -f ../Makefile
945     $ln Makefile ../Makefile
946     ;;
947 esac
948 $rm -f $firstmakefile
949
950 # Now do any special processing required before building.
951
952 case "$ebcdic" in
953 $define)
954     xxx=''
955     echo "This is an EBCDIC system, checking if any parser files need regenerating." >&4
956 case "$osname" in
957 os390|posix-bc)
958     rm -f y.tab.c y.tab.h
959     # yacc must be a reentrant ("pure") Bison in BS2000 Posix!
960     yacc -d perly.y >/dev/null 2>&1
961     if cmp -s y.tab.c perly.c; then
962         rm -f y.tab.c
963     else
964         echo "perly.y -> perly.c" >&2
965         mv -f y.tab.c perly.c
966         chmod u+w perly.c
967         sed -e '/^#include "perl\.h"/a\
968 \
969 #define yydebug    PL_yydebug\
970 #define yynerrs    PL_yynerrs\
971 #define yyerrflag  PL_yyerrflag\
972 #define yychar     PL_yychar\
973 #define yyval      PL_yyval\
974 #define yylval     PL_yylval'                           \
975             -e '/YYSTYPE *yyval;/D'                     \
976             -e '/YYSTYPE *yylval;/D'                    \
977             -e '/int  yychar,/,/yynerrs;/D'             \
978             -e 's/int yydebug = 0;/yydebug = 0;/'       \
979             -e 's/[^_]realloc(/PerlMem_realloc(/g'      \
980             -e 's/fprintf *( *stderr *,/PerlIO_printf(Perl_debug_log,/g' \
981             -e 's/y\.tab/perly/g' perly.c >perly.tmp && mv perly.tmp perly.c
982         xxx="$xxx perly.c"
983     fi
984     if cmp -s y.tab.h perly.h; then
985         rm -f y.tab.h
986     else
987         echo "perly.y -> perly.h" >&2
988         mv -f y.tab.h perly.h
989         xxx="$xxx perly.h"
990     fi
991     if cd x2p
992     then
993         rm -f y.tab.c y.tab.h
994         case "$osname" in
995         posix-bc)
996            # we are using two different yaccs in BS2000 Posix!
997            byacc a2p.y >/dev/null 2>&1
998            ;;
999         *) # e.g. os390
1000            yacc  a2p.y >/dev/null 2>&1
1001            ;;
1002         esac
1003         if cmp -s y.tab.c a2p.c
1004         then
1005             rm -f y.tab.c
1006         else
1007             echo "a2p.y -> a2p.c" >&2
1008             mv -f y.tab.c a2p.c
1009             chmod u+w a2p.c
1010             sed -e 's/fprintf *( *stderr *,/PerlIO_printf(Perl_debug_log,/g' \
1011                 -e 's|^static void __YY_YACC_MAIN.*BS2000.*|/*static main deleted*/|' \
1012                 -e 's/y\.tab/a2p/g' a2p.c >a2p.tmp && mv a2p.tmp a2p.c
1013             xxx="$xxx a2p.c"
1014         fi
1015         # In case somebody yacc -d:ed the a2p.y.
1016         if test -f y.tab.h
1017         then
1018             if cmp -s y.tab.h a2p.h
1019             then
1020                 rm -f y.tab.h
1021             else
1022                 echo "a2p.h -> a2p.h" >&2
1023                 mv -f y.tab.h a2p.h
1024                 xxx="$xxx a2p.h"
1025             fi
1026         fi
1027         cd ..
1028     fi
1029     ;;
1030 vmesa)
1031     # Do nothing in VM/ESA.
1032     ;;
1033 *)
1034     echo "'$osname' is an EBCDIC system I don't know that well." >&4
1035     ;;
1036 esac
1037     case "$xxx" in
1038     '') echo "No parser files were regenerated.  That's okay." >&2 ;;
1039     esac
1040     ;;
1041 esac
1042