This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Prevent "use sort 'stable'" from reversing the order
[perl5.git] / Makefile.SH
1 #! /bin/sh
2 case $PERL_CONFIG_SH in
3 '')
4         if test -f config.sh
5                 then TOP=.
6         else
7                 echo "Can't find config.sh."; exit 1
8         fi
9         . $TOP/config.sh
10         ;;
11 esac
12
13 # H.Merijn Brand [17 Feb 2004]
14 # This comment is just to ensure that Configure will find variables that
15 # are removed/replaced in patches on blead, but are still needed in the
16 # 5.8.x, 5.6.x and 5.005.x maintainance tracks.
17 # metaconfig -m will scan all .SH files on this level (not deeper), and
18 # not in x2p and other subfolders. This file is as good as any .SH
19 # patch   references
20 # #22227 $baserev
21 # #22302 $yacc $byacc
22
23 # H.Merijn Brand [30 Oct 2004]
24 # Mentioned for the same reason for future reference
25 # #23434 $d_strlcat $d_strlcpy
26
27 : This forces SH files to create target in same directory as SH file.
28 : This is so that make depend always knows where to find SH derivatives.
29 case "$0" in
30 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
31 esac
32
33 case "$d_dosuid" in
34 *define*) suidperl='suidperl' ;;
35 *) suidperl='';;
36 esac
37
38 linklibperl='$(LIBPERL)'
39 shrpldflags='$(LDDLFLAGS)'
40 ldlibpth=''
41 DPERL_EXTERNAL_GLOB='-DPERL_EXTERNAL_GLOB'
42 case "$useshrplib" in
43 true)
44         # Prefix all runs of 'miniperl' and 'perl' with
45         # $ldlibpth so that ./perl finds *this* shared libperl.
46         case "$LD_LIBRARY_PATH" in
47         '')
48                 ldlibpth="LD_LIBRARY_PATH=`pwd`";;
49         *)
50                 ldlibpth="LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}";;
51         esac
52
53         pldlflags="$cccdlflags"
54         static_target='static_pic'
55         case "${osname}${osvers}" in
56         next4*)
57                 ld=libtool
58                 lddlflags="-dynamic -undefined warning -framework System \
59                 -compatibility_version 1 -current_version $patchlevel \
60                 -prebind -seg1addr 0x27000000 -install_name \$(shrpdir)/\$@"
61                 ;;
62         rhapsody*|darwin*)
63                 shrpldflags="${ldflags} -dynamiclib \
64                             -compatibility_version \
65                                 ${api_revision}.${api_version}.${api_subversion} \
66                              -current_version \
67                                 ${revision}.${patchlevel}.${subversion} \
68                              -install_name \$(shrpdir)/\$@"
69                 ;;
70         cygwin*)
71                 linklibperl="-lperl"
72                 ;;
73         sunos*)
74                 linklibperl="-lperl"
75                 ;;
76         netbsd*|freebsd[234]*|openbsd*|dragonfly*)
77                 linklibperl="-L. -lperl"
78                 ;;
79         interix*)
80                 linklibperl="-L. -lperl"
81                 shrpldflags="$shrpldflags -Wl,--image-base,0x57000000"
82                 ;;
83         aix*)
84                 shrpldflags="-H512 -T512 -bhalt:4 -bM:SRE -bE:perl.exp"
85                 case "$osvers" in
86                 3*)     shrpldflags="$shrpldflags -e _nostart"
87                         ;;
88                 *)      shrpldflags="$shrpldflags -b noentry"
89                         ;;
90                 esac
91                 shrpldflags="$shrpldflags $ldflags $perllibs $cryptlib"
92                 linklibperl="-L $archlibexp/CORE -L `pwd | sed 's/\/UU$//'` -lperl"
93                 ;;
94         hpux*)
95                 linklibperl="-L `pwd | sed 's/\/UU$//'` -Wl,+s -Wl,+b$archlibexp/CORE -lperl"
96                 ;;
97         os390*)
98             shrpldflags='-W l,dll'
99             linklibperl='libperl.x'
100             DPERL_EXTERNAL_GLOB=''
101             ;;
102         esac
103         case "$ldlibpthname" in
104         '') ;;
105         *)
106             case "$osname" in
107             os2)
108                 ldlibpth=''
109                 ;;
110             *)
111                 eval "ldlibpth=\"$ldlibpthname=`pwd`:\$$ldlibpthname\""
112                 ;;
113             esac
114             # Strip off any trailing :'s
115             ldlibpth=`echo $ldlibpth | sed 's/:*$//'`
116             ;;
117         esac
118
119         case "$ldlibpth" in
120         # Protect any spaces
121         *" "*) ldlibpth=`echo $ldlibpth|sed 's/ /\\\\ /g'` ;;
122         esac
123
124         case "$osname" in
125         linux)
126             # If there is a pre-existing $libperl from a previous
127             # installation, Linux needs to use LD_PRELOAD to
128             # override the LD_LIBRARY_PATH setting.  See the
129             # INSTALL file, under "Building a shared perl library".
130             # If there is no pre-existing $libperl, we don't need
131             # to do anything further.
132             if test -f $archlib/CORE/$libperl; then
133                 rm -f preload
134                 cat <<'EOT' > preload
135 #! /bin/sh
136 lib=$1
137 shift
138 test -r $lib && export LD_PRELOAD="$lib $LD_PRELOAD"
139 exec "$@"
140 EOT
141                 chmod 755 preload
142                 ldlibpth="$ldlibpth `pwd`/preload `pwd`/$libperl"
143             fi
144             ;;
145         os390)  test -f /bin/env && ldlibpth="/bin/env $ldlibpth"
146                 ;;
147         esac
148
149         ;;
150
151 *)      pldlflags=''
152         static_target='static'
153         ;;
154 esac
155
156 : Prepare dependency lists for Makefile.
157 dynamic_list=' '
158 for f in $dynamic_ext; do
159     : the dependency named here will never exist
160       base=`echo "$f" | sed 's/.*\///'`
161     dynamic_list="$dynamic_list lib/auto/$f/$base.$dlext"
162 done
163
164 static_list=' '
165 for f in $static_ext; do
166         base=`echo "$f" | sed 's/.*\///'`
167         static_list="$static_list lib/auto/$f/$base\$(LIB_EXT)"
168 done
169
170 nonxs_list=' '
171 for f in $nonxs_ext; do
172     base=`echo "$f" | sed 's/.*\///'`
173     nonxs_list="$nonxs_list ext/$f/pm_to_blib"
174 done
175
176 echo "Extracting Makefile (with variable substitutions)"
177 $spitshell >Makefile <<!GROK!THIS!
178 # Makefile.SH
179 # This file is derived from Makefile.SH.  Any changes made here will
180 # be lost the next time you run Configure.
181 #  Makefile is used to generate $firstmakefile.  The only difference
182 #  is that $firstmakefile has the dependencies filled in at the end.
183
184 CC = $cc
185 LD = $ld
186
187 LDFLAGS = $ldflags
188 CLDFLAGS = $ldflags
189
190 mallocsrc = $mallocsrc
191 mallocobj = $mallocobj
192 madlyh = $madlyh
193 madlysrc = $madlysrc
194 madlyobj = $madlyobj
195 LNS = $lns
196 # NOTE: some systems don't grok "cp -f". XXX Configure test needed?
197 CPS = $cp
198 RMS = rm -f
199 ranlib = $ranlib
200
201 # The following are mentioned only to make metaconfig include the
202 # appropriate questions in Configure.  If you want to change these,
203 # edit config.sh instead, or specify --man1dir=/wherever on
204 # installman commandline.
205 bin = $installbin
206 scriptdir = $scriptdir
207 shrpdir = $archlibexp/CORE
208 privlib = $installprivlib
209 man1dir = $man1dir
210 man1ext = $man1ext
211 man3dir = $man3dir
212 man3ext = $man3ext
213
214 # The following are used to build and install shared libraries for
215 # dynamic loading.
216 LDDLFLAGS = $lddlflags
217 SHRPLDFLAGS = $shrpldflags
218 CCDLFLAGS = $ccdlflags
219 DLSUFFIX = .$dlext
220 PLDLFLAGS = $pldlflags
221 LIBPERL = $libperl
222 LLIBPERL= $linklibperl
223 SHRPENV = $shrpenv
224
225 # Static targets are ordinarily built without CCCDLFLAGS.  However,
226 # if building a shared libperl.so that might later be linked into
227 # another application, then it might be appropriate to also build static
228 # extensions (usually just DynaLoader) with relocatable code (e.g. -fPIC
229 # for GNU cc).  This is handled by ext/util/make_ext.
230 STATIC = $static_target
231
232 # The following is used to include the current directory in
233 # the dynamic loader path you are building a shared libperl.
234 LDLIBPTH = $ldlibpth
235
236 dynamic_ext = $dynamic_list
237 static_ext = $static_list
238 nonxs_ext = $nonxs_list
239 ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
240 DYNALOADER = DynaLoader\$(OBJ_EXT)
241
242 libs = $perllibs $cryptlib
243
244 public = perl\$(EXE_EXT) $suidperl utilities translators
245
246 shellflags = $shellflags
247
248 # This is set to  MAKE=$make if your $make command doesn't
249 # do it for you.
250 $make_set_make
251
252 # Mention $gmake here so it gets probed for by Configure.
253
254 # These variables may need to be manually set for non-Unix systems.
255 AR = $full_ar
256 EXE_EXT = $_exe
257 LIB_EXT = $_a
258 OBJ_EXT = $_o
259 PATH_SEP = $p_
260
261 # If you're going to use valgrind and it can't be invoked as plain valgrind
262 # then you'll need to change this, or override it on the make command line.
263 VALGRIND=valgrind
264
265 FIRSTMAKEFILE = $firstmakefile
266
267 # Any special object files needed by this architecture, e.g. os2/os2.obj
268 ARCHOBJS = $archobjs
269
270 .SUFFIXES: .c \$(OBJ_EXT) .i .s
271
272 # grrr
273 SHELL = $sh
274
275 # how to tr(anslate) newlines
276 TRNL = '$trnl'
277
278 OPTIMIZE = $optimize
279
280 EXTRAS = $extras
281
282 INSTALLPREFIXEXP = $prefix
283
284 !GROK!THIS!
285 # not used by Makefile but by installperl;
286 # mentioned here so that metaconfig picks these up
287 # $installusrbinperl
288 # $versiononly
289
290 case "${osname}:${osvers}" in
291 darwin:*)
292 $spitshell >>Makefile <<EOF
293
294 # Your locales are broken (osname $osname, osvers $osvers)
295 # and to avoid the numerous
296 # perl: warning: Setting locale failed.
297 # warnings during the build process we reset the locale variables.
298
299 LC_ALL=C
300 LANG=C
301 LANGUAGE=C
302 EOF
303         ;;
304 esac
305
306 ## In the following dollars and backticks do not need the extra backslash.
307 $spitshell >>Makefile <<'!NO!SUBS!'
308
309 CCCMD    = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $@`
310
311 CCCMDSRC = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $<`
312
313 CONFIGPM = lib/Config.pm lib/Config_heavy.pl
314 private = preplibrary $(CONFIGPM) lib/Config.pod lib/ExtUtils/Miniperl.pm
315
316 # Files to be built with variable substitution before miniperl
317 # is available.
318 sh = Makefile.SH cflags.SH config_h.SH makeaperl.SH makedepend.SH \
319         makedir.SH myconfig.SH writemain.SH pod/Makefile.SH
320
321 shextract = Makefile cflags config.h makeaperl makedepend \
322         makedir myconfig writemain pod/Makefile
323
324 # Files to be built with variable substitution after miniperl is
325 # available.  Dependencies handled manually below (for now).
326
327 pl = pod/pod2html.PL pod/pod2latex.PL pod/pod2man.PL pod/pod2text.PL \
328         pod/pod2usage.PL pod/podchecker.PL pod/podselect.PL
329
330 # lib/lib.pm is not listed here because it has a rule of its own.
331 plextract = pod/pod2html pod/pod2latex pod/pod2man pod/pod2text \
332         pod/pod2usage pod/podchecker pod/podselect
333
334 addedbyconf = UU $(shextract) $(plextract) lib/lib.pm pstruct
335
336 # Unicode data files generated by mktables
337 unidatafiles = lib/unicore/Canonical.pl lib/unicore/Exact.pl \
338         lib/unicore/Properties lib/unicore/Decomposition.pl \
339         lib/unicore/CombiningClass.pl lib/unicore/Name.pl lib/unicore/PVA.pl
340
341 # Directories of Unicode data files generated by mktables
342 unidatadirs = lib/unicore/To lib/unicore/lib
343
344 h1 = EXTERN.h INTERN.h XSUB.h av.h config.h cop.h cv.h dosish.h
345 h2 = embed.h form.h gv.h handy.h hv.h keywords.h mg.h op.h opcode.h
346 h3 = pad.h patchlevel.h perl.h perlapi.h perly.h pp.h proto.h regcomp.h
347 h4 = regexp.h scope.h sv.h unixish.h util.h iperlsys.h thread.h
348 h5 = utf8.h warnings.h $(madlyh)
349 h = $(h1) $(h2) $(h3) $(h4) $(h5)
350
351 c1 = av.c scope.c op.c doop.c doio.c dump.c gv.c hv.c mg.c reentr.c  perl.c
352 c2 = perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c utf8.c sv.c
353 c3 = taint.c toke.c util.c deb.c run.c universal.c xsutils.c pad.c globals.c
354 c4 = perlio.c perlapi.c numeric.c mathoms.c locale.c pp_pack.c pp_sort.c
355 c5 = $(madlysrc) $(mallocsrc)
356
357 c = $(c1) $(c2) $(c3) $(c4) $(c5) miniperlmain.c perlmain.c opmini.c
358
359 obj1 = $(madlyobj) $(mallocobj) gv$(OBJ_EXT) toke$(OBJ_EXT) perly$(OBJ_EXT) op$(OBJ_EXT) pad$(OBJ_EXT) regcomp$(OBJ_EXT) dump$(OBJ_EXT) util$(OBJ_EXT) mg$(OBJ_EXT) reentr$(OBJ_EXT)
360 obj2 = hv$(OBJ_EXT) av$(OBJ_EXT) perl$(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)
361 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) numeric$(OBJ_EXT) mathoms$(OBJ_EXT) locale$(OBJ_EXT) pp_pack$(OBJ_EXT) pp_sort$(OBJ_EXT)
362
363 obj = $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
364
365 lintflags = \
366     -b \
367     -n \
368     -p \
369     -Ncheck=%all \
370     -Nlevel=4 \
371     -errchk=parentheses \
372     -errhdr=%all \
373     -errfmt=src \
374     -errtags \
375     -erroff=E_ASSIGN_NARROW_CONV \
376     -erroff=E_BAD_PTR_CAST \
377     -erroff=E_BAD_PTR_CAST_ALIGN \
378     -erroff=E_BAD_PTR_INT_COMBINATION \
379     -erroff=E_BAD_SIGN_EXTEND \
380     -erroff=E_BLOCK_DECL_UNUSED \
381     -erroff=E_CASE_FALLTHRU \
382     -erroff=E_CONSTANT_CONDITION \
383     -erroff=E_EQUALITY_NOT_ASSIGNMENT \
384     -erroff=E_EXPR_NULL_EFFECT \
385     -erroff=E_FALSE_LOGICAL_EXPR \
386     -erroff=E_INCL_NUSD \
387     -erroff=E_INDISTING_FROM_TRUNC \
388     -erroff=E_LOOP_EMPTY \
389     -erroff=E_MAIN_PARAM \
390     -erroff=E_POINTER_TO_OBJECT \
391     -erroff=E_PTRDIFF_OVERFLOW \
392     -erroff=E_SHIFT_CNT_NEG_TOO_BIG_L \
393     -erroff=E_STATIC_UNUSED \
394     -erroff=E_TRUE_LOGICAL_EXPR
395
396 .c$(OBJ_EXT):
397         $(CCCMD) $(PLDLFLAGS) $*.c
398
399 .c.i:
400         $(CCCMDSRC) -E $*.c > $*.i
401
402 .c.s:
403         $(CCCMDSRC) -S $*.c
404
405 all: $(FIRSTMAKEFILE) miniperl$(EXE_EXT) extra.pods $(private) $(unidatafiles) $(public) $(dynamic_ext) $(nonxs_ext) extras.make
406         @echo " ";
407         @echo " Everything is up to date. Type '$(MAKE) test' to run test suite."
408
409 .PHONY: all compile translators utilities
410
411 compile: all
412         echo "testing compilation" > testcompile;
413         cd utils;  $(MAKE) compile;
414         cd x2p; $(MAKE) compile;
415         cd pod; $(MAKE) compile;
416
417 translators:    miniperl$(EXE_EXT) $(CONFIGPM) FORCE
418         @echo " "; echo "       Making x2p stuff"; cd x2p; $(LDLIBPTH) $(MAKE) all
419
420 utilities:      miniperl$(EXE_EXT) $(CONFIGPM) $(plextract) lib/lib.pm FORCE
421         @echo " "; echo "       Making utilities"; cd utils; $(LDLIBPTH) $(MAKE) all
422
423
424 # This is now done by installman only if you actually want the man pages.
425 #       @echo " "; echo "       Making docs"; cd pod; $(MAKE) all;
426
427 # Phony target to force checking subdirectories.
428 # Apparently some makes require an action for the FORCE target.
429 .PHONY: FORCE
430 FORCE:
431         @sh -c true
432 !NO!SUBS!
433 $spitshell >>Makefile <<!GROK!THIS!
434
435 # We do a copy of the op.c instead of a symlink because gcc gets huffy
436 # if we have a symlink forest to another disk (it complains about too many
437 # levels of symbolic links, even if we have only two)
438
439 opmini.c: op.c
440         \$(RMS) opmini.c
441         \$(CPS) op.c opmini.c
442
443 opmini\$(OBJ_EXT): opmini.c
444         \$(CCCMD) \$(PLDLFLAGS) $DPERL_EXTERNAL_GLOB opmini.c
445
446 !GROK!THIS!
447 $spitshell >>Makefile <<'!NO!SUBS!'
448 miniperlmain$(OBJ_EXT): miniperlmain.c patchlevel.h
449         $(CCCMD) $(PLDLFLAGS) $*.c
450
451 perlmain.c: miniperlmain.c config.sh $(FIRSTMAKEFILE)
452         sh writemain $(DYNALOADER) $(static_ext) > perlmain.c
453
454 !NO!SUBS!
455 case "$osname" in
456 cygwin)
457         ;; # Let cygwin/Makefile.SHs do its work.
458 *)
459         $spitshell >>Makefile <<'!NO!SUBS!'
460 perlmain$(OBJ_EXT): perlmain.c
461         $(CCCMD) $(PLDLFLAGS) $*.c
462
463 !NO!SUBS!
464         ;;
465 esac
466 $spitshell >>Makefile <<'!NO!SUBS!'
467 # The file ext.libs is a list of libraries that must be linked in
468 # for static extensions, e.g. -lm -lgdbm, etc.  The individual
469 # static extension Makefile's add to it.
470 ext.libs: $(static_ext)
471         -@test -f ext.libs || touch ext.libs
472
473 !NO!SUBS!
474
475 # How to build libperl.  This is still rather convoluted.
476 # Load up custom Makefile.SH fragment for shared loading and executables:
477 case "$osname" in
478 *)
479         Makefile_s="$osname/Makefile.SHs"
480         ;;
481 esac
482
483 case "$osname" in
484 aix)
485         $spitshell >>Makefile <<!GROK!THIS!
486 LIBS                    = $perllibs
487 # In AIX we need to change this for building Perl itself from
488 # its earlier definition (which is for building external
489 # extensions *after* Perl has been built and installed)
490 CCDLFLAGS               = `echo $ccdlflags|sed -e 's@-bE:.*/perl\.exp@-bE:perl.exp@'`
491
492 !GROK!THIS!
493         case "$useshrplib" in
494         define|true|[yY]*)
495                 $spitshell >>Makefile <<'!NO!SUBS!'
496
497 LIBPERL_NONSHR          = libperl_nonshr$(LIB_EXT)
498 MINIPERL_NONSHR         = miniperl_nonshr$(EXE_EXT)
499
500 $(LIBPERL_NONSHR): $(obj)
501         $(RMS) $(LIBPERL_NONSHR)
502         $(AR) rcu $(LIBPERL_NONSHR) $(obj)
503
504 $(MINIPERL_NONSHR): $(LIBPERL_NONSHR) miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT)
505         $(CC) $(LDFLAGS) -o $(MINIPERL_NONSHR) miniperlmain$(OBJ_EXT) \
506             opmini$(OBJ_EXT) $(LIBPERL_NONSHR) $(LIBS)
507
508 MINIPERLEXP             = $(MINIPERL_NONSHR)
509
510 LIBPERLEXPORT           = perl.exp
511
512 !NO!SUBS!
513                 
514                 ;;
515         *)      
516                 $spitshell >>Makefile <<'!NO!SUBS!'
517 MINIPERLEXP             = miniperl$(EXE_EXT)
518
519 PERLEXPORT              = perl.exp
520
521 !NO!SUBS!
522         ;;
523         esac
524         $spitshell >>Makefile <<'!NO!SUBS!'
525 perl.exp: $(MINIPERLEXP) makedef.pl config.sh $(SYM) $(SYMH)
526         ./$(MINIPERLEXP) makedef.pl PLATFORM=aix CC_FLAGS="$(OPTIMIZE)" | sort -u | sort -f > perl.exp
527
528 !NO!SUBS!
529         ;;
530 os2)
531         $spitshell >>Makefile <<'!NO!SUBS!'
532 MINIPERLEXP             = miniperl
533
534 perl5.def: $(MINIPERLEXP) makedef.pl config.sh $(SYM) $(SYMH) miniperl.map
535         ./$(MINIPERLEXP) makedef.pl PLATFORM=os2 -DPERL_DLL=$(PERL_DLL) CC_FLAGS="$(OPTIMIZE)" > perl.exp
536
537 !NO!SUBS!
538         ;;
539 esac
540
541 if test -r $Makefile_s ; then
542         . $Makefile_s
543         $spitshell >>Makefile <<!GROK!THIS!
544
545 Makefile: $Makefile_s
546 !GROK!THIS!
547 else
548         $spitshell >>Makefile <<'!NO!SUBS!'
549 $(LIBPERL): $& $(obj) $(DYNALOADER) $(LIBPERLEXPORT)
550 !NO!SUBS!
551         case "$useshrplib" in
552         true)
553                 $spitshell >>Makefile <<'!NO!SUBS!'
554         $(LD) -o $@ $(SHRPLDFLAGS) $(obj) $(DYNALOADER) $(libs)
555 !NO!SUBS!
556                 case "$osname" in
557                 aix)
558                         $spitshell >>Makefile <<'!NO!SUBS!'
559         rm -f libperl$(OBJ_EXT)
560         mv $@ libperl$(OBJ_EXT)
561         $(AR) qv $(LIBPERL) libperl$(OBJ_EXT)
562 !NO!SUBS!
563                         ;;
564                 esac
565                 ;;
566         *)
567                 $spitshell >>Makefile <<'!NO!SUBS!'
568         rm -f $(LIBPERL)
569         $(AR) rcu $(LIBPERL) $(obj) $(DYNALOADER)
570         @$(ranlib) $(LIBPERL)
571 !NO!SUBS!
572                 ;;
573         esac
574         $spitshell >>Makefile <<'!NO!SUBS!'
575
576 # How to build executables.
577
578 # The $& notation tells Sequent machines that it can do a parallel make,
579 # and is harmless otherwise.
580 # The miniperl -w -MExporter line is a basic cheap test to catch errors
581 # before make goes on to run preplibrary and then MakeMaker on extensions.
582 # This is very handy because later errors are often caused by miniperl
583 # build problems but that's not obvious to the novice.
584 # The Module used here must not depend on Config or any extensions.
585
586 !NO!SUBS!
587
588         case "${osname}${osvers}" in
589         aix*|beos*)
590                 $spitshell >>Makefile <<'!NO!SUBS!'
591 miniperl: $& miniperlmain$(OBJ_EXT) $(obj) opmini$(OBJ_EXT)
592         $(CC) -o miniperl $(CLDFLAGS) \
593             `echo $(obj) | sed 's/ op$(OBJ_EXT) / /'` \
594             miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(libs)
595         $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
596 !NO!SUBS!
597                 ;;
598         next4*)
599                 $spitshell >>Makefile <<'!NO!SUBS!'
600 miniperl: $& miniperlmain$(OBJ_EXT) $(obj) opmini$(OBJ_EXT)
601         $(CC) -o miniperl `echo $(obj) | sed 's/ op$(OBJ_EXT) / /'` \
602             miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(libs)
603         $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
604 !NO!SUBS!
605                 ;;
606         darwin*)
607                 case "$osvers" in
608                 [1-6].*) ;;
609                 *) case "$ldflags" in
610                     *"-flat_namespace"*) ;;
611                     *) # to allow opmini.o to override stuff in libperl.dylib
612                 $spitshell >>Makefile <<!NO!SUBS!
613 NAMESPACEFLAGS = -force_flat_namespace
614 !NO!SUBS!
615                        ;;
616                     esac
617                     ;;
618                 esac
619                 $spitshell >>Makefile <<'!NO!SUBS!'
620 miniperl$(EXE_EXT): $& miniperlmain$(OBJ_EXT) $(obj) opmini$(OBJ_EXT)
621         -@rm -f miniperl.xok
622         $(CC) $(CLDFLAGS) $(NAMESPACEFLAGS) -o miniperl \
623             `echo $(obj) | sed 's/ op$(OBJ_EXT) / /'` \
624             miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(libs)
625         $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
626 !NO!SUBS!
627                 ;;
628         *)
629                 $spitshell >>Makefile <<'!NO!SUBS!'
630 miniperl$(EXE_EXT): $& miniperlmain$(OBJ_EXT) $(obj) opmini$(OBJ_EXT)
631         -@rm -f miniperl.xok
632         $(LDLIBPTH) $(CC) $(CLDFLAGS) -o miniperl \
633             `echo $(obj) | sed 's/ op$(OBJ_EXT) / /'` \
634             miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(libs)
635         $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
636 !NO!SUBS!
637                 ;;
638         esac
639
640         $spitshell >>Makefile <<'!NO!SUBS!'
641
642 perl$(EXE_EXT): $& perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs $(PERLEXPORT)
643         -@rm -f miniperl.xok
644         $(SHRPENV) $(LDLIBPTH) $(CC) -o perl$(PERL_SUFFIX) $(PERL_PROFILE_LDFLAGS) $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
645
646 # Purify/Quantify Perls.
647
648 pureperl$(EXE_EXT): $& perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs $(PERLEXPORT)
649         $(SHRPENV) $(LDLIBPTH) purify $(CC) -o pureperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
650
651 purecovperl$(EXE_EXT): $& perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs $(PERLEXPORT)
652         $(SHRPENV) $(LDLIBPTH) purecov $(CC) -o purecovperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
653
654 quantperl$(EXE_EXT): $& perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs $(PERLEXPORT)
655         $(SHRPENV) $(LDLIBPTH) quantify $(CC) -o quantperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
656
657 # Valgrind perl (currently Linux only)
658
659 perl.valgrind.config: config.sh
660         @echo "To build perl.valgrind you must Configure -Doptimize=-g -Uusemymalloc, checking..."
661         @$(MAKE) perl.config.dashg
662         @echo "Checking usemymalloc='n' in config.sh..."
663         @grep "^usemymalloc="    config.sh
664         @grep "^usemymalloc='n'" config.sh >/dev/null || exit 1
665         @echo "And of course you have to have valgrind..."
666         $(VALGRIND) ./perl -e 1 2>/dev/null || exit 1
667
668 # Third Degree Perl (Tru64 only)
669
670 perl.config.dashg:
671         @echo "Checking optimize='-g' in config.sh..."
672         @grep "^optimize="     config.sh
673         @egrep "^optimize='(-g|.*-g[1-3].*)'" config.sh >/dev/null || exit 1
674
675 perl.third.config: config.sh
676         @echo "To build perl.third you must Configure -Doptimize=-g -Uusemymalloc, checking..."
677         @$(MAKE) perl.config.dashg
678         @echo "Checking usemymalloc='n' in config.sh..."
679         @grep "^usemymalloc="    config.sh
680         @grep "^usemymalloc='n'" config.sh >/dev/null || exit 1
681
682 perl.third: /usr/bin/atom perl.third.config perl
683         atom -tool third -L. -all -gp -toolargs="-invalid -uninit heap+stack+copy -min 0" perl
684         @echo "Now you may run perl.third and then study perl.3log."
685
686 # Pixie Perls (Tru64 and IRIX only)
687
688 perl.pixie.config: config.sh
689         @echo "To build perl.pixie you must Configure -Doptimize=-g, checking..."
690         @$(MAKE) perl.config.dashg
691
692 perl.pixie.atom: /usr/bin/atom perl
693         atom -tool pixie -L. -all -toolargs="-quiet" perl
694
695 perl.pixie.irix: perl
696         pixie perl
697
698 perl.pixie: /usr/bin/pixie perl.pixie.config perl
699         if test -x /usr/bin/atom; then \
700           $(MAKE) perl.pixie.atom; \
701         else \
702           $(MAKE) perl.pixie.irix; \
703         fi
704         @echo "Now you may run perl.pixie and then run pixie."
705
706 # Gprof Perl
707
708 perl.config.dashpg:
709         @echo "Checking optimize='-pg' in config.sh..."
710         @grep "^optimize="      config.sh
711         @grep "^optimize='.*-pg.*'" config.sh >/dev/null || exit 1
712
713 perl.gprof.config: config.sh
714         @echo "To build perl.gprof you must Configure -Doptimize=-pg, checking..."
715         @$(MAKE) perl.config.dashpg
716
717 perl.gprof: /usr/bin/gprof perl.gprof.config
718         @-rm -f perl
719         $(MAKE) PERL_SUFFIX=.gprof PERL_PROFILE_LDFLAGS=-pg perl
720         @echo "Now you may run perl.gprof and then run gprof perl.gprof."
721
722 # Gcov Perl
723
724 perl.config.gcov:
725         @echo "To build perl.gcov you must use gcc 3.0 or newer, checking..."
726         @echo "Checking gccversion in config.sh..."
727         @grep "^gccversion="      config.sh
728         @grep "^gccversion='[3-9]\." config.sh >/dev/null || exit 1
729         @echo "To build perl.gcov you must Configure -Dccflags=-fprofile-arcs -ftest-coverage, checking..."
730         @echo "Checking ccflags='-fprofile-arcs -ftest-coverage' in config.sh..."
731         @grep "^ccflags="      config.sh
732         @grep "^ccflags='.*-fprofile-arcs -ftest-coverage.*'" config.sh >/dev/null || exit 1
733
734 perl.gcov: perl.config.gcov
735         @-rm -f perl
736         $(MAKE) PERL_SUFFIX=.gcov PERL_PROFILE_LDFLAGS='' perl
737         @echo "Now you may run perl.gcov and then run gcov some.c."
738
739 # Microperl.  This is just a convenience thing if one happens to
740 # build also the full Perl and therefore the real big Makefile:
741 # usually one should manually explicitly issue the below command.
742
743 .PHONY: microperl
744 microperl:
745         $(MAKE) -f Makefile.micro
746
747 # This version, if specified in Configure, does ONLY those scripts which need
748 # set-id emulation.  Suidperl must be setuid root.  It contains the "taint"
749 # checks as well as the special code to validate that the script in question
750 # has been invoked correctly.
751
752 suidperl$(EXE_EXT): $& sperl$(OBJ_EXT) perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs $(PERLEXPORT)
753         $(SHRPENV) $(LDLIBPTH) $(CC) -o suidperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) sperl$(OBJ_EXT) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
754
755 !NO!SUBS!
756
757 fi
758
759 $spitshell >>Makefile <<'!NO!SUBS!'
760
761 sperl$(OBJ_EXT): perl.c $(h)
762         $(RMS) sperl.c
763         $(LNS) perl.c sperl.c
764         $(CCCMD) -DIAMSUID sperl.c
765         $(RMS) sperl.c
766
767 # We have to call our ./makedir because Ultrix 4.3 make can't handle the line
768 #       test -d lib/auto || mkdir lib/auto
769 # We need to autosplit in two steps because VOS can't handle so many args
770 #
771 .PHONY: preplibrary
772 preplibrary: miniperl$(EXE_EXT) $(CONFIGPM) lib/lib.pm $(PREPLIBRARY_LIBPERL)
773         @sh ./makedir lib/auto
774         @echo " AutoSplitting perl library"
775         $(LDLIBPTH) ./miniperl -Ilib -e 'use AutoSplit; \
776                 autosplit_lib_modules(@ARGV)' lib/*.pm
777         $(LDLIBPTH) ./miniperl -Ilib -e 'use AutoSplit; \
778                 autosplit_lib_modules(@ARGV)' lib/*/*.pm
779         $(MAKE) lib/re.pm
780
781 lib/Config.pod: config.sh miniperl$(EXE_EXT) configpm Porting/Glossary
782         $(LDLIBPTH) ./miniperl -Ilib configpm --heavy=lib/Config_heavy.pl lib/Config.pm
783
784 $(CONFIGPM): lib/Config.pod
785
786 lib/ExtUtils/Miniperl.pm: miniperlmain.c miniperl$(EXE_EXT) minimod.pl $(CONFIGPM)
787         $(LDLIBPTH) ./miniperl minimod.pl > lib/ExtUtils/Miniperl.pm
788
789 lib/re.pm: ext/re/re.pm
790         cp ext/re/re.pm lib/re.pm
791
792 $(plextract):   miniperl$(EXE_EXT) $(CONFIGPM) x2p/s2p
793         @-rm -f $@
794         $(LDLIBPTH) ./miniperl -I`pwd`/lib $@.PL
795
796 x2p/s2p: miniperl$(EXE_EXT) $(CONFIGPM) x2p/s2p.PL
797         cd x2p; $(LDLIBPTH) $(MAKE) s2p
798
799 lib/lib.pm:     miniperl$(EXE_EXT) $(CONFIGPM)
800         @-rm -f $@
801         $(LDLIBPTH) ./miniperl -Ilib lib/lib_pm.PL
802
803 unidatafiles $(unidatafiles): uni.data
804
805 uni.data: miniperl$(EXE_EXT) $(CONFIGPM) lib/unicore/mktables
806         cd lib/unicore && $(LDLIBPTH) ../../miniperl -I../../lib mktables -w
807         touch uni.data
808
809 extra.pods: miniperl$(EXE_EXT)
810         -@test ! -f extra.pods || rm -f `cat extra.pods`
811         -@rm -f extra.pods
812         -@for x in `grep -l '^=[a-z]' README.* | grep -v README.vms` ; do \
813             nx=`echo $$x | sed -e "s/README\.//"`; \
814             cd pod ; $(LNS) ../$$x "perl"$$nx".pod" ; cd .. ; \
815             echo "pod/perl"$$nx".pod" >> extra.pods ; \
816         done
817         -@rm -f pod/perlvms.pod
818         -@test -f vms/perlvms.pod && cd pod && $(LNS) ../vms/perlvms.pod perlvms.pod && cd .. && echo "pod/perlvms.pod" >> extra.pods
819         -@rm -f pod/perldelta.pod
820         -@test -f pod/perl594delta.pod && cd pod && $(LNS) perl594delta.pod perldelta.pod && cd .. && echo "pod/perldelta.pod" >> extra.pods # See buildtoc
821
822 extras.make: perl$(EXE_EXT)
823         -@test ! -s extras.lst || PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(LDLIBPTH) ./perl -Ilib -MCPAN -e '@ARGV&&make(@ARGV)' `cat extras.lst`
824
825 extras.test: perl$(EXE_EXT)
826         -@test ! -s extras.lst || PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(LDLIBPTH) ./perl -Ilib -MCPAN -e '@ARGV&&test(@ARGV)' `cat extras.lst`
827
828 extras.install: perl$(EXE_EXT)
829         -@test ! -s extras.lst || PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(LDLIBPTH) ./perl -Ilib -MCPAN -e '@ARGV&&install(@ARGV)' `cat extras.lst`
830
831 .PHONY: install install-strip install-all install-verbose install-silent \
832         no-install install.perl install.man install.html
833
834 META.yml:       Porting/makemeta Porting/Maintainers.pl Porting/Maintainers.pm
835         $(LDLIBPTH) ./miniperl -Ilib Porting/makemeta
836
837 install-strip:
838         $(MAKE) STRIPFLAGS=-s install DESTDIR="$(DESTDIR)"
839
840 install install-all:
841         $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) DESTDIR="$(DESTDIR)"
842
843 install-verbose:
844         $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-V DESTDIR="$(DESTDIR)"
845
846 install-silent:
847         $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-S DESTDIR="$(DESTDIR)"
848
849 no-install:
850         $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-n DESTDIR="$(DESTDIR)"
851
852 # Set this to an empty string to avoid an attempt of rebuild before install
853 INSTALL_DEPENDENCE = all
854
855 install.perl:   $(INSTALL_DEPENDENCE) installperl
856         if [ -n "$(COMPILE)" ]; \
857         then \
858                 cd utils; $(MAKE) compile; \
859                 cd ../x2p; $(MAKE) compile; \
860                 cd ../pod; $(MAKE) compile; \
861         else :; \
862         fi
863         $(LDLIBPTH) ./perl installperl --destdir=$(DESTDIR) $(INSTALLFLAGS) $(STRIPFLAGS)
864         $(MAKE) extras.install
865
866 install.man:    all installman
867         $(LDLIBPTH) ./perl installman --destdir=$(DESTDIR) $(INSTALLFLAGS)
868
869 # XXX Experimental. Hardwired values, but useful for testing.
870 # Eventually Configure could ask for some of these values.
871 install.html: all installhtml
872         -@test -f README.vms && cd vms && $(LNS) ../README.vms README_vms.pod && cd ..
873         $(LDLIBPTH) ./perl installhtml   \
874       --podroot=. --podpath=. --recurse  \
875       --htmldir=$(privlib)/html   \
876       --htmlroot=$(privlib)/html  \
877       --splithead=pod/perlipc     \
878       --splititem=pod/perlfunc    \
879       --libpods=perlfunc:perlguts:perlvar:perlrun:perlop \
880       --ignore=Porting/Maintainers.pm,Porting/patching.pod,Porting/pumpkin.pod,Porting/repository.pod \
881       --verbose
882
883
884 # I now supply perly.c with the kits, so the following section is
885 # used only if you force bison to run by saying
886 #       make regen_perly
887 # You normally shouldn't remake perly.[ch].
888
889 .PHONY: regen_perly
890
891 run_byacc:
892         @echo "run_byacc is obsolete; try 'make regen_perly' instead"
893
894 # this outputs perly.h, perly.act, perly.tab, madly.h, madly.act and madly.tab
895 regen_perly:
896         perl regen_perly.pl
897         perl regen_perly.pl madly.y
898
899 # We don't want to regenerate perly.c and perly.h, but they might
900 # appear out-of-date after a patch is applied or a new distribution is
901 # made.
902 perly.c: perly.y
903         -@sh -c true
904
905 perly.h: perly.y
906         -@sh -c true
907
908 # Similary for madly.
909 madly.c: madly.y
910         -@sh -c true
911
912 madly.h: madly.y
913         -@sh -c true
914
915 # No compat3.sym here since and including the 5.004_50.
916 # No interp.sym since 5.005_03.
917 SYM  = global.sym globvar.sym perlio.sym pp.sym
918
919 SYMH = perlvars.h intrpvar.h thrdvar.h
920
921 CHMOD_W = chmod +w
922
923 # The following files are generated automatically
924 #       autodoc.pl:     pod/perlapi.pod pod/perlintern.pod
925 #       bytecode.pl:    ext/ByteLoader/byterun.h ext/ByteLoader/byterun.c
926 #                       ext/B/B/Asmdata.pm
927 #       embed.pl:       proto.h embed.h embedvar.h global.sym
928 #                       perlapi.h perlapi.c 
929 # [* embed.pl needs pp.sym generated by opcode.pl! *]
930 #       keywords.pl:    keywords.h
931 #       opcode.pl:      opcode.h opnames.h pp_proto.h pp.sym
932 #       regcomp.pl:     regnodes.h
933 #       warnings.pl:    warnings.h lib/warnings.pm
934 # The correct versions should be already supplied with the perl kit,
935 # in case you don't have perl available.
936 # To force them to be regenerated, run
937 #       perl regen.pl
938 # with your existing copy of perl
939 # (make regen_headers is kept for backwards compatibility)
940
941 AUTOGEN_FILES = keywords.h opcode.h opnames.h pp_proto.h pp.sym proto.h \
942                 embed.h embedvar.h global.sym \
943                 pod/perlintern.pod pod/perlapi.pod \
944                 perlapi.h perlapi.c ext/ByteLoader/byterun.h \
945                 ext/ByteLoader/byterun.c ext/B/B/Asmdata.pm regnodes.h \
946                 warnings.h lib/warnings.pm
947
948 .PHONY: regen_headers regen_pods regen_all
949
950 regen regen_headers:    FORCE
951         -perl regen.pl
952
953 regen_pods:     FORCE
954         -cd pod; $(LDLIBPTH) $(MAKE) regen_pods
955
956 regen_all: regen regen_pods
957
958 .PHONY: manisort manicheck
959
960 manisort:       FORCE
961         LC_ALL=C sort -fdc MANIFEST || (echo "WARNING: re-sorting MANIFEST"; \
962                 LC_ALL=C sort -fdo MANIFEST MANIFEST)
963
964 manicheck:      FORCE
965         perl Porting/manicheck
966
967 # Extensions:
968 # Names added to $(dynamic_ext) or $(static_ext) or $(nonxs_ext) will
969 # automatically get built.  There should ordinarily be no need to change
970 # any of this part of makefile.
971 #
972 # The dummy dependency is a place holder in case $(dynamic_ext) or
973 # $(static_ext) is empty.
974 #
975 # DynaLoader may be needed for extensions that use Makefile.PL.
976
977 $(DYNALOADER):  miniperl$(EXE_EXT) preplibrary FORCE
978         @$(LDLIBPTH) sh ext/util/make_ext $(STATIC) $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
979
980 d_dummy $(dynamic_ext): miniperl$(EXE_EXT) preplibrary $(DYNALOADER) FORCE
981         @$(LDLIBPTH) sh ext/util/make_ext dynamic $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
982
983 s_dummy $(static_ext):  miniperl$(EXE_EXT) preplibrary $(DYNALOADER) FORCE
984         @$(LDLIBPTH) sh ext/util/make_ext $(STATIC) $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
985
986 n_dummy $(nonxs_ext):   miniperl$(EXE_EXT) preplibrary $(DYNALOADER) FORCE
987         @$(LDLIBPTH) sh ext/util/make_ext nonxs $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
988
989 .PHONY: printconfig
990 printconfig:
991         @eval `$(LDLIBPTH) ./perl -Ilib -V:$(CONFIGVAR)`; echo $$$(CONFIGVAR)
992
993 .PHONY: clean _tidy _mopup _cleaner1 _cleaner2 \
994         realclean _realcleaner clobber _clobber \
995         distclean veryclean _verycleaner
996
997 clean:          _tidy _mopup
998
999 realclean:      _realcleaner _mopup
1000         @echo "Note that '$(MAKE) realclean' does not delete config.sh or Policy.sh"
1001
1002 _clobber:
1003         -@rm -f Cross/run-* Cross/to-* Cross/from-*
1004         rm -f config.sh cppstdin Policy.sh extras.lst
1005
1006 clobber:        _realcleaner _mopup _clobber
1007
1008 distclean:      clobber
1009
1010 # Like distclean but also removes emacs backups and *.orig.
1011 veryclean:      _verycleaner _mopup _clobber
1012         -@rm -f Obsolete Wanted
1013
1014 # Do not 'make _mopup' directly.
1015 _mopup:
1016         rm -f *$(OBJ_EXT) *$(LIB_EXT) all perlmain.c opmini.c
1017         -rmdir .depending
1018         -@test -f extra.pods && rm -f `cat extra.pods`
1019         -@test -f vms/README_vms.pod && rm -f vms/README_vms.pod
1020         -rm -f perl.exp ext.libs extra.pods uni.data opmini.o
1021         -rm -f perl.export perl.dll perl.libexp perl.map perl.def
1022         -rm -f perl.loadmap miniperl.loadmap perl.prelmap miniperl.prelmap
1023         -rm -f perl.third lib*.so.perl.third perl.3log t/perl.third t/perl.3log
1024         -rm -f perl.pixie lib*.so.perl.pixie lib*.so.Addrs
1025         -rm -f perl.Addrs perl.Counts t/perl.Addrs t/perl.Counts *perl.xok
1026         -rm -f perlld cygwin.c ld2 libperl*.def libperl*.dll cygperl*.dll *.exe.stackdump
1027         -rm -f perl$(EXE_EXT) suidperl$(EXE_EXT) miniperl$(EXE_EXT) $(LIBPERL) libperl.* microperl
1028         -rm -f opcode.h-old opnames.h-old pp.sym-old pp_proto.h-old
1029         -rm -f config.over
1030
1031 # Do not 'make _tidy' directly.
1032 _tidy:
1033         -cd pod; $(LDLIBPTH) $(MAKE) clean
1034         -cd utils; $(LDLIBPTH) $(MAKE) clean
1035         -cd x2p; $(LDLIBPTH) $(MAKE) clean
1036         -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
1037         $(LDLIBPTH) sh ext/util/make_ext clean $$x MAKE=$(MAKE) ; \
1038         done
1039         rm -f testcompile compilelog
1040
1041 _cleaner1:
1042         -cd os2; rm -f Makefile
1043         -cd pod; $(LDLIBPTH) $(MAKE) $(CLEAN)
1044         -cd utils; $(LDLIBPTH) $(MAKE) $(CLEAN)
1045         -cd x2p; $(LDLIBPTH) $(MAKE) $(CLEAN)
1046         -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
1047         $(LDLIBPTH) sh ext/util/make_ext $(CLEAN) $$x MAKE=$(MAKE) ; \
1048         done
1049
1050 # Some systems do not support "?", so keep these files separate.
1051 _cleaner2:
1052         -rm -f core.*perl.*.? t/core.perl.*.? .?*.c
1053         rm -f core *perl.core t/core t/*perl.core core.* t/core.*
1054         rm -f t/misctmp* t/forktmp* t/tmp* t/c t/perl$(EXE_EXT) t/rantests
1055         rm -f so_locations $(LIBPERL_NONSHR) $(MINIPERL_NONSHR)
1056         rm -rf $(addedbyconf)
1057         rm -f $(FIRSTMAKEFILE) $(FIRSTMAKEFILE).old makefile.old
1058         rm -f $(private)
1059         rm -rf $(unidatafiles) $(unidatadirs)
1060         rm -rf lib/auto
1061         rm -f lib/.exists lib/*/.exists lib/*/*/.exists
1062         rm -f h2ph.man pstruct
1063         rm -rf .config
1064         rm -f preload
1065         rm -f testcompile compilelog
1066         rm -rf lib/Encode lib/Compress
1067         rm -rf lib/IO/Compress lib/IO/Uncompress
1068         rm -f lib/ExtUtils/ParseXS/t/XSTest.c
1069         rm -f lib/ExtUtils/ParseXS/t/XSTest$(OBJ_EXT)
1070         rm -f lib/ExtUtils/ParseXS/t/XSTest$(DLSUFFIX)
1071         -rmdir lib/B lib/Data
1072         -rmdir lib/Filter/Util lib/IO/Socket
1073         -rmdir lib/List lib/MIME lib/Scalar lib/Sys
1074         -rmdir lib/threads lib/XS lib/Hash
1075
1076 _realcleaner:
1077         @$(LDLIBPTH) $(MAKE) _cleaner1 CLEAN=realclean
1078         @$(LDLIBPTH) $(MAKE) _cleaner2
1079
1080 _verycleaner:
1081         @$(LDLIBPTH) $(MAKE) _cleaner1 CLEAN=veryclean
1082         @$(LDLIBPTH) $(MAKE) _cleaner2
1083         -rm -f *~ *.orig */*~ */*.orig */*/*~ */*/*.orig
1084
1085 .PHONY: lint
1086 lint: $(c)
1087         rm -f *.ln
1088         lint $(lintflags) -DPERL_CORE -D_REENTRANT -DDEBUGGING -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(c)
1089
1090 # Need to unset during recursion to go out of loop.
1091 # The README below ensures that the dependency list is never empty and
1092 # that when MAKEDEPEND is empty $(FIRSTMAKEFILE) doesn't need rebuilding.
1093
1094 MAKEDEPEND = Makefile makedepend
1095
1096 $(FIRSTMAKEFILE):       README $(MAKEDEPEND)
1097         $(MAKE) depend MAKEDEPEND=
1098
1099 config.h: config_h.SH config.sh
1100         $(SHELL) config_h.SH
1101
1102 # When done, touch perlmain.c so that it doesn't get remade each time.
1103 .PHONY: depend
1104 depend: makedepend
1105         sh ./makedepend MAKE=$(MAKE)
1106         - test -s perlmain.c && touch perlmain.c
1107         cd x2p; $(MAKE) depend
1108
1109 # Cannot postpone this until $firstmakefile is ready ;-)
1110 makedepend: makedepend.SH config.sh
1111         sh ./makedepend.SH
1112
1113 .PHONY: test check test_prep test_prep_nodll test_prep_pre _test_prep \
1114         test_tty test-tty _test_tty test_notty test-notty _test_notty \
1115         utest ucheck test.utf8 check.utf8 test.torture torturetest \
1116         test.utf16 check.utf16 utest.utf16 ucheck.utf16 \
1117         test.third check.third utest.third ucheck.third test_notty.third \
1118         test.deparse test_notty.deparse test_harness test_harness_notty \
1119         test.bytecompile minitest coretest test.taintwarn
1120
1121 # Cannot delegate rebuilding of t/perl to make
1122 # to allow interlaced test and minitest
1123
1124 TESTFILE=TEST
1125
1126 _test_prep:
1127         cd t && (rm -f $(PERL)$(EXE_EXT); $(LNS) ../$(PERL)$(EXE_EXT) $(PERL)$(EXE_EXT))
1128
1129 # Architecture-neutral stuff:
1130
1131 test_prep_pre: preplibrary utilities $(nonxs_ext)
1132
1133 test_prep: test_prep_pre miniperl$(EXE_EXT) $(unidatafiles) perl$(EXE_EXT) $(dynamic_ext) $(TEST_PERL_DLL)
1134         PERL=./perl $(MAKE) _test_prep
1135
1136 _test_tty:
1137         cd t && $(PERL_DEBUG) $(LDLIBPTH) $(PERL) $(TESTFILE) $(TEST_ARGS) </dev/tty
1138
1139 _test_notty:
1140         cd t && $(PERL_DEBUG) PERL_SKIP_TTY_TEST=1 $(LDLIBPTH) $(PERL) $(TESTFILE) $(TEST_ARGS)
1141
1142 # The second branch is for testing without a tty or controlling terminal,
1143 # see t/op/stat.t
1144 _test:
1145         if (true </dev/tty) >/dev/null 2>&1; then \
1146           $(MAKE) TEST_ARGS=$(TEST_ARGS) TESTFILE=$(TESTFILE) _test_tty   ; \
1147         else \
1148           $(MAKE) TEST_ARGS=$(TEST_ARGS) TESTFILE=$(TESTFILE) _test_notty ; \
1149         fi
1150         @echo "Ran tests" > t/rantests
1151
1152 test check: test_prep
1153         PERL=./perl $(MAKE) _test
1154
1155 test_tty: test_prep
1156         PERL=./perl $(MAKE) _test_tty
1157
1158 test_notty: test_prep
1159         PERL=./perl $(MAKE) _test_notty
1160
1161 utest ucheck test.utf8 check.utf8: test_prep
1162         PERL=./perl TEST_ARGS=-utf8 $(MAKE) _test
1163
1164 coretest: test_prep
1165         PERL=./perl TEST_ARGS=-core $(MAKE) _test
1166
1167 test-prep:      test_prep
1168
1169 test-tty:       test_tty
1170
1171 test-notty:     test_notty
1172
1173 # Torture testing
1174
1175 test.torture torturetest:       test_prep
1176         PERL=./perl TEST_ARGS=-torture $(MAKE) _test
1177
1178 # Targets for UTF16 testing:
1179
1180 minitest.utf16: minitest.prep
1181         - cd t && (rm -f perl$(EXE_EXT); $(LNS) ../miniperl$(EXE_EXT) perl$(EXE_EXT)) \
1182                 && $(LDLIBPTH) ./perl TEST -minitest -utf16 base/*.t comp/*.t cmd/*.t run/*.t io/*.t op/*.t uni/*.t </dev/tty
1183
1184 test.utf16 check.utf16: test_prep
1185         PERL=./perl $(MAKE) TEST_ARGS=-utf16 _test
1186
1187 utest.utf16 ucheck.utf16: test_prep
1188         PERL=./perl $(MAKE) TEST_ARGS="-utf8 -utf16" _test
1189
1190 # Targets for valgrind testing:
1191
1192 test_prep.valgrind: test_prep perl.valgrind
1193         PERL=./perl $(MAKE) _test_prep
1194
1195 test.valgrind check.valgrind:   test_prep perl.valgrind.config
1196         PERL=./perl PERL_DEBUG=PERL_VALGRIND=1 VALGRIND='$(VALGRIND)' $(MAKE) _test
1197
1198 utest.valgrind ucheck.valgrind: test_prep.valgrind perl.valgrind.config
1199         PERL=./perl PERL_DEBUG=PERL_VALGRIND=1 TEST_ARGS=-utf8 $(MAKE) _test
1200
1201 test_notty.valgrind: test_prep.valgrind perl.valgrind.config
1202         PERL=./perl $(MAKE) PERL_DEBUG=PERL_VALGRIND=1 _test_notty
1203
1204 # Targets for Third Degree testing.
1205
1206 test_prep.third: test_prep perl.third
1207         PERL=./perl.third $(MAKE) _test_prep
1208
1209 test.third check.third: test_prep.third perl.third
1210         PERL=./perl.third PERL_DEBUG=PERL_3LOG=1 $(MAKE) _test
1211
1212 utest.third ucheck.third: test_prep.third perl.third
1213         PERL=./perl.third PERL_DEBUG=PERL_3LOG=1 TEST_ARGS=-utf8 $(MAKE) _test
1214
1215 test_notty.third: test_prep.third perl.third
1216         PERL=./perl.third $(MAKE) PERL_DEBUG=PERL_3LOG=1 _test_notty
1217
1218 # Targets for Bytecode/ByteLoader testing.
1219
1220 test.bytecompile:       test_prep
1221         PERL=./perl TEST_ARGS=-bytecompile $(MAKE) _test
1222
1223 # Targets for Deparse testing.
1224
1225 test.deparse:   test_prep
1226         PERL=./perl TEST_ARGS=-deparse $(MAKE) _test
1227
1228 test_notty.deparse:     test_prep
1229         PERL=./perl TEST_ARGS=-deparse $(MAKE) _test_notty
1230
1231 # Targets to run the test suite with -t
1232
1233 test.taintwarn: test_prep
1234         PERL=./perl TEST_ARGS=-taintwarn $(MAKE) _test
1235
1236 minitest.prep:
1237         -@test -f lib/lib.pm && test -f lib/Config.pm || \
1238           $(MAKE) lib/Config.pm lib/lib.pm $(unidatafiles)
1239         @echo " "
1240         @echo "You may see some irrelevant test failures if you have been unable"
1241         @echo "to build lib/Config.pm, lib/lib.pm or the Unicode data files."
1242         @echo " "
1243
1244 # Can't depend on lib/Config.pm because that might be where miniperl
1245 # is crashing.
1246 minitest: miniperl$(EXE_EXT) lib/re.pm minitest.prep
1247         - cd t && (rm -f perl$(EXE_EXT); $(LNS) ../miniperl$(EXE_EXT) perl$(EXE_EXT)) \
1248                 && $(LDLIBPTH) ./perl TEST -minitest base/*.t comp/*.t cmd/*.t run/*.t io/*.t op/*.t uni/*.t </dev/tty
1249
1250 # Test via harness
1251
1252 test_harness: test_prep
1253         PERL=./perl $(MAKE) TESTFILE=harness _test
1254
1255 test_harness_notty: test_prep
1256         PERL=./perl HARNESS_NOTTY=1 $(MAKE) TESTFILE=harness _test
1257
1258 # Handy way to run perlbug -ok without having to install and run the
1259 # installed perlbug. We don't re-run the tests here - we trust the user.
1260 # Please *don't* use this unless all tests pass.
1261 # If you want to report test failures, use "make nok" instead.
1262
1263 .PHONY: ok okfile oknack okfilenack nok nokfile noknack nokfilenack
1264
1265 ok:     utilities
1266         $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)'
1267
1268 okfile: utilities
1269         $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok
1270
1271 oknack: utilities
1272         $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -A
1273
1274 okfilenack:     utilities
1275         $(LDLIBPTH) ./perl -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok -A
1276
1277 nok:    utilities
1278         $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)'
1279
1280 nokfile:        utilities
1281         $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -F perl.nok
1282
1283 noknack:        utilities
1284         $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -A
1285
1286 nokfilenack:    utilities
1287         $(LDLIBPTH) ./perl -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -F perl.nok -A
1288
1289 .PHONY: clist hlist shlist pllist
1290
1291 clist:  $(c)
1292         echo $(c) | tr ' ' $(TRNL) >.clist
1293
1294 hlist:  $(h)
1295         echo $(h) | tr ' ' $(TRNL) >.hlist
1296
1297 shlist: $(sh)
1298         echo $(sh) | tr ' ' $(TRNL) >.shlist
1299
1300 pllist: $(pl)
1301         echo $(pl) | tr ' ' $(TRNL) >.pllist
1302
1303 Makefile: Makefile.SH ./config.sh
1304         $(SHELL) Makefile.SH
1305
1306 .PHONY: distcheck
1307 distcheck: FORCE
1308         perl '-MExtUtils::Manifest=&fullcheck' -e 'fullcheck()'
1309
1310 .PHONY: elc
1311 elc:    emacs/cperl-mode.elc
1312
1313 emacs/cperl-mode.elc: emacs/cperl-mode.el
1314         -cd emacs; emacs -batch -q -no-site-file -f batch-byte-compile cperl-mode.el
1315
1316 .PHONY: etags ctags tags
1317
1318 etags:  TAGS
1319
1320 TAGS: emacs/cperl-mode.elc
1321         sh emacs/ptags
1322
1323 # Let's hope make will not go into an infinite loop on case-unsensitive systems
1324 # This may also fail if . is in the head of the path, since perl will
1325 # require -Ilib
1326 tags:   TAGS
1327         perl emacs/e2ctags.pl TAGS > tags
1328
1329 ctags:
1330         ctags -f Tags -N --totals --languages=c --langmap=c:+.h *.c *.h
1331
1332 # AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
1333 # If this runs make out of memory, delete /usr/include lines.
1334 !NO!SUBS!
1335
1336 $eunicefix Makefile
1337 case `pwd` in
1338 *SH)
1339     $rm -f ../Makefile
1340     $ln Makefile ../Makefile
1341     ;;
1342 esac
1343 $rm -f $firstmakefile
1344
1345 # Now do any special processing required before building.
1346
1347 case "$ebcdic" in
1348 define)
1349     xxx=''
1350     echo "This is an EBCDIC system, checking if any parser files need regenerating." >&2
1351 case "$osname" in
1352 os390|posix-bc)
1353     if cd x2p
1354     then
1355         rm -f y.tab.c y.tab.h
1356         case "$osname" in
1357         posix-bc)
1358            # we are using two different yaccs in BS2000 Posix!
1359            byacc a2p.y >/dev/null 2>&1
1360            ;;
1361         *) # e.g. os390
1362            yacc  a2p.y >/dev/null 2>&1
1363            ;;
1364         esac
1365         if cmp -s y.tab.c a2p.c
1366         then
1367             rm -f y.tab.c
1368         else
1369             echo "a2p.y -> a2p.c" >&2
1370             mv -f y.tab.c a2p.c
1371             chmod u+w a2p.c
1372             sed -e 's/fprintf *( *stderr *,/PerlIO_printf(Perl_debug_log,/g' \
1373                 -e 's|^static void __YY_YACC_MAIN.*BS2000.*|/*static main deleted*/|' \
1374                 -e 's/y\.tab/a2p/g' a2p.c >a2p.tmp && mv a2p.tmp a2p.c
1375             xxx="$xxx a2p.c"
1376         fi
1377         # In case somebody yacc -d:ed the a2p.y.
1378         if test -f y.tab.h
1379         then
1380             if cmp -s y.tab.h a2p.h
1381             then
1382                 rm -f y.tab.h
1383             else
1384                 echo "a2p.h -> a2p.h" >&2
1385                 mv -f y.tab.h a2p.h
1386                 xxx="$xxx a2p.h"
1387             fi
1388         fi
1389         cd ..
1390     fi
1391     ;;
1392 vmesa)
1393     # Do nothing in VM/ESA.
1394     ;;
1395 *)
1396     echo "'$osname' is an EBCDIC system I don't know that well." >&4
1397     ;;
1398 esac
1399     case "$xxx" in
1400     '') echo "No parser files were regenerated.  That's okay." >&2 ;;
1401     esac
1402     ;;
1403 esac
1404
1405 # ex: set ts=8 sts=4 sw=4 noet: