This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Change ref to obsolete global var
[perl5.git] / Makefile.SH
index 17707a1..e6c3eb7 100755 (executable)
@@ -20,16 +20,7 @@ case $PERL_CONFIG_SH in
        ;;
 esac
 
-case $CROSS_NAME in
-'')
-       Makefile=Makefile
-       ;;
-*)
-       # if cross-compilation, the Makefile named accordingly
-       Makefile=Makefile-cross-$CROSS_NAME
-       . Cross/config-${CROSS_NAME}.sh
-       ;;
-esac
+Makefile=Makefile
 
 : This forces SH files to create target in same directory as SH file.
 : This is so that make depend always knows where to find SH derivatives.
@@ -77,7 +68,7 @@ true)
        sunos*)
                linklibperl="-lperl"
                ;;
-       netbsd*|freebsd[234]*|openbsd*|dragonfly*)
+       netbsd*|freebsd[234]*|openbsd*|dragonfly*|bitrig*)
                linklibperl="-L. -lperl"
                ;;
        interix*)
@@ -302,7 +293,12 @@ STATIC_LDFLAGS = $static_ldflags
 LDLIBPTH = $ldlibpth
 
 # Sometimes running an executable is an adventure.
-RUN = $run
+RUN = 
+
+# When cross-compiling we want to use a (mini)perl built for the host, not the target
+HOST_PERL = $hostperl
+HOST_GENERATE = $hostgenerate
+SYSTEM_PERL = $perl
 
 # These variables may need to be manually set for non-Unix systems.
 AR = $full_ar
@@ -315,12 +311,28 @@ PATH_SEP = $p_
 # Macros to invoke a copy of miniperl during the build.  Targets which
 # are built using these macros should depend on \$(MINIPERL_EXE)
 MINIPERL_EXE = miniperl\$(EXE_EXT)
-MINIPERL = \$(LDLIBPTH) \$(RUN) ./miniperl\$(EXE_EXT) -Ilib
+MINIPERL = \$(LDLIBPTH) ./miniperl\$(EXE_EXT) -Ilib
 
+!GROK!THIS!
+
+case "$usecrosscompile$perl" in
+define?*)
+       $spitshell >>$Makefile <<!GROK!THIS!
 # Macros to invoke a copy of our fully operational perl during the build.
 PERL_EXE = perl\$(EXE_EXT)
-RUN_PERL = \$(LDLIBPTH) \$(RUN) ./perl\$(EXE_EXT)
+RUN_PERL = \$(LDLIBPTH) \$(RUN) $perl\$(EXE_EXT)
+!GROK!THIS!
+       ;;
+*)
+       $spitshell >>$Makefile <<!GROK!THIS!
+# Macros to invoke a copy of our fully operational perl during the build.
+PERL_EXE = perl\$(EXE_EXT)
+RUN_PERL = \$(LDLIBPTH) \$(RUN) ./perl\$(EXE_EXT) -Ilib
+!GROK!THIS!
+       ;;
+esac
 
+$spitshell >>$Makefile <<!GROK!THIS!
 # Macros to run our tests
 RUN_TESTS = \$(LDLIBPTH) ./runtests
 
@@ -404,14 +416,12 @@ EOF
        ;;
 esac
 
-case $CROSS_NAME in
-'')
 ## In the following dollars and backticks do not need the extra backslash.
 $spitshell >>$Makefile <<'!NO!SUBS!'
 
-CCCMD    = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $@`
+CCCMD    = sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $@
 
-CCCMDSRC = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $<`
+CCCMDSRC = sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $<
 
 CONFIGPM_FROM_CONFIG_SH = lib/Config.pm lib/Config_heavy.pl
 CONFIGPM = $(CONFIGPM_FROM_CONFIG_SH) lib/Config_git.pl
@@ -420,40 +430,18 @@ CONFIGPOD = lib/Config.pod
 
 CONFIGH = config.h
 !NO!SUBS!
-       ;;
-*)
-       # if cross-compilation
-$spitshell >>$Makefile <<!GROK!THIS!
-CROSS_NAME = $CROSS_NAME
-CROSS_LIB = xlib/$CROSS_NAME
-
-CCCMD    = \`sh \$(shellflags) cflags-cross-$CROSS_NAME "optimize='\$(OPTIMIZE)'" \$@\` -I\$(CROSS_LIB)
-CCCMDSRC = \`sh \$(shellflags) cflags-cross-$CROSS_NAME "optimize='\$(OPTIMIZE)'" \$<\` -I\$(CROSS_LIB)
-CONFIGPM = xlib/\$(CROSS_NAME)/Config.pm
-CONFIGPOD = xlib/\$(CROSS_NAME)/Config.pod
-CONFIGH = xconfig.h
-
-xconfig.h: config_h.SH Cross/config-\$(CROSS_NAME).sh
-       CONFIG_SH=Cross/config-\$(CROSS_NAME).sh CONFIG_H=xconfig.h \$(SHELL) config_h.SH
-       #TODO \$(LDLIBPTH) ./miniperl$(EXE_EXT) -Ilib -MCross=\$(CROSS_NAME) config_h.PL "INST_VER=\$(INST_VER)" "CORE_DIR=\$(CROSS_LIB)" "CONFIG_H=xconfig.h"
-       cp xconfig.h \$(CROSS_LIB)/
-       cp xconfig.h \$(CROSS_LIB)/config.h
-
-!GROK!THIS!
-       ;;
-esac
 
 SH_to_target() {
     echo $@ | sed -e s/\\\.SH//g -e s/_/./g
 }
 
-SH='Makefile.SH cflags.SH config_h.SH makedepend.SH myconfig.SH runtests.SH pod/Makefile.SH x2p/Makefile.SH'
+SH='Makefile.SH cflags.SH config_h.SH makedepend.SH myconfig.SH runtests.SH pod/Makefile.SH'
 shextract=`SH_to_target $SH`
 
 ## In the following dollars and backticks do not need the extra backslash.
 $spitshell >>$Makefile <<!GROK!THIS!
 
-private = preplibrary \$(CONFIGPM) \$(CONFIGPOD) lib/ExtUtils/Miniperl.pm git_version.h lib/buildcustomize.pl
+private = preplibrary \$(CONFIGPM) \$(CONFIGPOD) git_version.h lib/buildcustomize.pl
 
 # Files to be built with variable substitution before miniperl
 # is available.
@@ -487,7 +475,7 @@ h = $(h1) $(h2) $(h3) $(h4) $(h5) $(h6)
 c1 = av.c scope.c op.c doop.c doio.c dump.c gv.c hv.c mg.c reentr.c mro.c perl.c
 c2 = perly.c pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c utf8.c sv.c
 c3 = taint.c toke.c util.c deb.c run.c universal.c pad.c globals.c keywords.c
-c4 = perlio.c perlapi.c numeric.c mathoms.c locale.c pp_pack.c pp_sort.c
+c4 = perlio.c perlapi.c numeric.c mathoms.c locale.c pp_pack.c pp_sort.c caretx.c
 c5 = $(madlysrc) $(mallocsrc)
 
 c = $(c1) $(c2) $(c3) $(c4) $(c5) miniperlmain.c opmini.c perlmini.c
@@ -496,14 +484,14 @@ obj0 = op$(OBJ_EXT) perl$(OBJ_EXT)
 obj0mini = perlmini$(OBJ_EXT) opmini$(OBJ_EXT) miniperlmain$(OBJ_EXT)
 obj1 = $(madlyobj) $(mallocobj) gv$(OBJ_EXT) toke$(OBJ_EXT) perly$(OBJ_EXT) pad$(OBJ_EXT) regcomp$(OBJ_EXT) dump$(OBJ_EXT) util$(OBJ_EXT) mg$(OBJ_EXT) reentr$(OBJ_EXT) mro$(OBJ_EXT) keywords$(OBJ_EXT)
 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)
-obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) utf8$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) universal$(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)
+obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) utf8$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) universal$(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) caretx$(OBJ_EXT)
 
 minindt_obj = $(obj0mini) $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
 mini_obj = $(minindt_obj) $(MINIDTRACE_O)
 ndt_obj = $(obj0) $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
 obj = $(ndt_obj) $(DTRACE_O)
 
-perltoc_pod_prereqs = extra.pods pod/perl5191delta.pod pod/perlapi.pod pod/perlintern.pod pod/perlmodlib.pod pod/perluniprops.pod
+perltoc_pod_prereqs = extra.pods pod/perl5211delta.pod pod/perlapi.pod pod/perlintern.pod pod/perlmodlib.pod pod/perluniprops.pod
 generated_pods = pod/perltoc.pod $(perltoc_pod_prereqs)
 generated_headers = uudmap.h bitcount.h mg_data.h
 
@@ -566,13 +554,16 @@ splintflags = \
 splintfiles = $(c1)
 
 .c$(OBJ_EXT): 
-       $(CCCMD) $(PLDLFLAGS) $*.c
+       @echo `$(CCCMD)` $(PLDLFLAGS) $*.c
+       @`$(CCCMD)` $(PLDLFLAGS) $*.c
 
 .c.i: 
-       $(CCCMDSRC) -E $*.c > $*.i
+       @echo `$(CCCMDSRC)` -E $*.c \> $*.i
+       @`$(CCCMDSRC)` -E $*.c > $*.i
 
 .c.s:
-       $(CCCMDSRC) -S $*.c
+       @echo `$(CCCMDSRC)` -S $*.c
+       @`$(CCCMDSRC)` -S $*.c
 
 all: $(FIRSTMAKEFILE) $(MINIPERL_EXE) $(generated_pods) $(private) $(unidatafiles) $(public) $(dynamic_ext) $(nonxs_ext) extras.make
        @echo " ";
@@ -598,31 +589,19 @@ perl$(OBJ_EXT): git_version.h
 case "$usedl$static_cwd" in
 defineundef)
     util_deps='$(MINIPERL_EXE) $(CONFIGPM) lib/auto/Cwd/Cwd$(DLSUFFIX) FORCE'
-     x2p_deps="\$(MINIPERL_EXE) \$(CONFIGPM) \$(dynamic_ext) x2p/$firstmakefile FORCE"
     ;;
 definedefine)
     util_deps='$(PERL_EXE) $(CONFIGPM) FORCE'
-     x2p_deps="\$(PERL_EXE) \$(CONFIGPM) \$(dynamic_ext) x2p/$firstmakefile FORCE"
     ;;
 *)  util_deps='$(PERL_EXE) $(CONFIGPM) FORCE'
-     x2p_deps="\$(PERL_EXE) \$(CONFIGPM) x2p/$firstmakefile FORCE"
     ;;
 esac
 
 $spitshell >>$Makefile <<!GROK!THIS!
-x2p/$firstmakefile:    makedepend
-       cd x2p; \$(MAKE) depend
-
-translators:   $x2p_deps
-       @echo " "; echo "       Making x2p stuff"; cd x2p; \$(LDLIBPTH) \$(MAKE) all
-
-x2p/s2p: $x2p_deps
-       cd x2p; \$(LDLIBPTH) \$(MAKE) s2p
+utils/Makefile: \$(MINIPERL_EXE) \$(CONFIGPM) utils/Makefile.PL
+       \$(MINIPERL) -Ilib utils/Makefile.PL
 
-x2p/find2perl: $x2p_deps
-       cd x2p; \$(LDLIBPTH) \$(MAKE) find2perl
-
-utilities:     $util_deps
+utilities:     utils/Makefile $util_deps
        @echo " "; echo "       Making utilities"; cd utils; \$(LDLIBPTH) \$(MAKE) all
 
 !GROK!THIS!
@@ -663,7 +642,8 @@ ${file}mini.c: $file.c
     $spitshell >>$Makefile <<!GROK!THIS!
 
 ${file}mini\$(OBJ_EXT): ${file}mini.c
-       \$(CCCMD) \$(PLDLFLAGS) $DPERL_IS_MINIPERL $DPERL_EXTERNAL_GLOB ${file}mini.c
+       echo @\`\$(CCCMD)\` \$(PLDLFLAGS) $DPERL_IS_MINIPERL $DPERL_EXTERNAL_GLOB ${file}mini.c
+       @\`\$(CCCMD)\` \$(PLDLFLAGS) $DPERL_IS_MINIPERL $DPERL_EXTERNAL_GLOB ${file}mini.c
 !GROK!THIS!
 done
 
@@ -673,22 +653,48 @@ globals$(OBJ_EXT): $(generated_headers)
 
 uudmap.h mg_data.h: bitcount.h
 
-bitcount.h: generate_uudmap$(HOST_EXE_EXT)
-       $(RUN) ./generate_uudmap$(HOST_EXE_EXT) $(generated_headers)
-
 generate_uudmap$(OBJ_EXT): mg_raw.h
 
+!NO!SUBS!
+
+# If hostgerenate isn't defined, then we have to build
+# generate_uudmap and run it. This can potentially mean running
+# it on the target system if we're cross-compiling.
+# If it is defined, then we just run it locally.
+case "$hostgenerate" in
+'')
+$spitshell >>$Makefile <<!GROK!THIS!
+bitcount.h: generate_uudmap\$(HOST_EXE_EXT)
+       $run ./generate_uudmap\$(HOST_EXE_EXT) \$(generated_headers)
+       -@for f in \$(generated_headers); do \\
+           $from \$\$f; \\
+       done
+
+!GROK!THIS!
+
+$spitshell >>$Makefile <<'!NO!SUBS!'
 generate_uudmap$(HOST_EXE_EXT): generate_uudmap$(OBJ_EXT)
        $(CC) -o generate_uudmap$(EXE_EXT) $(LDFLAGS) generate_uudmap$(OBJ_EXT) $(libs)
 
-miniperlmain$(OBJ_EXT): miniperlmain.c patchlevel.h
-       $(CCCMD) $(PLDLFLAGS) $*.c
+!NO!SUBS!
+;;
+*)
+$spitshell >>$Makefile <<'!NO!SUBS!'
+bitcount.h: generate_uudmap$(HOST_EXE_EXT)
+       ./generate_uudmap$(HOST_EXE_EXT) $(generated_headers)
+
+generate_uudmap$(HOST_EXE_EXT): generate_uudmap$(OBJ_EXT)
+       -@rm generate_uudmap$(HOST_EXE_EXT)
+       $(LNS) $(HOST_GENERATE) generate_uudmap$(HOST_EXE_EXT)
 
-perlmain.c: $(MINIPERL_EXE) lib/ExtUtils/Miniperl.pm
-       $(MINIPERL) -Ilib -MExtUtils::Miniperl -e 'writemain(@ARGV)' DynaLoader $(static_ext) > perlmain.c
+!NO!SUBS!
+;;
+esac
 
-perlmain$(OBJ_EXT): perlmain.c
-       $(CCCMD) $(PLDLFLAGS) $*.c
+
+$spitshell >>$Makefile <<'!NO!SUBS!'
+perlmain.c: $(MINIPERL_EXE) ext/ExtUtils-Miniperl/pm_to_blib
+       $(MINIPERL) -Ilib -MExtUtils::Miniperl -e 'writemain(\"perlmain.c", @ARGV)' DynaLoader $(static_ext)
 
 # The file ext.libs is a list of libraries that must be linked in
 # for static extensions, e.g. -lm -lgdbm, etc.  The individual
@@ -853,7 +859,7 @@ $(LIBPERL): $& $(obj) $(DYNALOADER) $(LIBPERLEXPORT)
 # lib/buildcustomize.pl despite the reality that lib/buildcustomize.pl needs
 # miniperl to exist first permits us to
 # a) have one rule generate both miniperl and lib/buildcustomize.pl
-#    (so that lib/buildcustomise.pl is always available. This simplifies things)
+#    (so that lib/buildcustomize.pl is always available. This simplifies things)
 # b) have the rest of the Makefile depend on the more obvious $(MINIPERL_EXE)
 
 $(MINIPERL_EXE): lib/buildcustomize.pl
@@ -865,16 +871,16 @@ $(MINIPERL_EXE): lib/buildcustomize.pl
                $spitshell >>$Makefile <<'!NO!SUBS!'
 lib/buildcustomize.pl: $& $(mini_obj)
        $(CC) -o $(MINIPERL_EXE) $(CLDFLAGS) $(mini_obj) $(libs)
-       $(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
-       $(MINIPERL) write_buildcustomize.pl >lib/buildcustomize.pl
+       $(LDLIBPTH) ./miniperl$(HOST_EXE_EXT) -w -Ilib -Idist/Exporter/lib -MExporter -e '<?>' || sh -c 'echo >&2 Failed to build miniperl.  Please run make minitest; exit 1'
+       $(MINIPERL) -f write_buildcustomize.pl
 !NO!SUBS!
                ;;
        next4*)
                $spitshell >>$Makefile <<'!NO!SUBS!'
-lib/buildcustomize.pl: $& $(mini_obj) write_buildcustomize.pl
-       $(CC) -o $(MINIPERL_EXE) $(mini_obj) $(libs)
-       $(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
-       $(MINIPERL) write_buildcustomize.pl >lib/buildcustomize.pl
+lib/buildcustomize.pl: $& $(mini_obj) write    ldcustomize.pl
+       $(CC) -o $(MINIPERL_EXE) $(mini_obj    libs)
+       $(LDLIBPTH) ./miniperl$(HOST    _EXT) -w -Ilib -Idist/Exporter/lib -MExporter -e '<?>' || sh -c 'echo >&2 Failed to build miniperl.  Please run make minitest; exit 1'
+       $(MINIPERL) -f write_buildcustomize.pl    
 !NO!SUBS!
                ;;
        darwin*)
@@ -895,19 +901,30 @@ lib/buildcustomize.pl: $& $(mini_obj) write_buildcustomize.pl
        -@rm -f miniperl.xok
        $(CC) $(CLDFLAGS) $(NAMESPACEFLAGS) -o $(MINIPERL_EXE) \
            $(mini_obj) $(libs)
-       $(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
-       $(MINIPERL) write_buildcustomize.pl >lib/buildcustomize.pl
+       $(LDLIBPTH) ./miniperl$(HOST_EXE_EXT) -w -Ilib -Idist/Exporter/lib -MExporter -e '<?>' || sh -c 'echo >&2 Failed to build miniperl.  Please run make minitest; exit 1'
+       $(MINIPERL) -f write_buildcustomize.pl
 !NO!SUBS!
                ;;
        *)
-               $spitshell >>$Makefile <<'!NO!SUBS!'
+               if test "X$hostperl" != X; then
+                       $spitshell >>$Makefile <<!GROK!THIS!
+lib/buildcustomize.pl: \$& \$(mini_obj) write_buildcustomize.pl
+       -@rm -f miniperl.xok
+       -@rm \$(MINIPERL_EXE)
+       \$(LNS) \$(HOST_PERL) \$(MINIPERL_EXE)
+       \$(LDLIBPTH) ./miniperl\$(HOST_EXE_EXT) -w -Ilib -Idist/Exporter/lib -MExporter -e '<?>' || sh -c 'echo >&2 Failed to build miniperl.  Please run make minitest; exit 1'
+       \$(MINIPERL) -f write_buildcustomize.pl 'osname' "$osname"
+!GROK!THIS!
+               else
+                       $spitshell >>$Makefile <<'!NO!SUBS!'
 lib/buildcustomize.pl: $& $(mini_obj) write_buildcustomize.pl
        -@rm -f miniperl.xok
-       $(LDLIBPTH) $(CC) $(CLDFLAGS) -o $(MINIPERL_EXE) \
+       $(CC) $(CLDFLAGS) -o $(MINIPERL_EXE) \
            $(mini_obj) $(libs)
-       $(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
-       $(MINIPERL) write_buildcustomize.pl >lib/buildcustomize.pl
+       $(LDLIBPTH) ./miniperl$(HOST_EXE_EXT) -w -Ilib -Idist/Exporter/lib -MExporter -e '<?>' || sh -c 'echo >&2 Failed to build miniperl.  Please run make minitest; exit 1'
+       $(MINIPERL) -f write_buildcustomize.pl
 !NO!SUBS!
+               fi
                ;;
        esac
 
@@ -915,110 +932,7 @@ lib/buildcustomize.pl: $& $(mini_obj) write_buildcustomize.pl
 
 $(PERL_EXE): $& perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs $(PERLEXPORT) write_buildcustomize.pl
        -@rm -f miniperl.xok
-       $(SHRPENV) $(LDLIBPTH) $(CC) -o perl$(PERL_SUFFIX) $(PERL_PROFILE_LDFLAGS) $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
-
-# Purify/Quantify Perls.
-
-pure$(PERL_EXE): $& perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs $(PERLEXPORT)
-       $(SHRPENV) $(LDLIBPTH) purify $(CC) -o pureperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
-
-purecov$(PERL_EXE): $& perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs $(PERLEXPORT)
-       $(SHRPENV) $(LDLIBPTH) purecov $(CC) -o purecovperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
-
-quant$(PERL_EXE): $& perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs $(PERLEXPORT)
-       $(SHRPENV) $(LDLIBPTH) quantify $(CC) -o quantperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
-
-!NO!SUBS!
-
-case "${osname}${osvers}" in
-linux*|darwin*)
-       $spitshell >>$Makefile <<'!NO!SUBS!'
-# Valgrind perl (currently Linux, Darwin only)
-
-perl.valgrind.config: config.sh
-       @echo "To build perl.valgrind you must Configure -Doptimize=-g -Uusemymalloc, checking..."
-       @$(MAKE) perl.config.dashg
-       @echo "Checking usemymalloc='n' in config.sh..."
-       @grep "^usemymalloc="    config.sh
-       @grep "^usemymalloc='n'" config.sh >/dev/null || exit 1
-       @echo "And of course you have to have valgrind..."
-       $(VALGRIND) $(VG_TEST) || exit 1
-!NO!SUBS!
-       ;;
-esac   
-
-$spitshell >>$Makefile <<'!NO!SUBS!'
-
-# Third Degree Perl (Tru64 only)
-
-perl.config.dashg:
-       @echo "Checking optimize='-g' in config.sh..."
-       @grep "^optimize=" config.sh
-       @egrep "^optimize='(.*-g.*)'" config.sh >/dev/null || exit 1
-
-perl.third.config: config.sh
-       @echo "To build perl.third you must Configure -Doptimize=-g -Uusemymalloc, checking..."
-       @$(MAKE) perl.config.dashg
-       @echo "Checking usemymalloc='n' in config.sh..."
-       @grep "^usemymalloc="    config.sh
-       @grep "^usemymalloc='n'" config.sh >/dev/null || exit 1
-
-perl.third: /usr/bin/atom perl.third.config perl
-       atom -tool third -L. -all -gp -toolargs="-invalid -uninit heap+stack+copy -min 0" perl
-       @echo "Now you may run perl.third and then study perl.3log."
-
-# Pixie Perls (Tru64 and IRIX only)
-
-perl.pixie.config: config.sh
-       @echo "To build perl.pixie you must Configure -Doptimize=-g, checking..."
-       @$(MAKE) perl.config.dashg
-
-perl.pixie.atom: /usr/bin/atom perl
-       atom -tool pixie -L. -all -toolargs="-quiet" perl
-
-perl.pixie.irix: perl
-       pixie perl
-
-perl.pixie: /usr/bin/pixie perl.pixie.config perl
-       if test -x /usr/bin/atom; then \
-         $(MAKE) perl.pixie.atom; \
-       else \
-         $(MAKE) perl.pixie.irix; \
-       fi
-       @echo "Now you may run perl.pixie and then run pixie."
-
-# Gprof Perl
-
-perl.config.dashpg:
-       @echo "Checking optimize='-pg' in config.sh..."
-       @grep "^optimize="      config.sh
-       @grep "^optimize='.*-pg.*'" config.sh >/dev/null || exit 1
-
-perl.gprof.config: config.sh
-       @echo "To build perl.gprof you must Configure -Doptimize=-pg, checking..."
-       @$(MAKE) perl.config.dashpg
-
-perl.gprof: /usr/bin/gprof perl.gprof.config
-       @-rm -f perl
-       $(MAKE) PERL_SUFFIX=.gprof PERL_PROFILE_LDFLAGS=-pg perl
-       @echo "Now you may run perl.gprof and then run gprof perl.gprof."
-
-# Gcov Perl
-
-perl.config.gcov:
-       @echo "To build perl.gcov you must use gcc 3.0 or newer, checking..."
-       @echo "Checking gccversion in config.sh..."
-       @grep "^gccversion="      config.sh
-       @grep "^gccversion='[3-9]\." config.sh >/dev/null || exit 1
-       @echo "To build perl.gcov you must Configure -Dccflags=-fprofile-arcs -ftest-coverage, checking..."
-       @echo "Checking ccflags='-fprofile-arcs -ftest-coverage' in config.sh..."
-       @grep "^ccflags="      config.sh
-       @grep "^ccflags='.*-fprofile-arcs -ftest-coverage.*'" config.sh >/dev/null || exit 1
-
-perl.gcov: perl.config.gcov
-       @-rm -f perl
-       $(MAKE) PERL_SUFFIX=.gcov PERL_PROFILE_LDFLAGS='' perl
-       @echo "Now you may run perl.gcov and then run gcov some.c."
+       $(SHRPENV) $(CC) -o perl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
 
 # Microperl.  This is just a convenience thing if one happens to
 # build also the full Perl and therefore the real big Makefile:
@@ -1065,9 +979,6 @@ $(CONFIGPM_FROM_CONFIG_SH): $(CONFIGPOD)
 $(CONFIGPOD): config.sh $(MINIPERL_EXE) configpm Porting/Glossary lib/Config_git.pl
        $(MINIPERL) configpm
 
-lib/ExtUtils/Miniperl.pm: miniperlmain.c $(MINIPERL_EXE) minimod.pl $(CONFIGPM)
-       $(MINIPERL) minimod.pl > lib/ExtUtils/Miniperl.pm
-
 unidatafiles $(unidatafiles) pod/perluniprops.pod: uni.data
 
 uni.data: $(MINIPERL_EXE) $(CONFIGPM) lib/unicore/mktables $(nonxs_ext)
@@ -1076,24 +987,23 @@ uni.data: $(MINIPERL_EXE) $(CONFIGPM) lib/unicore/mktables $(nonxs_ext)
 #      can in this makefile to decide if needs to run or not
 #      touch uni.data
 
-# $(PERL_EXE) and ext because buildtoc uses Text::Wrap uses re
+# $(PERL_EXE) and ext because pod_lib.pl needs Digest::MD5
 # But also this ensures that all extensions are built before we try to scan
 # them, which picks up Devel::PPPort's documentation.
 pod/perltoc.pod: $(perltoc_pod_prereqs)  $(PERL_EXE) $(ext) pod/buildtoc
-       $(RUN_PERL) -f -Ilib pod/buildtoc -q
+       $(RUN_PERL) -f pod/buildtoc -q
 
 pod/perlapi.pod: pod/perlintern.pod
 
-# Depending on $(nonxs_ext) gets us Text::Wrap built
-pod/perlintern.pod: $(MINIPERL_EXE) autodoc.pl embed.fnc $(nonxs_ext)
+pod/perlintern.pod: $(MINIPERL_EXE) autodoc.pl embed.fnc
        $(MINIPERL) autodoc.pl
 
 pod/perlmodlib.pod: $(MINIPERL_EXE) pod/perlmodlib.PL MANIFEST
        $(MINIPERL) pod/perlmodlib.PL -q
 
-pod/perl5191delta.pod: pod/perldelta.pod
-       $(RMS) pod/perl5191delta.pod
-       $(LNS) perldelta.pod pod/perl5191delta.pod
+pod/perl5211delta.pod: pod/perldelta.pod
+       $(RMS) pod/perl5211delta.pod
+       $(LNS) perldelta.pod pod/perl5211delta.pod
 
 extra.pods: $(MINIPERL_EXE)
        -@test ! -f extra.pods || rm -f `cat extra.pods`
@@ -1105,40 +1015,77 @@ extra.pods: $(MINIPERL_EXE)
        done
 
 extras.make: $(PERL_EXE)
-       -@test ! -s extras.lst || PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib -MCPAN -e '@ARGV&&make(@ARGV)' `cat extras.lst`
+       -@test ! -s extras.lst || PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -MCPAN -e '@ARGV&&make(@ARGV)' `cat extras.lst`
 
 extras.test: $(PERL_EXE)
-       -@test ! -s extras.lst || PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib -MCPAN -e '@ARGV&&test(@ARGV)' `cat extras.lst`
+       -@test ! -s extras.lst || PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -MCPAN -e '@ARGV&&test(@ARGV)' `cat extras.lst`
 
 extras.install: $(PERL_EXE)
-       -@test ! -s extras.lst || PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib -MCPAN -e '@ARGV&&install(@ARGV)' `cat extras.lst`
+       -@test ! -s extras.lst || PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -MCPAN -e '@ARGV&&install(@ARGV)' `cat extras.lst`
 
 .PHONY: install install-strip install-all install-verbose install-silent \
        no-install install.perl install.man install.html
 
-install_strip install-strip:
-       $(MAKE) STRIPFLAGS=-s install DESTDIR="$(DESTDIR)"
+# Set this to an empty string to avoid an attempt of rebuild before install
+INSTALL_DEPENDENCE = all
 
-install install_all install-all:
-       $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) DESTDIR="$(DESTDIR)"
+no_install no-install: install-notify
 
-install_verbose install-verbose:
-       $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-V DESTDIR="$(DESTDIR)"
+install: install-all
+!NO!SUBS!
 
-install_silent install-silent:
-       $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-S DESTDIR="$(DESTDIR)"
 
-no_install no-install:
-       $(MAKE) install.perl install.man STRIPFLAGS=$(STRIPFLAGS) INSTALLFLAGS=-n DESTDIR="$(DESTDIR)"
+for name in all notify silent strip verbose; do
+    flags="--$name";
+    flags=`echo $flags | sed -e 's/--all//'`
+    if test "X$hostperl" != X; then
+        $spitshell >>$Makefile <<EOT
 
-# Set this to an empty string to avoid an attempt of rebuild before install
-INSTALL_DEPENDENCE = all
+install_$name install-$name: \$(INSTALL_DEPENDENCE) installperl all installman
+       \$(HOST_PERL) installperl --destdir=\$(DESTDIR) $flags \$(INSTALLFLAGS) \$(STRIPFLAGS)
+       \$(HOST_PERL) installman --destdir=\$(DESTDIR) $flags
+EOT
+    else
+        $spitshell >>$Makefile <<EOT
 
+install_$name install-$name: \$(INSTALL_DEPENDENCE) installperl all installman
+       \$(RUN_PERL) installperl --destdir=\$(DESTDIR) $flags \$(INSTALLFLAGS) \$(STRIPFLAGS)
+       \$(RUN_PERL) installman --destdir=\$(DESTDIR) $flags
+EOT
+    fi
+
+    test $name = notify || echo '      -@test ! -s extras.lst || PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib -MCPAN -e '\''@ARGV&&install(@ARGV)'\'' `cat extras.lst`' >>$Makefile
+done
+
+if test "X$hostperl" != X; then
+       $spitshell >>$Makefile <<'!NO!SUBS!'
 install.perl:  $(INSTALL_DEPENDENCE) installperl
-       $(RUN_PERL) installperl --destdir=$(DESTDIR) $(INSTALLFLAGS) $(STRIPFLAGS)
+       $(HOST_PERL) installperl --destdir=$(DESTDIR) $(INSTALLFLAGS) $(STRIPFLAGS)
        -@test ! -s extras.lst || $(MAKE) extras.install
 
 install.man:   all installman
+       $(HOST_PERL) installman --destdir=$(DESTDIR) $(INSTALLFLAGS)
+
+# XXX Experimental. Hardwired values, but useful for testing.
+# Eventually Configure could ask for some of these values.
+install.html: all installhtml
+       -@test -f README.vms && cd vms && $(LNS) ../README.vms README_vms.pod && cd ..
+       $(HOST_PERL) installhtml   \
+      --podroot=. --podpath=. --recurse  \
+      --htmldir=$(privlib)/html   \
+      --htmlroot=$(privlib)/html  \
+      --splithead=pod/perlipc     \
+      --splititem=pod/perlfunc    \
+      --ignore=Porting/Maintainers.pm,Porting/pumpkin.pod,Porting/repository.pod \
+      --verbose
+!NO!SUBS!
+else
+       $spitshell >>$Makefile <<'!NO!SUBS!'
+install.perl:  $(INSTALL_DEPENDENCE) installperl
+       $(RUN_PERL) installperl --destdir=$(DESTDIR) $(INSTALLFLAGS) $(STRIPFLAGS)
+       -@test ! -s extras.lst || PATH="`pwd`:\${PATH}" PERL5LIB="`pwd`/lib" \$(RUN_PERL) -Ilib -MCPAN -e '@ARGV&&install(@ARGV)' `cat extras.lst`
+
+install.man:   all installman
        $(RUN_PERL) installman --destdir=$(DESTDIR) $(INSTALLFLAGS)
 
 # XXX Experimental. Hardwired values, but useful for testing.
@@ -1153,7 +1100,10 @@ install.html: all installhtml
       --splititem=pod/perlfunc    \
       --ignore=Porting/Maintainers.pm,Porting/pumpkin.pod,Porting/repository.pod \
       --verbose
+!NO!SUBS!
+fi
 
+$spitshell >>$Makefile <<'!NO!SUBS!'
 
 # I now supply perly.c with the kits, so the following section is
 # used only if you force bison to run by saying
@@ -1214,10 +1164,10 @@ regen_headers regen-headers:    FORCE
 regen_meta regen-meta:  META.yml META.json
 
 META.yml:   FORCE
-       PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib Porting/makemeta -y
+       PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) Porting/makemeta -y
 
 META.json:   FORCE
-       PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib Porting/makemeta -j
+       PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) Porting/makemeta -j
 
 
 regen_all regen-all: regen regen_meta
@@ -1262,7 +1212,7 @@ $spitshell >>$Makefile <<'!NO!SUBS!'
 
 .PHONY: printconfig
 printconfig:
-       @eval `$(RUN_PERL) -Ilib -V:$(CONFIGVAR)`; echo $$$(CONFIGVAR)
+       @eval `$(RUN_PERL) -V:$(CONFIGVAR)`; echo $$$(CONFIGVAR)
 
 .PHONY: clean _tidy _mopup _cleaner1 _cleaner2 \
        realclean _realcleaner clobber _clobber \
@@ -1274,7 +1224,8 @@ realclean:        _realcleaner _mopup
        @echo "Note that '$(MAKE) realclean' does not delete config.sh or Policy.sh"
 
 _clobber:
-       -@rm -f Cross/run-* Cross/to-* Cross/from-*
+       -@rm -f Cross/run-* Cross/to-* Cross/from-* Cross/mkdir
+       -rm -rf host
        rm -f t/test_state
        rm -f config.sh cppstdin Policy.sh extras.lst
 
@@ -1294,9 +1245,7 @@ _mopup:
        -@test -f vms/README_vms.pod && rm -f vms/README_vms.pod
        -rm -f perl.exp ext.libs $(generated_pods) uni.data opmini.o perlmini.o pod/roffitall
        -rm -f perl.export perl.dll perl.libexp perl.map perl.def
-       -rm -f perl.third lib*.so.perl.third perl.3log t/perl.third t/perl.3log
-       -rm -f perl.pixie lib*.so.perl.pixie lib*.so.Addrs
-       -rm -f perl.Addrs perl.Counts t/perl.Addrs t/perl.Counts *perl.xok
+       -rm -f *perl.xok
        -rm -f cygwin.c libperl*.def libperl*.dll cygperl*.dll *.exe.stackdump
        -rm -f $(PERL_EXE) $(MINIPERL_EXE) $(LIBPERL) libperl.* microperl
        -rm -f config.arch config.over $(DTRACE_H)
@@ -1305,7 +1254,6 @@ _mopup:
 _tidy:
        -cd pod; $(LDLIBPTH) $(MAKE) clean
        -cd utils; $(LDLIBPTH) $(MAKE) clean
-       -cd x2p; $(LDLIBPTH) $(MAKE) clean
        -rm -f lib/Config_git.pl git_version.h
        -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
        $(MINIPERL) make_ext.pl --target=clean $$x MAKE=$(MAKE) ; \
@@ -1315,7 +1263,6 @@ _cleaner1:
        -cd os2; rm -f Makefile
        -cd pod; $(LDLIBPTH) $(MAKE) $(CLEAN)
        -cd utils; $(LDLIBPTH) $(MAKE) $(CLEAN)
-       -cd x2p; $(LDLIBPTH) $(MAKE) $(CLEAN)
        -@if test -f $(MINIPERL_EXE) ; then \
        for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
        $(MINIPERL) make_ext.pl --target=$(CLEAN) $$x MAKE=$(MAKE) ; \
@@ -1324,7 +1271,7 @@ _cleaner1:
        sh $(CLEAN).sh ; \
        fi
        rm -f realclean.sh veryclean.sh
-       -for file in `find cpan dist ext -name ppport.h` ; do rm -f $$file; done
+       -rm -f `grep -v ^# mkppport.lst | grep . | sed -e 's/$$/\/ppport.h/'`
 
 # Dear POSIX, thanks for making the default to xargs to be
 # run once if nothhing is passed in. It is such a great help.
@@ -1335,9 +1282,8 @@ _cleaner2:
        rm -f core *perl.core t/core t/*perl.core core.* t/core.*
        rm -f t/$(PERL_EXE) t/rantests
        rm -rf t/tmp*
-       rm -f so_locations $(LIBPERL_NONSHR) $(MINIPERL_NONSHR)
        rm -rf $(addedbyconf)
-       rm -f $(FIRSTMAKEFILE) $(FIRSTMAKEFILE).old makefile.old
+       rm -f $(FIRSTMAKEFILE) $(FIRSTMAKEFILE).old makefile.old utils/Makefile
        rm -f $(private)
        rm -rf $(unidatafiles) $(unidatadirs)
        rm -rf lib/auto
@@ -1345,45 +1291,44 @@ _cleaner2:
        rm -f h2ph.man pstruct
        rm -rf .config
        rm -f preload
-       rm -rf lib/Encode lib/Compress lib/Hash lib/re
-       rm -rf lib/TAP lib/Module/Pluggable lib/App
-       rm -rf lib/mro
-       rm -rf lib/IO/Compress lib/IO/Uncompress
-       rm -f lib/ExtUtils/ParseXS/t/XSTest.c
-       rm -f lib/ExtUtils/ParseXS/t/XSTest$(OBJ_EXT)
-       rm -f lib/ExtUtils/ParseXS/t/XSTest$(DLSUFFIX)
-       rm -fr lib/B
-       rm -fr lib/CPAN
-       rm -fr lib/ExtUtils/CBuilder
        rm -f pod2htmd.tmp
        rm -rf pod/perlfunc pod/perlipc
        -rmdir ext/B/lib
-       -rmdir lib/Archive/Tar lib/Archive lib/Attribute
-       -rmdir lib/CGI lib/Carp
-       -rmdir lib/Data lib/Devel lib/Digest
-       -rmdir lib/ExtUtils/Command lib/ExtUtils/Constant lib/ExtUtils/Liblist lib/ExtUtils/MakeMaker
-       -rmdir lib/File/Spec lib/Filter/Util lib/Filter
-       -rmdir lib/I18N/LangTags lib/IO/Socket lib/IO lib/IPC
-       -rmdir lib/List/Util lib/List
-       -rmdir lib/Locale/Maketext lib/Locale
-       -rmdir lib/Log/Message lib/Log
-       -rmdir lib/Math/Big* lib/Math
-       -rmdir lib/Memoize lib/MIME
-       -rmdir lib/Module/Build/Platform lib/Module/Build lib/Module/Load lib/Module
-       -rmdir lib/Net/FTP lib/Object
-       -rmdir lib/Parse/CPAN lib/Parse
-       -rmdir lib/PerlIO/via lib/PerlIO
-       -rmdir lib/Package lib/Params
-       -rmdir lib/Pod/Perldoc lib/Pod/Simple lib/Pod/Text
-       -rmdir lib/Sys lib/Scalar/Util lib/Scalar
-       -rmdir lib/Term/UI lib/Thread lib/Tie/Hash
-       -rmdir lib/Test/Builder/Tester lib/Test/Builder lib/Test
-       -rmdir lib/Unicode/Collate
-       -rmdir lib/XS/APItest lib/XS
-       -rmdir lib/inc/latest lib/inc
-       -rmdir lib/autodie/exception lib/autodie lib/encoding lib/threads
-       -rm -f lib/ExtUtils/CBuilder/t/libcompilet.dll.a
-       -rm -f lib/ExtUtils/ParseXS/t/libXSTest.dll.a
+       rm -f so_locations $(LIBPERL_NONSHR) $(MINIPERL_NONSHR)
+       -rmdir lib/version lib/threads lib/encoding lib/autodie/exception
+       -rmdir lib/autodie/Scope lib/autodie lib/XS lib/Win32API lib/VMS
+       -rmdir lib/Unicode/Collate/Locale lib/Unicode/Collate/CJK
+       -rmdir lib/Unicode/Collate lib/Tie/Hash lib/Thread lib/Text
+       -rmdir lib/Test/Builder/Tester lib/Test/Builder lib/Test lib/Term
+       -rmdir lib/TAP/Parser/YAMLish lib/TAP/Parser/SourceHandler
+       -rmdir lib/TAP/Parser/Scheduler lib/TAP/Parser/Result
+       -rmdir lib/TAP/Parser/Iterator lib/TAP/Parser lib/TAP/Harness
+       -rmdir lib/TAP/Formatter/File lib/TAP/Formatter/Console
+       -rmdir lib/TAP/Formatter lib/TAP lib/Sys/Syslog lib/Sys lib/Search
+       -rmdir lib/Scalar lib/Pod/Text lib/Pod/Simple lib/Pod/Perldoc
+       -rmdir lib/PerlIO/via lib/PerlIO lib/Perl lib/Parse/CPAN lib/Parse
+       -rmdir lib/Params lib/Net/FTP lib/Module/Load lib/Module/CoreList
+       -rmdir lib/Module lib/Memoize lib/Math/BigInt lib/Math/BigFloat
+       -rmdir lib/Math lib/MIME lib/Locale/Maketext lib/Locale/Codes
+       -rmdir lib/Locale lib/List/Util lib/List lib/JSON/PP lib/JSON lib/IPC
+       -rmdir lib/IO/Uncompress/Adapter lib/IO/Uncompress lib/IO/Socket
+       -rmdir lib/IO/Compress/Zlib lib/IO/Compress/Zip lib/IO/Compress/Gzip
+       -rmdir lib/IO/Compress/Base lib/IO/Compress/Adapter lib/IO/Compress
+       -rmdir lib/IO lib/I18N/LangTags lib/I18N lib/Hash/Util lib/Hash
+       -rmdir lib/HTTP lib/Filter/Util lib/Filter lib/File/Spec
+       -rmdir lib/ExtUtils/Typemaps lib/ExtUtils/ParseXS
+       -rmdir lib/ExtUtils/MakeMaker lib/ExtUtils/Liblist
+       -rmdir lib/ExtUtils/Constant lib/ExtUtils/Command
+       -rmdir lib/ExtUtils/CBuilder/Platform/Windows
+       -rmdir lib/ExtUtils/CBuilder/Platform lib/ExtUtils/CBuilder
+       -rmdir lib/Exporter lib/Encode/Unicode lib/Encode/MIME/Header
+       -rmdir lib/Encode/MIME lib/Encode/KR lib/Encode/JP lib/Encode/CN
+       -rmdir lib/Encode lib/Digest lib/Devel lib/Data lib/Config/Perl
+       -rmdir lib/Compress/Raw lib/Compress lib/Carp lib/CPAN/Meta
+       -rmdir lib/CPAN/LWP lib/CPAN/Kwalify lib/CPAN/HTTP lib/CPAN/FTP
+       -rmdir lib/CPAN/Exception lib/CPAN/API lib/CPAN lib/Attribute
+       -rmdir lib/Archive/Tar lib/Archive lib/App/Prove/State/Result
+       -rmdir lib/App/Prove/State lib/App/Prove lib/App
 
 _realcleaner:
        @$(LDLIBPTH) $(MAKE) _cleaner1 CLEAN=distclean
@@ -1430,15 +1375,11 @@ depend: makedepend
 
 .PHONY: test check test_prep test_prep_nodll test_prep_pre \
        test_prep_reonly test_tty test-tty test_notty test-notty \
-       utest ucheck test.utf8 check.utf8 test.torture torturetest \
-       test.utf16 check.utf16 utest.utf16 ucheck.utf16 \
-       test.third check.third utest.third ucheck.third test_notty.third \
-       test.deparse test_notty.deparse test_harness test_harness_notty \
-       minitest coretest test.taintwarn test-reonly _test
+       test_harness test_harness_notty minitest test-reonly _test
 
 _test:
        echo >&2 The _test target is deprecated. Please upgrade your smoker
-       PERL=./perl $(RUN_TESTS) choose
+       $(RUN_TESTS) choose
 
 # Cannot delegate rebuilding of t/perl to make
 # to allow interlaced test and minitest
@@ -1446,48 +1387,94 @@ _test:
 # Architecture-neutral stuff:
 
 test_prep_pre: preplibrary utilities $(nonxs_ext)
+!NO!SUBS!
 
+case "$targethost" in
+'') $spitshell >>$Makefile <<'!NO!SUBS!'
 test_prep test-prep: test_prep_pre $(MINIPERL_EXE) $(unidatafiles) $(PERL_EXE) \
-       $(dynamic_ext) $(TEST_PERL_DLL) runtests x2p/s2p x2p/find2perl \
-       $(generated_pods)
+       $(dynamic_ext) $(TEST_PERL_DLL) runtests $(generated_pods)
        cd t && (rm -f $(PERL_EXE); $(LNS) ../$(PERL_EXE) $(PERL_EXE))
 
+!NO!SUBS!
+;;
+*) $spitshell >>$Makefile <<!GROK!THIS!
+test_prep test-prep: test_prep_pre \$(MINIPERL_EXE) \$(unidatafiles) \$(PERL_EXE) \
+       \$(dynamic_ext) \$(TEST_PERL_DLL) runtests \
+       \$(generated_pods)
+       $to libperl.*
+       $to t/*
+       $to lib/*
+       $to TestInit.pm
+       $to win32/FindExt.pm
+       $to regen/*
+       $to pod/*
+       $to MANIFEST
+       $to Porting/*
+       $to cpan/*/t
+       $to dist/*/t
+       $to ext/*/t
+       $to cpan/Term-Cap/test.pl
+       $to cpan/Pod-Usage/*
+       $to cpan/Pod-Parser/*
+       $to cpan/IO-Compress/*
+       $to cpan/HTTP-Tiny/lib/*
+       $to cpan/Filter-Util-Call/filter-util.pl
+       $to cpan/Digest-MD5/*
+       $to cpan/Digest-SHA/*
+       $to cpan/Test-Simple/*
+       $to cpan/Pod-Parser/lib/*
+       $to cpan/Test-Harness/*
+       $to cpan/Scalar-List-Utils/*
+       $to ext/IPC-Open3/*
+       $to ext/Tie-Memoize/*
+       $to ext/POSIX/*
+       $to dist/IO/*
+# --- These three are needed by ExtUtils::MM_Unix to verify PERL_CORE
+       $to config_h.SH
+       $to perl.h
+       $to cflags
+       $to *.h
+# --- For t/TEST
+       $to config.sh
+# --- For lib/diagnostics.t with -Duseshrplib
+       $to \$(PERL_EXE)
+       cd t && (rm -f \$(PERL_EXE); \$(LNS) ../\$(PERL_EXE) \$(PERL_EXE)) && cd ..
+       $to t/\$(PERL_EXE)
+
+!GROK!THIS!
+;;
+esac
+
+$spitshell >>$Makefile <<'!NO!SUBS!'
 test_prep_reonly: $(MINIPERL_EXE) $(PERL_EXE) $(dynamic_ext_re) $(TEST_PERL_DLL)
        $(MINIPERL) make_ext.pl $(dynamic_ext_re) MAKE=$(MAKE) LIBPERL_A=$(LIBPERL) LINKTYPE=dynamic
        cd t && (rm -f $(PERL_EXE); $(LNS) ../$(PERL_EXE) $(PERL_EXE))
+!NO!SUBS!
+
+case "$targethost" in
+'') $spitshell >>$Makefile <<'!NO!SUBS!'
 
 test check: test_prep
        $(RUN_TESTS) choose
 
+!NO!SUBS!
+;;
+*) $spitshell >>$Makefile <<!GROK!THIS!
+
+test check: test_prep
+       $run -cwd $targetdir/t -env "$targetenv LD_LIBRARY_PATH=$targetdir:$targetdir/lib:$targetdir/lib/auto:\$\$LD_LIBRARY_PATH" ./TEST
+
+!GROK!THIS!
+;;
+esac
+
+$spitshell >>$Makefile <<'!NO!SUBS!'
 test_tty test-tty: test_prep
        $(RUN_TESTS) tty
 
 test_notty test-notty: test_prep
        $(RUN_TESTS) no-tty
 
-utest ucheck test.utf8 check.utf8: test_prep
-       TEST_ARGS=-utf8 $(RUN_TESTS) choose
-
-coretest: test_prep
-       TEST_ARGS=-core $(RUN_TESTS) choose
-
-# Torture testing
-
-test.torture torturetest:      test_prep
-       TEST_ARGS=-torture $(RUN_TESTS) choose
-
-# Targets for UTF16 testing:
-
-minitest.utf16: minitest.prep
-       - cd t && (rm -f $(PERL_EXE); $(LNS) ../$(MINIPERL_EXE) $(PERL_EXE)) \
-               && $(RUN_PERL) TEST -utf16 base/*.t comp/*.t cmd/*.t run/*.t io/*.t opbasic/*.t op/*.t uni/*.t </dev/tty
-
-test.utf16 check.utf16: test_prep
-       TEST_ARGS=-utf16 $(RUN_TESTS) choose
-
-utest.utf16 ucheck.utf16: test_prep
-       TEST_ARGS="-utf8 -utf16" $(RUN_TESTS) choose
-
 !NO!SUBS!
 
 case "${osname}${osvers}" in
@@ -1495,59 +1482,27 @@ linux*|darwin*)
        $spitshell >>$Makefile <<'!NO!SUBS!'
 # Targets for valgrind testing:
 
-test_prep.valgrind: test_prep perl.valgrind
-
-test.valgrind check.valgrind:  test_prep perl.valgrind.config
-       PERL_VALGRIND=1 VALGRIND='$(VALGRIND)' $(RUN_TESTS) choose
-
-utest.valgrind ucheck.valgrind: test_prep.valgrind perl.valgrind.config
-       PERL_VALGRIND=1 TEST_ARGS=-utf8 $(RUN_TESTS) choose
-
-test_notty.valgrind: test_prep.valgrind perl.valgrind.config
-       PERL_VALGRIND=1 $(RUN_TESTS) no-tty
+test.valgrind check.valgrind:  test_prep
+       @echo "Checking usemymalloc='n' in config.sh..."
+       @grep "^usemymalloc="    config.sh
+       @grep "^usemymalloc='n'" config.sh >/dev/null || exit 1
+       @echo "And of course you have to have valgrind..."
+       $(VALGRIND) $(VG_TEST) || exit 1
+       PERL_VALGRIND=1 VALGRIND='$(VALGRIND)' TESTFILE=harness $(RUN_TESTS) choose
 !NO!SUBS!
        ;;
 esac
 
 $spitshell >>$Makefile <<'!NO!SUBS!'
 
-# Targets for Third Degree testing.
-
-test_prep.third: test_prep perl.third
-       cd t && (rm -f ./perl.third$(EXE_EXT); $(LNS) ../perl.third$(EXE_EXT) perl.third(EXE_EXT))
-
-test.third check.third:        test_prep.third perl.third
-       PERL=./perl.third PERL_3LOG=1 $(RUN_TESTS) choose
-
-utest.third ucheck.third: test_prep.third perl.third
-       PERL=./perl.third PERL_3LOG=1 TEST_ARGS=-utf8 $(RUN_TESTS) choose
-
-test_notty.third: test_prep.third perl.third
-       PERL=./perl.third PERL_3LOG=1 $(RUN_TESTS) choose
-
-# Targets for Deparse testing.
-
-test.deparse:  test_prep
-       TEST_ARGS=-deparse $(RUN_TESTS) choose
-
-test_notty.deparse:    test_prep
-       TEST_ARGS=-deparse $(RUN_TESTS) no-tty
-
-# Targets to run the test suite with -t
-
-test.taintwarn:        test_prep
-       TEST_ARGS=-taintwarn $(RUN_TESTS) choose
-
-minitest.prep:
+# Can't depend on lib/Config.pm because that might be where miniperl
+# is crashing.
+minitest: $(MINIPERL_EXE)
        -@test -f lib/Config.pm || $(MAKE) lib/Config.pm $(unidatafiles)
        @echo " "
        @echo "You may see some irrelevant test failures if you have been unable"
        @echo "to build lib/Config.pm, or the Unicode data files."
        @echo " "
-
-# Can't depend on lib/Config.pm because that might be where miniperl
-# is crashing.
-minitest: $(MINIPERL_EXE) minitest.prep
        - cd t && (rm -f $(PERL_EXE); $(LNS) ../$(MINIPERL_EXE) $(PERL_EXE)) \
                && $(RUN_PERL) TEST base/*.t comp/*.t cmd/*.t run/*.t io/*.t re/*.t opbasic/*.t op/*.t uni/*.t </dev/tty
 
@@ -1576,28 +1531,28 @@ test_porting test-porting: test_prep
 .PHONY: ok okfile oknack okfilenack nok nokfile noknack nokfilenack
 
 ok:    utilities
-       $(RUN_PERL) -Ilib utils/perlbug -ok -s '(UNINSTALLED)'
+       $(RUN_PERL) utils/perlbug -ok -s '(UNINSTALLED)'
 
 okfile:        utilities
-       $(RUN_PERL) -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok
+       $(RUN_PERL) utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok
 
 oknack:        utilities
-       $(RUN_PERL) -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -A
+       $(RUN_PERL) utils/perlbug -ok -s '(UNINSTALLED)' -A
 
 okfilenack:    utilities
-       $(RUN_PERL) -Ilib utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok -A
+       $(RUN_PERL) utils/perlbug -ok -s '(UNINSTALLED)' -F perl.ok -A
 
 nok:   utilities
-       $(RUN_PERL) -Ilib utils/perlbug -nok -s '(UNINSTALLED)'
+       $(RUN_PERL) utils/perlbug -nok -s '(UNINSTALLED)'
 
 nokfile:       utilities
-       $(RUN_PERL) -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -F perl.nok
+       $(RUN_PERL) utils/perlbug -nok -s '(UNINSTALLED)' -F perl.nok
 
 noknack:       utilities
-       $(RUN_PERL) -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -A
+       $(RUN_PERL) utils/perlbug -nok -s '(UNINSTALLED)' -A
 
 nokfilenack:   utilities
-       $(RUN_PERL) -Ilib utils/perlbug -nok -s '(UNINSTALLED)' -F perl.nok -A
+       $(RUN_PERL) utils/perlbug -nok -s '(UNINSTALLED)' -F perl.nok -A
 
 .PHONY: clist hlist
 
@@ -1631,44 +1586,6 @@ define)
     echo "This is an EBCDIC system, checking if any parser files need regenerating." >&2
 case "$osname" in
 os390|posix-bc)
-    if cd x2p
-    then
-        rm -f y.tab.c y.tab.h
-        case "$osname" in
-        posix-bc)
-           # we are using two different yaccs in BS2000 Posix!
-           byacc a2p.y >/dev/null 2>&1
-           ;;
-        *) # e.g. os390
-           yacc  a2p.y >/dev/null 2>&1
-           ;;
-        esac
-        if cmp -s y.tab.c a2p.c
-        then
-            rm -f y.tab.c
-        else
-            echo "a2p.y -> a2p.c" >&2
-            mv -f y.tab.c a2p.c
-            chmod u+w a2p.c
-            sed -e 's/fprintf *( *stderr *,/PerlIO_printf(Perl_debug_log,/g' \
-               -e 's|^static void __YY_YACC_MAIN.*BS2000.*|/*static main deleted*/|' \
-                -e 's/y\.tab/a2p/g' a2p.c >a2p.tmp && mv a2p.tmp a2p.c
-            xxx="$xxx a2p.c"
-        fi
-        # In case somebody yacc -d:ed the a2p.y.
-        if test -f y.tab.h
-        then
-            if cmp -s y.tab.h a2p.h
-            then
-                rm -f y.tab.h
-            else
-                echo "a2p.h -> a2p.h" >&2
-                mv -f y.tab.h a2p.h
-                xxx="$xxx a2p.h"
-            fi
-        fi
-        cd ..
-    fi
     ;;
 *)
     echo "'$osname' is an EBCDIC system I don't know that well." >&4