This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
re-parallelize Win32 build after Unicode::Normalize got XS
[perl5.git] / win32 / makefile.mk
index 12e4cf3..a6f46a3 100644 (file)
@@ -6,7 +6,7 @@
 #      Windows SDK 64-bit compiler and tools
 #
 # This is set up to build a perl.exe that runs off a shared library
-# (perl521.dll).  Also makes individual DLLs for the XS extensions.
+# (perl523.dll).  Also makes individual DLLs for the XS extensions.
 #
 
 ##
@@ -44,7 +44,7 @@ INST_TOP      *= $(INST_DRV)\perl
 # versioned installation can be obtained by setting INST_TOP above to a
 # path that includes an arbitrary version string.
 #
-#INST_VER      *= \5.21.7
+#INST_VER      *= \5.23.5
 
 #
 # Comment this out if you DON'T want your perl installation to have
@@ -87,15 +87,6 @@ USE_ITHREADS *= define
 USE_IMP_SYS    *= define
 
 #
-# Comment out next assign to disable perl's I/O subsystem and use compiler's 
-# stdio for IO - depending on your compiler vendor and run time library you may 
-# then get a number of fails from make test i.e. bugs - complain to them not us ;-). 
-# You will also be unable to take full advantage of perl5.8's support for multiple 
-# encodings and may see lower IO performance. You have been warned.
-#
-USE_PERLIO     *= define
-
-#
 # Comment this out if you don't want to enable large file support for
 # some reason.  Should normally only be changed to maintain compatibility
 # with an older release of perl.
@@ -117,35 +108,42 @@ USE_LARGE_FILES   *= define
 #USE_LONG_DOUBLE *=define
 
 #
+# Uncomment this if you want to disable looking up values from
+# HKEY_CURRENT_USER\Software\Perl and HKEY_LOCAL_MACHINE\Software\Perl in
+# the Registry.
+#
+#USE_NO_REGISTRY *=define
+
+#
 # uncomment exactly one of the following
 #
-# Visual C++ 6.x (aka Visual C++ 98)
+# Visual C++ 6.0 (aka Visual C++ 98)
 #CCTYPE                *= MSVC60
-# Visual C++ .NET 2002/2003 (aka Visual C++ 7.x) (full version)
+# Visual C++ .NET 2002/2003 (aka Visual C++ 7.0/7.1) (full version)
 #CCTYPE                *= MSVC70
-# Visual C++ Toolkit 2003 (aka Visual C++ 7.x) (free command-line tools)
+# Visual C++ Toolkit 2003 (aka Visual C++ 7.1) (free command-line tools)
 #CCTYPE                *= MSVC70FREE
 # Windows Server 2003 SP1 Platform SDK (April 2005)
 #CCTYPE                = SDK2003SP1
-# Visual C++ 2005 (aka Visual C++ 8.x) (full version)
+# Visual C++ 2005 (aka Visual C++ 8.0) (full version)
 #CCTYPE                *= MSVC80
-# Visual C++ 2005 Express Edition (aka Visual C++ 8.x) (free version)
+# Visual C++ 2005 Express Edition (aka Visual C++ 8.0) (free version)
 #CCTYPE                *= MSVC80FREE
-# Visual C++ 2008 (aka Visual C++ 9.x) (full version)
+# Visual C++ 2008 (aka Visual C++ 9.0) (full version)
 #CCTYPE                *= MSVC90
-# Visual C++ 2008 Express Edition (aka Visual C++ 9.x) (free version)
+# Visual C++ 2008 Express Edition (aka Visual C++ 9.0) (free version)
 #CCTYPE                *= MSVC90FREE
-# Visual C++ 2010 (aka Visual C++ 10.x) (full version)
+# Visual C++ 2010 (aka Visual C++ 10.0) (full version)
 #CCTYPE                = MSVC100
-# Visual C++ 2010 Express Edition (aka Visual C++ 10.x) (free version)
+# Visual C++ 2010 Express Edition (aka Visual C++ 10.0) (free version)
 #CCTYPE                = MSVC100FREE
-# Visual C++ 2012 (aka Visual C++ 11.x) (full version)
+# Visual C++ 2012 (aka Visual C++ 11.0) (full version)
 #CCTYPE                = MSVC110
-# Visual C++ 2012 Express Edition (aka Visual C++ 11.x) (free version)
+# Visual C++ 2012 Express Edition (aka Visual C++ 11.0) (free version)
 #CCTYPE                = MSVC110FREE
-# Visual C++ 2013 (aka Visual C++ 12.x) (full version)
+# Visual C++ 2013 (aka Visual C++ 12.0) (full version)
 #CCTYPE                = MSVC120
-# Visual C++ 2013 Express Edition (aka Visual C++ 12.x) (free version)
+# Visual C++ 2013 Express Edition (aka Visual C++ 12.0) (free version)
 #CCTYPE                = MSVC120FREE
 # MinGW or mingw-w64 with gcc-3.4.5 or later
 CCTYPE         *= GCC
@@ -162,10 +160,27 @@ CCTYPE            *= GCC
 #__ICC         *= define
 
 #
-# uncomment next line if you want debug version of perl (big,slow)
+# Uncomment this if you want to build everything in C++ mode
+#
+#USE_CPLUSPLUS *= define
+
+#
+# uncomment next line if you want debug version of perl (big/slow)
 # If not enabled, we automatically try to use maximum optimization
 # with all compilers that are known to have a working optimizer.
 #
+# You can also set CFG = DebugSymbols for a slightly smaller/faster
+# debug build without the special debugging code in perl which is
+# enabled via -DDEBUGGING;
+#
+# or you can set CFG = DebugFull for an even fuller (bigger/slower)
+# debug build using the debug version of the CRT, and enabling VC++
+# debug features such as extra assertions and invalid parameter warnings
+# in perl and CRT code via -D_DEBUG.  (Note that the invalid parameter
+# handler does get triggered from time to time in this configuration,
+# which causes warnings to be printed on STDERR, which in turn causes a
+# few tests to fail.)  (This configuration is only available for VC++ builds.)
+#
 #CFG           *= Debug
 
 #
@@ -197,7 +212,7 @@ CCTYPE              *= GCC
 # set this to additionally provide a statically linked perl-static.exe.
 # Note that dynamic loading will not work with this perl, so you must
 # include required modules statically using the STATIC_EXT or ALL_STATIC
-# variables below. A static library perl521s.lib will also be created.
+# variables below. A static library perl523s.lib will also be created.
 # Ordinary perl.exe is not affected by this option.
 #
 #BUILD_STATIC  *= define
@@ -299,10 +314,10 @@ USE_SITECUST      *= undef
 USE_MULTI      *= undef
 USE_ITHREADS   *= undef
 USE_IMP_SYS    *= undef
-USE_PERLIO     *= undef
 USE_LARGE_FILES        *= undef
 USE_64_BIT_INT *= undef
 USE_LONG_DOUBLE        *= undef
+USE_NO_REGISTRY        *= undef
 
 .IF "$(USE_IMP_SYS)" == "define"
 PERL_MALLOC    = undef
@@ -336,8 +351,16 @@ BUILDOPT   += -DPERL_IMPLICIT_CONTEXT
 BUILDOPT       += -DPERL_IMPLICIT_SYS
 .ENDIF
 
+.IF "$(USE_NO_REGISTRY)" != "undef"
+BUILDOPT       += -DWIN32_NO_REGISTRY
+.ENDIF
+
 PROCESSOR_ARCHITECTURE *= x86
 
+.IF "$(WIN64)" == "undef"
+PROCESSOR_ARCHITECTURE = x86
+.ENDIF
+
 .IF "$(WIN64)" == ""
 # When we are running from a 32bit cmd.exe on AMD64 then
 # PROCESSOR_ARCHITECTURE is set to x86 and PROCESSOR_ARCHITEW6432
@@ -386,15 +409,7 @@ ARCHITECTURE       = ia64
 .IF "$(USE_MULTI)" == "define"
 ARCHNAME       = MSWin32-$(ARCHITECTURE)-multi
 .ELSE
-.IF "$(USE_PERLIO)" == "define"
 ARCHNAME       = MSWin32-$(ARCHITECTURE)-perlio
-.ELSE
-ARCHNAME       = MSWin32-$(ARCHITECTURE)
-.ENDIF
-.ENDIF
-
-.IF "$(USE_PERLIO)" == "define"
-BUILDOPT       += -DUSE_PERLIO
 .ENDIF
 
 .IF "$(USE_ITHREADS)" == "define"
@@ -407,6 +422,10 @@ ARCHNAME   !:= $(ARCHNAME)-64int
 .ENDIF
 .ENDIF
 
+.IF "$(USE_LONG_DOUBLE)" == "define"
+ARCHNAME       !:= $(ARCHNAME)-ld
+.ENDIF
+
 ARCHDIR                = ..\lib\$(ARCHNAME)
 COREDIR                = ..\lib\CORE
 AUTODIR                = ..\lib\auto
@@ -465,13 +484,12 @@ a = .a
 # Options
 #
 
-INCLUDES       = -I.\include -I. -I.. -I$(COREDIR)
+INCLUDES       = -I.\include -I. -I..
 DEFINES                = -DWIN32
 .IF "$(WIN64)" == "define"
 DEFINES                += -DWIN64 -DCONSERVATIVE
 .ENDIF
 LOCDEFS                = -DPERLDLL -DPERL_CORE
-SUBSYS         = console
 CXX_FLAG       = -xc++
 
 # Current releases of MinGW 5.1.4 (as of 11-Aug-2009) will fail to link
@@ -480,38 +498,55 @@ LIBC              =
 #LIBC          = -lmsvcrt
 
 # same libs as MSVC
-LIBFILES       = $(LIBC) \
-                 -lmoldname -lkernel32 -luser32 -lgdi32 \
-                 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 \
-                 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr \
-                 -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
+LIBFILES       = $(LIBC) -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool \
+       -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 \
+       -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
 
 .IF  "$(CFG)" == "Debug"
 OPTIMIZE       = -g -O2 -DDEBUGGING
 LINK_DBG       = -g
+.ELIF  "$(CFG)" == "DebugSymbols"
+OPTIMIZE       = -g -O2
+LINK_DBG       = -g
 .ELSE
 OPTIMIZE       = -s -O2
 LINK_DBG       = -s
 .ENDIF
 
 EXTRACFLAGS    =
+.IF "$(USE_CPLUSPLUS)" == "define"
+EXTRACFLAGS    += $(CXX_FLAG)
+.ENDIF
 CFLAGS         = $(EXTRACFLAGS) $(INCLUDES) $(DEFINES) $(LOCDEFS) $(OPTIMIZE)
 LINK_FLAGS     = $(LINK_DBG) -L"$(INST_COREDIR)" -L"$(CCLIBDIR)"
 OBJOUT_FLAG    = -o
 EXEOUT_FLAG    = -o
 LIBOUT_FLAG    =
+PDBOUT         =
 
 BUILDOPT       += -fno-strict-aliasing -mms-bitfields
+MINIBUILDOPT   += -fno-strict-aliasing
+
+TESTPREPGCC    = test-prep-gcc
 
 .ELSE
 
-# All but the free version of VC++ 7.x can load DLLs on demand.  Makes the test
+# All but the free version of VC++ 7.1 can load DLLs on demand.  Makes the test
 # suite run in about 10% less time.
 .IF "$(CCTYPE)" != "MSVC70FREE"
+# If no registry, advapi32 is only used for Perl_pp_getlogin/getlogin/GetUserNameA
+# which is rare to execute
+.IF "$(USE_NO_REGISTRY)" != "undef"
+DELAYLOAD      = -DELAYLOAD:ws2_32.dll -DELAYLOAD:advapi32.dll delayimp.lib
+MINIDELAYLOAD  =
+.ELSE
 DELAYLOAD      = -DELAYLOAD:ws2_32.dll delayimp.lib
+#miniperl never does any registry lookups
+MINIDELAYLOAD  = -DELAYLOAD:advapi32.dll
+.ENDIF
 .ENDIF
 
-# Visual C++ 2005 and 2008 (VC++ 8.x and 9.x) create manifest files for EXEs and
+# Visual C++ 2005 and 2008 (VC++ 8.0 and 9.0) create manifest files for EXEs and
 # DLLs. These either need copying everywhere with the binaries, or else need
 # embedding in them otherwise MSVCR80.dll or MSVCR90.dll won't be found. For
 # simplicity, embed them if they exist (and delete them afterwards so that they
@@ -544,18 +579,24 @@ RSC               = rc
 # Options
 #
 
-INCLUDES       = -I$(COREDIR) -I.\include -I. -I..
+INCLUDES       = -I.\include -I. -I..
 #PCHFLAGS      = -Fpc:\temp\vcmoduls.pch -YX
 DEFINES                = -DWIN32 -D_CONSOLE -DNO_STRICT
 LOCDEFS                = -DPERLDLL -DPERL_CORE
-SUBSYS         = console
 CXX_FLAG       = -TP -EHsc
 
-LIBC   = msvcrt.lib
+LIBC           = msvcrt.lib
 
 .IF  "$(CFG)" == "Debug"
 OPTIMIZE       = -Od -MD -Zi -DDEBUGGING
 LINK_DBG       = -debug
+.ELIF  "$(CFG)" == "DebugSymbols"
+OPTIMIZE       = -Od -MD -Zi
+LINK_DBG       = -debug
+.ELIF  "$(CFG)" == "DebugFull"
+LIBC           = msvcrtd.lib
+OPTIMIZE       = -Od -MDd -Zi -D_DEBUG -DDEBUGGING
+LINK_DBG       = -debug
 .ELSE
 # -O1 yields smaller code, which turns out to be faster than -O2 on x86 and x64
 OPTIMIZE       = -O1 -MD -Zi -DNDEBUG
@@ -580,7 +621,7 @@ DEFINES             += -DWIN64 -DCONSERVATIVE
 OPTIMIZE       += -fp:precise
 .ENDIF
 
-# For now, silence warnings from VC++ 8.x onwards about "unsafe" CRT functions
+# For now, silence warnings from VC++ 8.0 onwards about "unsafe" CRT functions
 # and POSIX CRT function names being deprecated.
 .IF "$(PREMSVC80)" == "undef"
 DEFINES                += -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
@@ -600,11 +641,10 @@ BUILDOPT  += -D_USE_32BIT_TIME_T
 .ENDIF
 .ENDIF
 
-LIBBASEFILES   = \
-               oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib \
-               comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
-               netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib \
-               version.lib odbc32.lib odbccp32.lib comctl32.lib
+LIBBASEFILES   = oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib \
+       comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
+       netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib \
+       odbc32.lib odbccp32.lib comctl32.lib
 
 # Avoid __intel_new_proc_init link error for libircmt.
 # libmmd is /MD equivelent, other variants exist.
@@ -626,17 +666,22 @@ LIBFILES  = $(LIBBASEFILES) $(LIBC)
 
 EXTRACFLAGS    = -nologo -GF -W3
 .IF "$(__ICC)" == "define"
-EXTRACFLAGS    = $(EXTRACFLAGS) -Qstd=c99
+EXTRACFLAGS    += -Qstd=c99
+.ENDIF
+.IF "$(USE_CPLUSPLUS)" == "define"
+EXTRACFLAGS    += $(CXX_FLAG)
 .ENDIF
 CFLAGS         = $(EXTRACFLAGS) $(INCLUDES) $(DEFINES) $(LOCDEFS) \
                $(PCHFLAGS) $(OPTIMIZE)
 LINK_FLAGS     = -nologo -nodefaultlib $(LINK_DBG) \
                -libpath:"$(INST_COREDIR)" \
                -machine:$(PROCESSOR_ARCHITECTURE)
-LIB_FLAGS      = $(LIB_FLAGS) -nologo
+LIB_FLAGS      += -nologo
 OBJOUT_FLAG    = -Fo
 EXEOUT_FLAG    = -Fe
 LIBOUT_FLAG    = /out:
+PDBOUT         = -Fd$*.pdb
+TESTPREPGCC    =
 
 .ENDIF
 
@@ -649,10 +694,23 @@ RSC_FLAGS = -DINCLUDE_MANIFEST
 .ENDIF
 
 
-# used to allow local linking flags that are not propogated into Config.pm,
-# currently unused
-#   -- BKS, 12-12-1999
-PRIV_LINK_FLAGS        *=
+# For XP support in >= VS 2013 (VC++ 12.0), subsystem is always in Config.pm
+# LINK_FLAGS else subsystem is only needed for EXE building, not XS DLL building
+# Console vs GUI makes no difference for DLLs, so use default for cleaner
+# building cmd lines
+.IF "$(CCTYPE)" == "MSVC120" || "$(CCTYPE)" == "MSVC120FREE" \
+    || "$(CCTYPE)" == "MSVC140" || "$(CCTYPE)" == "MSVC140FREE"
+.IF "$(WIN64)" == "define"
+LINK_FLAGS     += -subsystem:console,"5.02"
+.ELSE
+LINK_FLAGS     += -subsystem:console,"5.01"
+.ENDIF
+PRIV_LINK_FLAGS        =
+
+.ELIF "$(CCTYPE)" != "GCC"
+PRIV_LINK_FLAGS        = -subsystem:console
+.ENDIF
+
 BLINK_FLAGS    = $(PRIV_LINK_FLAGS) $(LINK_FLAGS)
 
 #################### do not edit below this line #######################
@@ -682,7 +740,7 @@ LKPOST              = )
 .SUFFIXES : .c .i $(o) .dll $(a) .exe .rc .res
 
 .c$(o):
-       $(CC) -c $(null,$(<:d) $(NULL) -I$(<:d)) $(CFLAGS_O) $(OBJOUT_FLAG)$@ $<
+       $(CC) -c $(null,$(<:d) $(NULL) -I$(<:d)) $(CFLAGS_O) $(OBJOUT_FLAG)$@ $(PDBOUT) $<
 
 .c.i:
        $(CC) -c $(null,$(<:d) $(NULL) -I$(<:d)) $(CFLAGS_O) -E $< >$@
@@ -695,7 +753,7 @@ $(o).dll:
        $(LINK32) -o $@ $(BLINK_FLAGS) $< $(LIBFILES)
        $(IMPLIB) --input-def $(*B).def --output-lib $(*B).a $@
 .ELSE
-       $(LINK32) -dll -subsystem:windows -implib:$(*B).lib -def:$(*B).def \
+       $(LINK32) -dll -implib:$(*B).lib -def:$(*B).def \
            -out:$@ $(BLINK_FLAGS) $(LIBFILES) $< $(LIBPERL)
        $(EMBED_DLL_MANI)
 .ENDIF
@@ -709,14 +767,19 @@ $(o).dll:
 
 #
 # various targets
+
+#do not put $(MINIPERL) as a dep/prereq in a rule, instead put $(HAVEMINIPERL)
+#$(MINIPERL) is not a buildable target, use "dmake mp" if you want to just build
+#miniperl alone
 MINIPERL       = ..\miniperl.exe
+HAVEMINIPERL   = ..\lib\buildcustomize.pl
 MINIDIR                = .\mini
 PERLEXE                = ..\perl.exe
 WPERLEXE       = ..\wperl.exe
 PERLEXESTATIC  = ..\perl-static.exe
 STATICDIR      = .\static.tmp
 GLOBEXE                = ..\perlglob.exe
-CONFIGPM       = ..\lib\Config.pm ..\lib\Config_heavy.pl
+CONFIGPM       = ..\lib\Config.pm
 GENUUDMAP      = ..\generate_uudmap.exe
 .IF "$(BUILD_STATIC)" == "define" || "$(ALL_STATIC)" == "define"
 PERLSTATIC     = static
@@ -743,7 +806,7 @@ PERLDLL_RES =
 # This used to be $(PERLEXE), but at worst it is the .dll that they depend
 # on and really only the interface - i.e. the .def file used to export symbols
 # from the .dll
-PERLDEP = perldll.def
+PERLDEP = $(PERLIMPLIB)
 
 
 PL2BAT         = bin\pl2bat.pl
@@ -760,6 +823,7 @@ UTILS               =                       \
                ..\utils\perlivp        \
                ..\utils\libnetcfg      \
                ..\utils\enc2xs         \
+               ..\utils\encguess               \
                ..\utils\piconv         \
                ..\utils\corelist       \
                ..\utils\cpan           \
@@ -783,8 +847,8 @@ UTILS               =                       \
 
 CFGSH_TMPL     = config.gc
 CFGH_TMPL      = config_H.gc
-PERLIMPLIB     = ..\libperl521$(a)
-PERLSTATICLIB  = ..\libperl521s$(a)
+PERLIMPLIB     = ..\libperl523$(a)
+PERLSTATICLIB  = ..\libperl523s$(a)
 INT64          = long long
 
 .ELSE
@@ -797,51 +861,67 @@ INT64             = __int64
 
 # makedef.pl must be updated if this changes, and this should normally
 # only change when there is an incompatible revision of the public API.
-PERLIMPLIB     *= ..\perl521$(a)
-PERLSTATICLIB  *= ..\perl521s$(a)
-PERLDLL                = ..\perl521.dll
+PERLIMPLIB     *= ..\perl523$(a)
+PERLEXPLIB     *= ..\perl523.exp
+PERLSTATICLIB  *= ..\perl523s$(a)
+PERLDLL                = ..\perl523.dll
+
+#EUMM on Win32 isn't ready for parallel make, so only allow this file to be parallel
+#$(MAKE) will contain the -P that this makefile was called with, which is bad for
+#make_ext.pl since upto jobs*jobs processes will run instead of jobs
+#also any recipie containing $(MAKE) is special cased by dmake to execute recipes
+#containing $(MAKE) when "dmake -n" is executed, which causes recursive calls
+#to dmake, which means "dmake -n" is then broken as a diagnostic tool since
+#"dmake -n" will invoke all the make_ext.pl scripts build things instead of
+#showing what to build since $(MAKE) is an arg to make_ext.pl, not an invocation
+#of the dmake process
+PLMAKE         = dmake
 
 XCOPY          = xcopy /f /r /i /d /y
 RCOPY          = xcopy /f /r /i /e /d /y
 NOOP           = @rem
 
+#first ones are arrange in compile time order for faster parallel building
+#see #123867 for details
 MICROCORE_SRC  =               \
+               ..\toke.c       \
+               ..\regcomp.c    \
+               ..\regexec.c    \
+               ..\op.c         \
+               ..\sv.c         \
+               ..\pp.c         \
+               ..\pp_ctl.c     \
+               ..\pp_sys.c     \
+               ..\pp_pack.c    \
+               ..\pp_hot.c     \
+               ..\gv.c         \
+               ..\perl.c       \
+               ..\utf8.c       \
+               ..\dump.c       \
+               ..\hv.c         \
                ..\av.c         \
                ..\caretx.c     \
                ..\deb.c        \
                ..\doio.c       \
                ..\doop.c       \
-               ..\dump.c       \
+               ..\dquote.c     \
                ..\globals.c    \
-               ..\gv.c         \
-               ..\mro.c        \
-               ..\hv.c         \
+               ..\mro_core.c   \
                ..\locale.c     \
                ..\keywords.c   \
                ..\mathoms.c    \
                ..\mg.c         \
                ..\numeric.c    \
-               ..\op.c         \
                ..\pad.c        \
-               ..\perl.c       \
                ..\perlapi.c    \
                ..\perly.c      \
-               ..\pp.c         \
-               ..\pp_ctl.c     \
-               ..\pp_hot.c     \
-               ..\pp_pack.c    \
                ..\pp_sort.c    \
-               ..\pp_sys.c     \
                ..\reentr.c     \
-               ..\regcomp.c    \
-               ..\regexec.c    \
                ..\run.c        \
                ..\scope.c      \
-               ..\sv.c         \
                ..\taint.c      \
-               ..\toke.c       \
+               ..\time64.c     \
                ..\universal.c  \
-               ..\utf8.c       \
                ..\util.c
 
 EXTRACORE_SRC  += perllib.c
@@ -854,16 +934,11 @@ EXTRACORE_SRC     += ..\perlio.c
 
 WIN32_SRC      =               \
                .\win32.c       \
+               .\win32io.c     \
                .\win32sck.c    \
                .\win32thread.c \
                .\fcrypt.c
 
-# We need this for miniperl build unless we override canned 
-# config.h #define building mini\*
-#.IF "$(USE_PERLIO)" == "define"
-WIN32_SRC      += .\win32io.c
-#.ENDIF
-
 CORE_NOCFG_H   =               \
                ..\av.h         \
                ..\cop.h        \
@@ -911,6 +986,10 @@ UUDMAP_H   = ..\uudmap.h
 BITCOUNT_H     = ..\bitcount.h
 MG_DATA_H      = ..\mg_data.h
 GENERATED_HEADERS = $(UUDMAP_H) $(BITCOUNT_H) $(MG_DATA_H)
+#a stub ppport.h must be generated so building XS modules, .c->.obj wise, will
+#work, so this target also represents creating the COREDIR and filling it
+HAVE_COREDIR   = $(COREDIR)\ppport.h
+
 
 MICROCORE_OBJ  = $(MICROCORE_SRC:db:+$(o))
 CORE_OBJ       = $(MICROCORE_OBJ) $(EXTRACORE_SRC:db:+$(o))
@@ -919,7 +998,6 @@ MINICORE_OBJ        = $(MINIDIR)\{$(MICROCORE_OBJ:f) miniperlmain$(o) perlio$(o)}
 MINIWIN32_OBJ  = $(MINIDIR)\{$(WIN32_OBJ:f)}
 MINI_OBJ       = $(MINICORE_OBJ) $(MINIWIN32_OBJ)
 DLL_OBJ                = $(DYNALOADER)
-GENUUDMAP_OBJ  = $(GENUUDMAP:db:+$(o))
 
 PERLDLL_OBJ    = $(CORE_OBJ)
 PERLEXE_OBJ    = perlmain$(o)
@@ -956,6 +1034,7 @@ CFG_VARS   =                                       \
                cc=$(CC)                        ~       \
                ld=$(LINK32)                    ~       \
                ccflags=$(EXTRACFLAGS) $(OPTIMIZE) $(DEFINES) $(BUILDOPT)       ~       \
+               usecplusplus=$(USE_CPLUSPLUS)   ~       \
                cf_email=$(EMAIL)               ~       \
                d_mymalloc=$(PERL_MALLOC)       ~       \
                libs=$(LIBFILES:f)              ~       \
@@ -963,7 +1042,7 @@ CFG_VARS   =                                       \
                libperl=$(PERLIMPLIB:f)         ~       \
                libpth=$(CCLIBDIR);$(EXTRALIBDIRS)      ~       \
                libc=$(LIBC)                    ~       \
-               make=dmake                      ~       \
+               make=$(PLMAKE)                  ~       \
                _o=$(o)                         ~       \
                obj_ext=$(o)                    ~       \
                _a=$(a)                         ~       \
@@ -972,7 +1051,6 @@ CFG_VARS   =                                       \
                usethreads=$(USE_ITHREADS)      ~       \
                useithreads=$(USE_ITHREADS)     ~       \
                usemultiplicity=$(USE_MULTI)    ~       \
-               useperlio=$(USE_PERLIO)         ~       \
                use64bitint=$(USE_64_BIT_INT)   ~       \
                uselongdouble=$(USE_LONG_DOUBLE)        ~       \
                uselargefiles=$(USE_LARGE_FILES)        ~       \
@@ -986,19 +1064,13 @@ CFG_VARS =                                       \
 # Top targets
 #
 
-all : CHECKDMAKE .\config.h ..\git_version.h $(GLOBEXE) $(MINIPERL)    \
-       $(CONFIGPM) $(UNIDATAFILES) MakePPPort                          \
-       $(PERLEXE) Extensions Extensions_nonxs $(PERLSTATIC)
-
-regnodes : ..\regnodes.h
+all : CHECKDMAKE  rebasePE Extensions_nonxs $(PERLSTATIC)
 
 ..\regcomp$(o) : ..\regnodes.h ..\regcharclass.h
 
 ..\regexec$(o) : ..\regnodes.h ..\regcharclass.h
 
-reonly : regnodes .\config.h ..\git_version.h $(GLOBEXE) $(MINIPERL)   \
-       $(CONFIGPM) $(UNIDATAFILES) $(PERLEXE)                          \
-       Extensions_reonly
+reonly : ..\regnodes.h $(UNIDATAFILES) Extensions_reonly
 
 static: $(PERLEXESTATIC)
 
@@ -1013,192 +1085,30 @@ CHECKDMAKE :
        @exit 1
 .ENDIF
 
-$(GLOBEXE) : perlglob$(o)
+$(GLOBEXE) : perlglob.c
 .IF "$(CCTYPE)" == "GCC"
-       $(LINK32) $(BLINK_FLAGS) -mconsole -o $@ perlglob$(o) $(LIBFILES)
+       $(LINK32) $(OPTIMIZE) $(BLINK_FLAGS) -mconsole -o $@ perlglob.c $(LIBFILES)
 .ELSE
-       $(LINK32) $(BLINK_FLAGS) $(LIBFILES) -out:$@ -subsystem:$(SUBSYS) \
-           perlglob$(o) setargv$(o)
-       $(EMBED_EXE_MANI)
+       $(CC) $(OPTIMIZE) -Fe$@ perlglob.c -link $(BLINK_FLAGS) setargv$(o) \
+       $(LIBFILES) && $(EMBED_EXE_MANI)
 .ENDIF
 
-perlglob$(o)  : perlglob.c
-
 config.w32 : $(CFGSH_TMPL)
        copy $(CFGSH_TMPL) config.w32
 
-#
-# Copy the template config.h and set configurables at the end of it
-# as per the options chosen and compiler used.
-# Note: This config.h is only used to build miniperl.exe anyway, but
-# it's as well to have its options correct to be sure that it builds
-# and so that it's "-V" options are correct for use by makedef.pl. The
-# real config.h used to build perl.exe is generated from the top-level
-# config_h.SH by config_h.PL (run by miniperl.exe).
-#
-.\config.h : $(CFGH_TMPL) $(CORE_NOCFG_H)
-       -del /f config.h
-       copy $(CFGH_TMPL) config.h
-       @echo.>>$@
-       @echo #ifndef _config_h_footer_>>$@
-       @echo #define _config_h_footer_>>$@
-       @echo #undef Off_t>>$@
-       @echo #undef LSEEKSIZE>>$@
-       @echo #undef Off_t_size>>$@
-       @echo #undef PTRSIZE>>$@
-       @echo #undef SSize_t>>$@
-       @echo #undef HAS_ATOLL>>$@
-       @echo #undef HAS_STRTOLL>>$@
-       @echo #undef HAS_STRTOULL>>$@
-       @echo #undef Size_t_size>>$@
-       @echo #undef IVTYPE>>$@
-       @echo #undef UVTYPE>>$@
-       @echo #undef IVSIZE>>$@
-       @echo #undef UVSIZE>>$@
-       @echo #undef NV_PRESERVES_UV>>$@
-       @echo #undef NV_PRESERVES_UV_BITS>>$@
-       @echo #undef IVdf>>$@
-       @echo #undef UVuf>>$@
-       @echo #undef UVof>>$@
-       @echo #undef UVxf>>$@
-       @echo #undef UVXf>>$@
-       @echo #undef USE_64_BIT_INT>>$@
-       @echo #undef Gconvert>>$@
-       @echo #undef HAS_FREXPL>>$@
-       @echo #undef HAS_ISNANL>>$@
-       @echo #undef HAS_MODFL>>$@
-       @echo #undef HAS_MODFL_PROTO>>$@
-       @echo #undef HAS_SQRTL>>$@
-       @echo #undef HAS_STRTOLD>>$@
-       @echo #undef PERL_PRIfldbl>>$@
-       @echo #undef PERL_PRIgldbl>>$@
-       @echo #undef PERL_PRIeldbl>>$@
-       @echo #undef PERL_SCNfldbl>>$@
-       @echo #undef NVTYPE>>$@
-       @echo #undef NVSIZE>>$@
-       @echo #undef LONG_DOUBLESIZE>>$@
-       @echo #undef NV_OVERFLOWS_INTEGERS_AT>>$@
-       @echo #undef NVef>>$@
-       @echo #undef NVff>>$@
-       @echo #undef NVgf>>$@
-       @echo #undef USE_LONG_DOUBLE>>$@
-.IF "$(USE_LARGE_FILES)"=="define"
-       @echo #define Off_t $(INT64)>>$@
-       @echo #define LSEEKSIZE ^8>>$@
-       @echo #define Off_t_size ^8>>$@
-.ELSE
-       @echo #define Off_t long>>$@
-       @echo #define LSEEKSIZE ^4>>$@
-       @echo #define Off_t_size ^4>>$@
-.ENDIF
-.IF "$(WIN64)"=="define"
-       @echo #define PTRSIZE ^8>>$@
-       @echo #define SSize_t $(INT64)>>$@
-       @echo #define HAS_ATOLL>>$@
-       @echo #define HAS_STRTOLL>>$@
-       @echo #define HAS_STRTOULL>>$@
-       @echo #define Size_t_size ^8>>$@
-.ELSE
-       @echo #define PTRSIZE ^4>>$@
-       @echo #define SSize_t int>>$@
-       @echo #undef HAS_ATOLL>>$@
-       @echo #undef HAS_STRTOLL>>$@
-       @echo #undef HAS_STRTOULL>>$@
-       @echo #define Size_t_size ^4>>$@
-.ENDIF
-.IF "$(USE_64_BIT_INT)"=="define"
-       @echo #define IVTYPE $(INT64)>>$@
-       @echo #define UVTYPE unsigned $(INT64)>>$@
-       @echo #define IVSIZE ^8>>$@
-       @echo #define UVSIZE ^8>>$@
-.IF "$(USE_LONG_DOUBLE)"=="define"
-       @echo #define NV_PRESERVES_UV>>$@
-       @echo #define NV_PRESERVES_UV_BITS 64>>$@
-.ELSE
-       @echo #undef NV_PRESERVES_UV>>$@
-       @echo #define NV_PRESERVES_UV_BITS 53>>$@
-.ENDIF
-       @echo #define IVdf "I64d">>$@
-       @echo #define UVuf "I64u">>$@
-       @echo #define UVof "I64o">>$@
-       @echo #define UVxf "I64x">>$@
-       @echo #define UVXf "I64X">>$@
-       @echo #define USE_64_BIT_INT>>$@
-.ELSE
-       @echo #define IVTYPE long>>$@
-       @echo #define UVTYPE unsigned long>>$@
-       @echo #define IVSIZE ^4>>$@
-       @echo #define UVSIZE ^4>>$@
-       @echo #define NV_PRESERVES_UV>>$@
-       @echo #define NV_PRESERVES_UV_BITS 32>>$@
-       @echo #define IVdf "ld">>$@
-       @echo #define UVuf "lu">>$@
-       @echo #define UVof "lo">>$@
-       @echo #define UVxf "lx">>$@
-       @echo #define UVXf "lX">>$@
-       @echo #undef USE_64_BIT_INT>>$@
-.ENDIF
-.IF "$(USE_LONG_DOUBLE)"=="define"
-       @echo #define Gconvert(x,n,t,b) sprintf((b),"%.*""Lg",(n),(x))>>$@
-       @echo #define HAS_FREXPL>>$@
-       @echo #define HAS_ISNANL>>$@
-       @echo #define HAS_MODFL>>$@
-       @echo #define HAS_MODFL_PROTO>>$@
-       @echo #define HAS_SQRTL>>$@
-       @echo #define HAS_STRTOLD>>$@
-       @echo #define PERL_PRIfldbl "Lf">>$@
-       @echo #define PERL_PRIgldbl "Lg">>$@
-       @echo #define PERL_PRIeldbl "Le">>$@
-       @echo #define PERL_SCNfldbl "Lf">>$@
-       @echo #define NVTYPE long double>>$@
-.IF "$(WIN64)"=="define"
-       @echo #define NVSIZE ^16>>$@
-       @echo #define LONG_DOUBLESIZE ^16>>$@
-.ELSE
-       @echo #define NVSIZE ^12>>$@
-       @echo #define LONG_DOUBLESIZE ^12>>$@
-.ENDIF
-       @echo #define NV_OVERFLOWS_INTEGERS_AT 256.0*256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0>>$@
-       @echo #define NVef "Le">>$@
-       @echo #define NVff "Lf">>$@
-       @echo #define NVgf "Lg">>$@
-       @echo #define USE_LONG_DOUBLE>>$@
-.ELSE
-       @echo #define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))>>$@
-       @echo #undef HAS_FREXPL>>$@
-       @echo #undef HAS_ISNANL>>$@
-       @echo #undef HAS_MODFL>>$@
-       @echo #undef HAS_MODFL_PROTO>>$@
-       @echo #undef HAS_SQRTL>>$@
-       @echo #undef HAS_STRTOLD>>$@
-       @echo #undef PERL_PRIfldbl>>$@
-       @echo #undef PERL_PRIgldbl>>$@
-       @echo #undef PERL_PRIeldbl>>$@
-       @echo #undef PERL_SCNfldbl>>$@
-       @echo #define NVTYPE double>>$@
-       @echo #define NVSIZE ^8>>$@
-       @echo #define LONG_DOUBLESIZE ^8>>$@
-       @echo #define NV_OVERFLOWS_INTEGERS_AT 256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0>>$@
-       @echo #define NVef "e">>$@
-       @echo #define NVff "f">>$@
-       @echo #define NVgf "g">>$@
-       @echo #undef USE_LONG_DOUBLE>>$@
-.ENDIF
-       @echo #endif>>$@
-
-..\git_version.h : $(MINIPERL) ..\make_patchnum.pl
+..\git_version.h : $(HAVEMINIPERL) ..\make_patchnum.pl
        cd .. && miniperl -Ilib make_patchnum.pl
 
 # make sure that we recompile perl.c if the git version changes
 ..\perl$(o) : ..\git_version.h
 
-..\config.sh : config.w32 $(MINIPERL) config_sh.PL FindExt.pm
+..\config.sh : config.w32 $(HAVEMINIPERL) config_sh.PL FindExt.pm
        $(MINIPERL) -I..\lib config_sh.PL --cfgsh-option-file \
            $(mktmp $(CFG_VARS)) config.w32 > ..\config.sh
 
 # This target is for when changes to the main config.sh happen.
 # Edit config.gc, then make perl using GCC in a minimal configuration (i.e.
-# with MULTI, ITHREADS, IMP_SYS, LARGE_FILES and PERLIO off), then make
+# with MULTI, ITHREADS, IMP_SYS and LARGE_FILES off), then make
 # this target to regenerate config_H.gc.
 regen_config_h:
        $(MINIPERL) -I..\lib config_sh.PL --cfgsh-option-file $(mktmp $(CFG_VARS)) \
@@ -1208,54 +1118,221 @@ regen_config_h:
        -$(MINIPERL) -I..\lib config_h.PL "ARCHPREFIX=$(ARCHPREFIX)"
        rename config.h $(CFGH_TMPL)
 
-$(CONFIGPM) : $(MINIPERL) ..\config.sh config_h.PL
+$(CONFIGPM): ..\config.sh config_h.PL
        $(MINIPERL) -I..\lib ..\configpm --chdir=..
-       if exist lib\* $(RCOPY) lib\*.* ..\lib\$(NULL)
-       $(XCOPY) ..\*.h $(COREDIR)\*.*
-       $(XCOPY) *.h $(COREDIR)\*.*
-       $(RCOPY) include $(COREDIR)\*.*
-       $(MINIPERL) -I..\lib config_h.PL "ARCHPREFIX=$(ARCHPREFIX)" \
-           || $(MAKE) $(MAKEMACROS) $(CONFIGPM) $(MAKEFILE)
+       $(XCOPY) config.h $(COREDIR)\*.*
+       -$(MINIPERL) -I..\lib config_h.PL "ARCHPREFIX=$(ARCHPREFIX)"
 
-# See the comment in Makefile.SH explaining this seemingly cranky ordering
-$(MINIPERL) : ..\lib\buildcustomize.pl
+.\config.h : $(CONFIGPM)
 
-..\lib\buildcustomize.pl : $(MINIDIR) $(MINI_OBJ) $(CRTIPMLIBS) ..\write_buildcustomize.pl
+# See the comment in Makefile.SH explaining this seemingly cranky ordering
+..\lib\buildcustomize.pl : $(MINI_OBJ) ..\write_buildcustomize.pl
 .IF "$(CCTYPE)" == "GCC"
        $(LINK32) -v -mconsole -o $(MINIPERL) $(BLINK_FLAGS) \
            $(mktmp $(LKPRE) $(MINI_OBJ) $(LIBFILES) $(LKPOST))
 .ELSE
-       $(LINK32) -subsystem:console -out:$(MINIPERL) $(BLINK_FLAGS) \
-           @$(mktmp $(DELAYLOAD) $(LIBFILES) $(MINI_OBJ))
+       $(LINK32) -out:$(MINIPERL) $(BLINK_FLAGS) \
+           @$(mktmp $(DELAYLOAD) $(MINIDELAYLOAD) $(LIBFILES) $(MINI_OBJ))
        $(EMBED_EXE_MANI:s/$@/$(MINIPERL)/)
 .ENDIF
        $(MINIPERL) -I..\lib -f ..\write_buildcustomize.pl ..
 
-$(MINIDIR) :
+#convinence target, get a working miniperl
+mp : $(CONFIGPM)
+
+$(MINIDIR)\.exists : $(CFGH_TMPL)
        if not exist "$(MINIDIR)" mkdir "$(MINIDIR)"
+#
+# Copy the template config.h and set configurables at the end of it
+# as per the options chosen and compiler used.
+# Note: This config.h is only used to build miniperl.exe anyway, but
+# it's as well to have its options correct to be sure that it builds
+# and so that it's "-V" options are correct for use by makedef.pl. The
+# real config.h used to build perl.exe is generated from the top-level
+# config_h.SH by config_h.PL (run by miniperl.exe).
+#
+# MINIDIR generates config.h so miniperl.exe is not rebuilt when the 2nd
+# config.h is generated in CONFIGPM target, see also the comments for $(MINI_OBJ).
+       -if exist config.h del /f config.h
+       copy $(CFGH_TMPL) config.h
+       @(echo.&& \
+       echo #ifndef _config_h_footer_&& \
+       echo #define _config_h_footer_&& \
+       echo #undef Off_t&& \
+       echo #undef LSEEKSIZE&& \
+       echo #undef Off_t_size&& \
+       echo #undef PTRSIZE&& \
+       echo #undef SSize_t&& \
+       echo #undef HAS_ATOLL&& \
+       echo #undef HAS_STRTOLL&& \
+       echo #undef HAS_STRTOULL&& \
+       echo #undef Size_t_size&& \
+       echo #undef IVTYPE&& \
+       echo #undef UVTYPE&& \
+       echo #undef IVSIZE&& \
+       echo #undef UVSIZE&& \
+       echo #undef NV_PRESERVES_UV&& \
+       echo #undef NV_PRESERVES_UV_BITS&& \
+       echo #undef IVdf&& \
+       echo #undef UVuf&& \
+       echo #undef UVof&& \
+       echo #undef UVxf&& \
+       echo #undef UVXf&& \
+       echo #undef USE_64_BIT_INT&& \
+       echo #undef Gconvert&& \
+       echo #undef HAS_FREXPL&& \
+       echo #undef HAS_ISNANL&& \
+       echo #undef HAS_MODFL&& \
+       echo #undef HAS_MODFL_PROTO&& \
+       echo #undef HAS_SQRTL&& \
+       echo #undef HAS_STRTOLD&& \
+       echo #undef PERL_PRIfldbl&& \
+       echo #undef PERL_PRIgldbl&& \
+       echo #undef PERL_PRIeldbl&& \
+       echo #undef PERL_SCNfldbl&& \
+       echo #undef NVTYPE&& \
+       echo #undef NVSIZE&& \
+       echo #undef LONG_DOUBLESIZE&& \
+       echo #undef NV_OVERFLOWS_INTEGERS_AT&& \
+       echo #undef NVef&& \
+       echo #undef NVff&& \
+       echo #undef NVgf&& \
+       echo #undef USE_LONG_DOUBLE&& \
+       echo #undef USE_CPLUSPLUS)>> config.h
+.IF "$(USE_LARGE_FILES)"=="define"
+       @(echo #define Off_t $(INT64)&& \
+       echo #define LSEEKSIZE ^8&& \
+       echo #define Off_t_size ^8)>> config.h
+.ELSE
+       @(echo #define Off_t long&& \
+       echo #define LSEEKSIZE ^4&& \
+       echo #define Off_t_size ^4)>> config.h
+.ENDIF
+.IF "$(WIN64)"=="define"
+       @(echo #define PTRSIZE ^8&& \
+       echo #define SSize_t $(INT64)&& \
+       echo #define HAS_ATOLL&& \
+       echo #define HAS_STRTOLL&& \
+       echo #define HAS_STRTOULL&& \
+       echo #define Size_t_size ^8)>> config.h
+.ELSE
+       @(echo #define PTRSIZE ^4&& \
+       echo #define SSize_t int&& \
+       echo #undef HAS_ATOLL&& \
+       echo #undef HAS_STRTOLL&& \
+       echo #undef HAS_STRTOULL&& \
+       echo #define Size_t_size ^4)>> config.h
+.ENDIF
+.IF "$(USE_64_BIT_INT)"=="define"
+       @(echo #define IVTYPE $(INT64)&& \
+       echo #define UVTYPE unsigned $(INT64)&& \
+       echo #define IVSIZE ^8&& \
+       echo #define UVSIZE ^8)>> config.h
+.IF "$(USE_LONG_DOUBLE)"=="define"
+       @(echo #define NV_PRESERVES_UV&& \
+       echo #define NV_PRESERVES_UV_BITS 64)>> config.h
+.ELSE
+       @(echo #undef NV_PRESERVES_UV&& \
+       echo #define NV_PRESERVES_UV_BITS 53)>> config.h
+.ENDIF
+       @(echo #define IVdf "I64d"&& \
+       echo #define UVuf "I64u"&& \
+       echo #define UVof "I64o"&& \
+       echo #define UVxf "I64x"&& \
+       echo #define UVXf "I64X"&& \
+       echo #define USE_64_BIT_INT)>> config.h
+.ELSE
+       @(echo #define IVTYPE long&& \
+       echo #define UVTYPE unsigned long&& \
+       echo #define IVSIZE ^4&& \
+       echo #define UVSIZE ^4&& \
+       echo #define NV_PRESERVES_UV&& \
+       echo #define NV_PRESERVES_UV_BITS 32&& \
+       echo #define IVdf "ld"&& \
+       echo #define UVuf "lu"&& \
+       echo #define UVof "lo"&& \
+       echo #define UVxf "lx"&& \
+       echo #define UVXf "lX"&& \
+       echo #undef USE_64_BIT_INT)>> config.h
+.ENDIF
+.IF "$(USE_LONG_DOUBLE)"=="define"
+       @(echo #define Gconvert^(x,n,t,b^) sprintf^(^(b^),"%.*""Lg",^(n^),^(x^)^)&& \
+       echo #define HAS_FREXPL&& \
+       echo #define HAS_ISNANL&& \
+       echo #define HAS_MODFL&& \
+       echo #define HAS_MODFL_PROTO&& \
+       echo #define HAS_SQRTL&& \
+       echo #define HAS_STRTOLD&& \
+       echo #define PERL_PRIfldbl "Lf"&& \
+       echo #define PERL_PRIgldbl "Lg"&& \
+       echo #define PERL_PRIeldbl "Le"&& \
+       echo #define PERL_SCNfldbl "Lf"&& \
+       echo #define NVTYPE long double)>> config.h
+.IF "$(WIN64)"=="define"
+       @(echo #define NVSIZE ^16&& \
+       echo #define LONG_DOUBLESIZE ^16)>> config.h
+.ELSE
+       @(echo #define NVSIZE ^12&& \
+       echo #define LONG_DOUBLESIZE ^12)>> config.h
+.ENDIF
+       @(echo #define NV_OVERFLOWS_INTEGERS_AT 256.0*256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0&& \
+       echo #define NVef "Le"&& \
+       echo #define NVff "Lf"&& \
+       echo #define NVgf "Lg"&& \
+       echo #define USE_LONG_DOUBLE)>> config.h
+.ELSE
+       @(echo #define Gconvert^(x,n,t,b^) sprintf^(^(b^),"%.*g",^(n^),^(x^)^)&& \
+       echo #undef HAS_FREXPL&& \
+       echo #undef HAS_ISNANL&& \
+       echo #undef HAS_MODFL&& \
+       echo #undef HAS_MODFL_PROTO&& \
+       echo #undef HAS_SQRTL&& \
+       echo #undef HAS_STRTOLD&& \
+       echo #undef PERL_PRIfldbl&& \
+       echo #undef PERL_PRIgldbl&& \
+       echo #undef PERL_PRIeldbl&& \
+       echo #undef PERL_SCNfldbl&& \
+       echo #define NVTYPE double&& \
+       echo #define NVSIZE ^8&& \
+       echo #define LONG_DOUBLESIZE ^8&& \
+       echo #define NV_OVERFLOWS_INTEGERS_AT 256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0&& \
+       echo #define NVef "e"&& \
+       echo #define NVff "f"&& \
+       echo #define NVgf "g"&& \
+       echo #undef USE_LONG_DOUBLE)>> config.h
+.ENDIF
+.IF "$(USE_CPLUSPLUS)"=="define"
+       @(echo #define USE_CPLUSPLUS&& \
+       echo #endif)>> config.h
+.ELSE
+       @(echo #undef USE_CPLUSPLUS&& \
+       echo #endif)>> config.h
+.ENDIF
+#separate line since this is sentinal that this target is done
+       rem. > $(MINIDIR)\.exists
 
 $(MINICORE_OBJ) : $(CORE_NOCFG_H)
-       $(CC) -c $(CFLAGS) $(MINIBUILDOPT) -DPERL_EXTERNAL_GLOB -DPERL_IS_MINIPERL $(OBJOUT_FLAG)$@ ..\$(*B).c
+       $(CC) -c $(CFLAGS) $(MINIBUILDOPT) -DPERL_EXTERNAL_GLOB -DPERL_IS_MINIPERL $(OBJOUT_FLAG)$@ $(PDBOUT) ..\$(*B).c
 
 $(MINIWIN32_OBJ) : $(CORE_NOCFG_H)
-       $(CC) -c $(CFLAGS) $(MINIBUILDOPT) -DPERL_IS_MINIPERL $(OBJOUT_FLAG)$@ $(*B).c
+       $(CC) -c $(CFLAGS) $(MINIBUILDOPT) -DPERL_IS_MINIPERL $(OBJOUT_FLAG)$@ $(PDBOUT) $(*B).c
 
 # -DPERL_IMPLICIT_SYS needs C++ for perllib.c
 # rules wrapped in .IFs break Win9X build (we end up with unbalanced []s unless
 # unless the .IF is true), so instead we use a .ELSE with the default.
 # This is the only file that depends on perlhost.h, vmem.h, and vdir.h
 
-perllib$(o)    : perllib.c .\perlhost.h .\vdir.h .\vmem.h
+perllib$(o)    : perllib.c perllibst.h .\perlhost.h .\vdir.h .\vmem.h
 .IF "$(USE_IMP_SYS)" == "define"
-       $(CC) -c -I. $(CFLAGS_O) $(CXX_FLAG) $(OBJOUT_FLAG)$@ perllib.c
+       $(CC) -c -I. $(CFLAGS_O) $(CXX_FLAG) $(OBJOUT_FLAG)$@ $(PDBOUT) perllib.c
 .ELSE
-       $(CC) -c -I. $(CFLAGS_O) $(OBJOUT_FLAG)$@ perllib.c
+       $(CC) -c -I. $(CFLAGS_O) $(OBJOUT_FLAG)$@ $(PDBOUT) perllib.c
 .ENDIF
 
 # 1. we don't want to rebuild miniperl.exe when config.h changes
 # 2. we don't want to rebuild miniperl.exe with non-default config.h
 # 3. we can't have miniperl.exe depend on git_version.h, as miniperl creates it
-$(MINI_OBJ)    : $(CORE_NOCFG_H)
+$(MINI_OBJ)    : $(MINIDIR)\.exists $(CORE_NOCFG_H)
 
 $(WIN32_OBJ)   : $(CORE_H)
 
@@ -1263,12 +1340,26 @@ $(CORE_OBJ)     : $(CORE_H)
 
 $(DLL_OBJ)     : $(CORE_H)
 
-perldll.def : $(MINIPERL) $(CONFIGPM) ..\embed.fnc ..\makedef.pl create_perllibst_h.pl
+
+perllibst.h : $(HAVEMINIPERL) $(CONFIGPM) create_perllibst_h.pl
        $(MINIPERL) -I..\lib create_perllibst_h.pl
+
+perldll.def : $(HAVEMINIPERL) $(CONFIGPM) ..\embed.fnc ..\makedef.pl
        $(MINIPERL) -I..\lib -w ..\makedef.pl PLATFORM=win32 $(OPTIMIZE) $(DEFINES) \
        $(BUILDOPT) CCTYPE=$(CCTYPE) TARG_DIR=..\ > perldll.def
 
-$(PERLDLL): perldll.def $(PERLDLL_OBJ) $(PERLDLL_RES) Extensions_static
+$(PERLIMPLIB) : perldll.def
+.IF "$(CCTYPE)" == "GCC"
+       $(IMPLIB) -k -d perldll.def -l $(PERLIMPLIB)
+.ELSE #VC family
+       lib -def:perldll.def -machine:$(ARCHITECTURE) /OUT:$(PERLIMPLIB)
+.ENDIF
+       $(XCOPY) $(PERLIMPLIB) $(COREDIR)
+
+#PERLEXPLIB is built in PERLIMPLIB
+$(PERLEXPLIB): $(PERLIMPLIB)
+
+$(PERLDLL): $(PERLEXPLIB) $(PERLDLL_OBJ) $(PERLDLL_RES) Extensions_static
 .IF "$(CCTYPE)" == "GCC"
        $(LINK32) -mdll -o $@ -Wl,--base-file -Wl,perl.base $(BLINK_FLAGS) \
            $(mktmp $(LKPRE) $(PERLDLL_OBJ) \
@@ -1284,13 +1375,12 @@ $(PERLDLL): perldll.def $(PERLDLL_OBJ) $(PERLDLL_RES) Extensions_static
                $(shell @type Extensions_static) \
                $(LIBFILES) perl.exp $(LKPOST))
 .ELSE
-       $(LINK32) -dll -def:perldll.def -out:$@ $(BLINK_FLAGS) \
+       $(LINK32) -dll -out:$@ $(BLINK_FLAGS) \
            @Extensions_static \
            @$(mktmp -base:0x28000000 $(DELAYLOAD) $(LIBFILES) \
-               $(PERLDLL_RES) $(PERLDLL_OBJ))
+               $(PERLDLL_RES) $(PERLDLL_OBJ) $(PERLEXPLIB))
        $(EMBED_DLL_MANI)
 .ENDIF
-       $(XCOPY) $(PERLIMPLIB) $(COREDIR)
 
 $(PERLSTATICLIB): $(PERLDLL_OBJ) Extensions_static
 .IF "$(CCTYPE)" == "GCC"
@@ -1305,47 +1395,47 @@ $(PERLSTATICLIB): $(PERLDLL_OBJ) Extensions_static
        $(LIB32) $(LIB_FLAGS) -out:$@ @Extensions_static \
            @$(mktmp $(PERLDLL_OBJ))
 .ENDIF
-       $(XCOPY) $(PERLSTATICLIB) $(COREDIR)
+       $(XCOPY) $(PERLSTATICLIB) $(COREDIR)\$(NULL)
 
 $(PERLEXE_RES): perlexe.rc $(PERLEXE_MANIFEST) $(PERLEXE_ICO)
 
 $(MINIDIR)\globals$(o) : $(GENERATED_HEADERS)
 
-$(UUDMAP_H) $(MG_DATA_H) : $(BITCOUNT_H)
-
-$(BITCOUNT_H) : $(GENUUDMAP)
-       $(GENUUDMAP) $(GENERATED_HEADERS)
-
-$(GENUUDMAP_OBJ) : ..\mg_raw.h
-
-$(GENUUDMAP) : $(GENUUDMAP_OBJ)
+$(GENUUDMAP) $(GENERATED_HEADERS) .UPDATEALL : ..\mg_raw.h
 .IF "$(CCTYPE)" == "GCC"
-       $(LINK32) -v -o $@ $(BLINK_FLAGS) \
-           $(mktmp $(LKPRE) $(GENUUDMAP_OBJ) $(LIBFILES) $(LKPOST))
+       $(LINK32) $(CFLAGS_O) -o..\generate_uudmap.exe ..\generate_uudmap.c \
+       $(BLINK_FLAGS) -x $(mktmp $(LKPRE) $(LIBFILES) $(LKPOST))
 .ELSE
-       $(LINK32) -subsystem:console -out:$@ $(BLINK_FLAGS) \
-           @$(mktmp $(LIBFILES) $(GENUUDMAP_OBJ))
-       $(EMBED_EXE_MANI)
+       $(CC) $(CFLAGS_O) -Fe..\generate_uudmap.exe ..\generate_uudmap.c @$(mktmp -link $(LIBFILES)) -link $(BLINK_FLAGS) 
+       $(EMBED_EXE_MANI:s/$@/..\generate_uudmap.exe/)
 .ENDIF
+       $(GENUUDMAP) $(GENERATED_HEADERS)
+
+#This generates a stub ppport.h & creates & fills /lib/CORE to allow for XS
+#building .c->.obj wise (linking is a different thing). This taget is AKA
+#$(HAVE_COREDIR).
+$(COREDIR)\ppport.h : $(CORE_H)
+       $(XCOPY) *.h $(COREDIR)\*.* && $(RCOPY) include $(COREDIR)\*.* && $(XCOPY) ..\*.h $(COREDIR)\*.*
+       rem. > $@
 
 perlmain.c : runperl.c
        copy runperl.c perlmain.c
 
-perlmain$(o) : perlmain.c
-       $(CC) $(CFLAGS_O:s,-DPERLDLL,-UPERLDLL,) $(OBJOUT_FLAG)$@ -c perlmain.c
+perlmain$(o) : $(CONFIGPM) perlmain.c
+       $(CC) $(CFLAGS_O:s,-DPERLDLL,-UPERLDLL,) $(OBJOUT_FLAG)$@ $(PDBOUT) -c perlmain.c
 
 perlmainst.c : runperl.c
        copy runperl.c perlmainst.c
 
-perlmainst$(o) : perlmainst.c
-       $(CC) $(CFLAGS_O) $(OBJOUT_FLAG)$@ -c perlmainst.c
+perlmainst$(o) : $(CONFIGPM) perlmainst.c
+       $(CC) $(CFLAGS_O) $(OBJOUT_FLAG)$@ $(PDBOUT) -c perlmainst.c
 
-$(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ) $(PERLEXE_RES)
+$(PERLEXE): $(CONFIGPM) $(PERLEXE_OBJ) $(PERLEXE_RES) $(PERLIMPLIB)
 .IF "$(CCTYPE)" == "GCC"
        $(LINK32) -mconsole -o $@ $(BLINK_FLAGS)  \
            $(PERLEXE_OBJ) $(PERLEXE_RES) $(PERLIMPLIB) $(LIBFILES)
 .ELSE
-       $(LINK32) -subsystem:console -out:$@ $(BLINK_FLAGS) \
+       $(LINK32) -out:$@ $(BLINK_FLAGS) \
            $(PERLEXE_OBJ) $(PERLEXE_RES) $(PERLIMPLIB) $(LIBFILES) $(SETARGV_OBJ)
        $(EMBED_EXE_MANI)
 .ENDIF
@@ -1357,49 +1447,57 @@ $(PERLEXESTATIC): $(PERLSTATICLIB) $(CONFIGPM) $(PERLEXEST_OBJ) $(PERLEXE_RES)
        $(LINK32) -mconsole -o $@ $(BLINK_FLAGS) \
            $(PERLEXEST_OBJ) $(PERLEXE_RES) $(PERLSTATICLIB) $(LIBFILES)
 .ELSE
-       $(LINK32) -subsystem:console -out:$@ $(BLINK_FLAGS) \
+       $(LINK32) -out:$@ $(BLINK_FLAGS) \
            $(PERLEXEST_OBJ) $(PERLEXE_RES) $(PERLSTATICLIB) $(LIBFILES) $(SETARGV_OBJ)
        $(EMBED_EXE_MANI)
 .ENDIF
 
-MakePPPort: $(MINIPERL) $(CONFIGPM) Extensions_nonxs
-       $(MINIPERL) -I..\lib ..\mkppport
-
 #-------------------------------------------------------------------------------
 # There's no direct way to mark a dependency on
 # DynaLoader.pm, so this will have to do
-Extensions : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
-       $(XCOPY) ..\*.h $(COREDIR)\*.*
-       $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic
 
-Extensions_reonly : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER)
-       $(XCOPY) ..\*.h $(COREDIR)\*.*
-       $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic +re
+#most of deps of this target are in DYNALOADER and therefore omitted here
+Extensions : $(PERLDEP) $(DYNALOADER) $(GLOBEXE)
+       $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic !Unicode/Normalize
 
-Extensions_static : ..\make_ext.pl ..\lib\buildcustomize.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs
-       $(XCOPY) ..\*.h $(COREDIR)\*.*
-       $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --static
+Extensions_normalize : $(PERLDEP) $(DYNALOADER) $(GLOBEXE) $(UNIDATAFILES)
+       $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic +Unicode/Normalize
+
+Extensions_reonly : $(PERLDEP) $(DYNALOADER)
+       $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic +re
+
+Extensions_static : ..\make_ext.pl list_static_libs.pl $(CONFIGPM) $(GLOBEXE) $(HAVE_COREDIR)
+       $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --static
        $(MINIPERL) -I..\lib list_static_libs.pl > Extensions_static
 
-Extensions_nonxs : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) ..\pod\perlfunc.pod
-       $(XCOPY) ..\*.h $(COREDIR)\*.*
-       $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --nonxs
+Extensions_nonxs : ..\make_ext.pl ..\pod\perlfunc.pod $(CONFIGPM) $(GLOBEXE)
+       $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --nonxs !libs
 
-$(DYNALOADER) : ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs
-       $(XCOPY) ..\*.h $(COREDIR)\*.*
-       $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --dynaloader
+#lib must be built, it can't be buildcustomize.pl-ed, and is required for XS building
+$(DYNALOADER) : ..\make_ext.pl $(CONFIGPM) $(HAVE_COREDIR)
+       $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(EXTDIR) --dir=$(DISTDIR) --dynaloader lib
 
 Extensions_clean :
-       -if exist $(MINIPERL) $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --all --target=clean
+       -if exist $(MINIPERL) $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --all --target=clean
 
 Extensions_realclean :
-       -if exist $(MINIPERL) $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --all --target=realclean
+       -if exist $(MINIPERL) $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --all --target=realclean
+
+# all PE files need to be built by the time this target runs, PP files can still
+# be running in parallel like UNIDATAFILES, this target a placeholder for the
+# future
+.IF "$(BUILD_STATIC)"=="define"
+rebasePE : Extensions $(PERLDLL) Extensions_normalize $(PERLEXE) $(GLOBEXE) $(PERLEXESTATIC)
+.ELSE
+rebasePE : Extensions $(PERLDLL) Extensions_normalize $(PERLEXE) $(GLOBEXE)
+.ENDIF
+       $(NOOP)
 
 #-------------------------------------------------------------------------------
 
 
-doc: $(PERLEXE) ..\pod\perltoc.pod
-       $(PERLEXE) -I..\lib ..\installhtml --podroot=.. --htmldir=$(HTMLDIR) \
+doc: $(PERLEXE) $(PERLDLL) ..\pod\perltoc.pod
+       $(PERLEXE) ..\installhtml --podroot=.. --htmldir=$(HTMLDIR) \
            --podpath=pod:lib:utils --htmlroot="file://$(INST_HTML:s,:,|,)"\
            --recurse
 
@@ -1408,8 +1506,8 @@ doc: $(PERLEXE) ..\pod\perltoc.pod
 
 # Note that this next section is parsed (and regenerated) by pod/buildtoc
 # so please check that script before making structural changes here
-utils: $(PERLEXE) ..\utils\Makefile
-       cd ..\utils && $(MAKE) PERL=$(MINIPERL)
+utils: $(HAVEMINIPERL) ..\utils\Makefile
+       cd ..\utils && $(PLMAKE) PERL=$(MINIPERL)
        copy ..\README.aix      ..\pod\perlaix.pod
        copy ..\README.amiga    ..\pod\perlamiga.pod
        copy ..\README.android  ..\pod\perlandroid.pod
@@ -1443,12 +1541,12 @@ utils: $(PERLEXE) ..\utils\Makefile
        copy ..\README.tw       ..\pod\perltw.pod
        copy ..\README.vos      ..\pod\perlvos.pod
        copy ..\README.win32    ..\pod\perlwin32.pod
-       copy ..\pod\perldelta.pod ..\pod\perl5217delta.pod
-       $(PERLEXE) $(PL2BAT) $(UTILS)
+       copy ..\pod\perldelta.pod ..\pod\perl5235delta.pod
+       $(MINIPERL) -I..\lib $(PL2BAT) $(UTILS)
        $(MINIPERL) -I..\lib ..\autodoc.pl ..
        $(MINIPERL) -I..\lib ..\pod\perlmodlib.PL -q ..
 
-..\pod\perltoc.pod: $(PERLEXE) Extensions Extensions_nonxs
+..\pod\perltoc.pod: $(PERLEXE) $(PERLDLL) Extensions Extensions_nonxs ..\pod\perluniprops.pod utils
        $(PERLEXE) -f ..\pod\buildtoc -q
 
 # Note that the pod cleanup in this next section is parsed (and regenerated
@@ -1477,6 +1575,7 @@ distclean: realclean
        -del /f $(LIBDIR)\buildcustomize.pl
        -del /f $(DISTDIR)\XSLoader\XSLoader.pm
        -del /f *.def *.map
+       -if exist $(LIBDIR)\Amiga rmdir /s /q $(LIBDIR)\Amiga
        -if exist $(LIBDIR)\App rmdir /s /q $(LIBDIR)\App
        -if exist $(LIBDIR)\Archive rmdir /s /q $(LIBDIR)\Archive
        -if exist $(LIBDIR)\Attribute rmdir /s /q $(LIBDIR)\Attribute
@@ -1538,7 +1637,7 @@ distclean: realclean
        -if exist $(LIBDIR)\Win32API rmdir /s /q $(LIBDIR)\Win32API
        -if exist $(LIBDIR)\XS rmdir /s /q $(LIBDIR)\XS
        -cd $(PODDIR) && del /f *.html *.bat roffitall \
-           perl5217delta.pod perlaix.pod perlamiga.pod perlandroid.pod \
+           perl5235delta.pod perlaix.pod perlamiga.pod perlandroid.pod \
            perlapi.pod perlbs2000.pod perlce.pod perlcn.pod perlcygwin.pod \
            perldos.pod perlfreebsd.pod perlhaiku.pod perlhpux.pod \
            perlhurd.pod perlintern.pod perlirix.pod perljp.pod perlko.pod \
@@ -1549,7 +1648,7 @@ distclean: realclean
            perltru64.pod perltw.pod perluniprops.pod perlvos.pod \
            perlwin32.pod
        -cd ..\utils && del /f h2ph splain perlbug pl2pm c2ph pstruct h2xs \
-           perldoc perlivp libnetcfg enc2xs piconv cpan *.bat \
+           perldoc perlivp libnetcfg enc2xs encguess piconv cpan *.bat \
            xsubpp pod2html instmodsh json_pp prove ptar ptardiff ptargrep shasum corelist zipdetails
        -del /f ..\config.sh perlmain.c dlutils.c config.h.new \
            perlmainst.c
@@ -1573,6 +1672,7 @@ install : all installbare installhtml
 
 installbare : utils ..\pod\perltoc.pod
        $(PERLEXE) ..\installperl
+       attrib -r $(INST_COREDIR)\ppport.h && del $(INST_COREDIR)\ppport.h
        if exist $(WPERLEXE) $(XCOPY) $(WPERLEXE) $(INST_BIN)\*.*
        if exist $(PERLEXESTATIC) $(XCOPY) $(PERLEXESTATIC) $(INST_BIN)\*.*
        $(XCOPY) $(GLOBEXE) $(INST_BIN)\*.*
@@ -1585,67 +1685,68 @@ installhtml : doc
 inst_lib : $(CONFIGPM)
        $(RCOPY) ..\lib $(INST_LIB)\*.*
 
-$(UNIDATAFILES) ..\pod\perluniprops.pod .UPDATEALL : $(MINIPERL) $(CONFIGPM) ..\lib\unicore\mktables Extensions_nonxs
+$(UNIDATAFILES) ..\pod\perluniprops.pod .UPDATEALL : $(CONFIGPM) ..\lib\unicore\mktables
        cd ..\lib\unicore && \
-       ..\$(MINIPERL) -I.. -I..\..\dist\Cwd\lib -I..\..\dist\Cwd mktables -P ..\..\pod -maketest -makelist -p
+       ..\$(MINIPERL) -I.. mktables -P ..\..\pod -maketest -makelist -p
 
-minitest : $(MINIPERL) $(GLOBEXE) $(CONFIGPM) $(UNIDATAFILES) utils
+minitest : .\config.h $(HAVEMINIPERL) ..\git_version.h $(GLOBEXE) $(CONFIGPM) $(UNIDATAFILES) $(TESTPREPGCC)
        $(XCOPY) $(MINIPERL) ..\t\$(NULL)
        if exist ..\t\perl.exe del /f ..\t\perl.exe
        rename ..\t\miniperl.exe perl.exe
        $(XCOPY) $(GLOBEXE) ..\t\$(NULL)
-       attrib -r ..\t\*.*
-       cd ..\t && \
-       $(MINIPERL) -I..\lib harness base/*.t comp/*.t cmd/*.t io/*.t opbasic/*.t op/*.t pragma/*.t
+# Note this perl.exe is miniperl
+       cd ..\t && perl.exe TEST base/*.t comp/*.t cmd/*.t run/*.t io/*.t re/*.t opbasic/*.t op/*.t uni/*.t perf/*.t pragma/*.t
+
+test-prep : all utils ..\pod\perltoc.pod $(TESTPREPGCC)
+       $(XCOPY) $(PERLEXE) ..\t\$(NULL) && $(XCOPY) $(PERLDLL) ..\t\$(NULL) \
+       && $(XCOPY) $(GLOBEXE) ..\t\$(NULL)
 
-test-prep : all utils ..\pod\perltoc.pod
-       $(XCOPY) $(PERLEXE) ..\t\$(NULL)
-       $(XCOPY) $(PERLDLL) ..\t\$(NULL)
-       $(XCOPY) $(GLOBEXE) ..\t\$(NULL)
-.IF "$(CCTYPE)" == "GCC"
 # If building with gcc versions 4.x.x or greater, then
 # the GCC helper DLL will also need copied to the test directory.
 # The name of the dll can change, depending upon which vendor has supplied
 # your compiler, and upon the values of "x".
 # libstdc++-6.dll is copied if it exists as it, too, may then be needed.
 # Without this copying, the op/taint.t test script will fail.
+
+.IF "$(CCTYPE)" == "GCC"
+
+test-prep-gcc :
        if exist $(CCDLLDIR)\libgcc_s_seh-1.dll $(XCOPY) $(CCDLLDIR)\libgcc_s_seh-1.dll ..\t\$(NULL)
        if exist $(CCDLLDIR)\libgcc_s_sjlj-1.dll $(XCOPY) $(CCDLLDIR)\libgcc_s_sjlj-1.dll ..\t\$(NULL)
        if exist $(CCDLLDIR)\libgcc_s_dw2-1.dll $(XCOPY) $(CCDLLDIR)\libgcc_s_dw2-1.dll ..\t\$(NULL)
        if exist $(CCDLLDIR)\libstdc++-6.dll $(XCOPY) $(CCDLLDIR)\libstdc++-6.dll ..\t\$(NULL)
        if exist $(CCDLLDIR)\libwinpthread-1.dll $(XCOPY) $(CCDLLDIR)\libwinpthread-1.dll ..\t\$(NULL)
+
 .ENDIF
 
 test : test-prep
        set PERL_STATIC_EXT=$(STATIC_EXT) && \
-           cd ..\t && $(PERLEXE) -I..\lib harness $(TEST_SWITCHES) $(TEST_FILES)
+           cd ..\t && perl.exe harness $(TEST_SWITCHES) $(TEST_FILES)
 
 test_porting : test-prep
        set PERL_STATIC_EXT=$(STATIC_EXT) && \
-           cd ..\t && $(PERLEXE) -I..\lib harness $(TEST_SWITCHES) porting\*.t ..\lib\diagnostics.t
+           cd ..\t && perl.exe harness $(TEST_SWITCHES) porting\*.t ..\lib\diagnostics.t
 
 test-reonly : reonly utils
        $(XCOPY) $(PERLEXE) ..\t\$(NULL)
        $(XCOPY) $(PERLDLL) ..\t\$(NULL)
        $(XCOPY) $(GLOBEXE) ..\t\$(NULL)
-       cd ..\t && \
-       $(PERLEXE) -I..\lib harness $(OPT) -re \bpat\\/ $(EXTRA) && \
-       cd ..\win32
+       cd ..\t && perl.exe harness $(OPT) -re \bpat\\/ $(EXTRA)
 
 regen :
-       cd .. && regen.pl && cd win32
+       cd .. && regen.pl
 
 test-notty : test-prep
        set PERL_STATIC_EXT=$(STATIC_EXT) && \
            set PERL_SKIP_TTY_TEST=1 && \
-           cd ..\t && $(PERLEXE) -I.\lib harness $(TEST_SWITCHES) $(TEST_FILES)
+           cd ..\t && perl.exe harness $(TEST_SWITCHES) $(TEST_FILES)
 
 _test :
        $(XCOPY) $(PERLEXE) ..\t\$(NULL)
        $(XCOPY) $(PERLDLL) ..\t\$(NULL)
        $(XCOPY) $(GLOBEXE) ..\t\$(NULL)
        set PERL_STATIC_EXT=$(STATIC_EXT) && \
-           cd ..\t && $(PERLEXE) -I..\lib harness $(TEST_SWITCHES) $(TEST_FILES)
+           cd ..\t && perl.exe harness $(TEST_SWITCHES) $(TEST_FILES)
 
 _clean :
        -@erase miniperlmain$(o)
@@ -1673,7 +1774,7 @@ _clean :
        -@erase ..\*$(o) ..\*$(a) ..\*.exp *$(o) *$(a) *.exp *.res
        -@erase ..\t\*.exe ..\t\*.dll ..\t\*.bat
        -@erase *.ilk
-       -@erase *.pdb
+       -@erase *.pdb ..\*.pdb
        -@erase Extensions_static
 
 
@@ -1687,13 +1788,13 @@ realclean : Extensions_realclean _clean
 # Please *don't* use this unless all tests pass.
 # If you want to report test failures, use "dmake nok" instead.
 ok: utils
-       $(PERLEXE) -I..\lib ..\utils\perlbug -ok -s "(UNINSTALLED)"
+       $(PERLEXE) ..\utils\perlbug -ok -s "(UNINSTALLED)"
 
 okfile: utils
-       $(PERLEXE) -I..\lib ..\utils\perlbug -ok -s "(UNINSTALLED)" -F perl.ok
+       $(PERLEXE) ..\utils\perlbug -ok -s "(UNINSTALLED)" -F perl.ok
 
 nok: utils
-       $(PERLEXE) -I..\lib ..\utils\perlbug -nok -s "(UNINSTALLED)"
+       $(PERLEXE) ..\utils\perlbug -nok -s "(UNINSTALLED)"
 
 nokfile: utils
-       $(PERLEXE) -I..\lib ..\utils\perlbug -nok -s "(UNINSTALLED)" -F perl.nok
+       $(PERLEXE) ..\utils\perlbug -nok -s "(UNINSTALLED)" -F perl.nok