xref: /openbsd-src/gnu/usr.bin/perl/win32/GNUmakefile (revision 9f11ffb7133c203312a01e4b986886bc88c7d74b)
1#
2# Makefile to build perl on Windows using GMAKE.
3# Supported compilers:
4#	Microsoft Visual C++ 6.0 or later
5#	MinGW with gcc-3.4.5 or later with runtime < 3.21
6#	MinGW64 with gcc-4.4.3 or later
7#	Windows SDK 64-bit compiler and tools
8#
9# This is set up to build a perl.exe that runs off a shared library
10# (perl528.dll).  Also makes individual DLLs for the XS extensions.
11#
12# The easiest way to customize the build process is to use parameters like this:
13#
14# c:\dev\perlsrc\win32> gmake INST_TOP=c:\sw\perl CCHOME=c:\sw\mingw USE_64_BIT_INT=define
15
16
17##
18## Make sure you read README.win32 *before* you mess with anything here!
19##
20
21#
22# We set this to point to cmd.exe in case GNU Make finds sh.exe in the path.
23# Comment this line out if necessary
24#
25SHELL := cmd.exe
26
27# define whether you want to use native gcc compiler or cross-compiler
28# possible values: gcc
29#                  i686-w64-mingw32-gcc
30#                  x86_64-w64-mingw32-gcc
31GCCBIN := gcc
32
33ifeq ($(GCCBIN),x86_64-w64-mingw32-gcc)
34GCCCROSS := x86_64-w64-mingw32
35endif
36ifeq ($(GCCBIN),i686-w64-mingw32-gcc)
37GCCCROSS := i686-w64-mingw32
38endif
39
40
41##
42## Build configuration.  Edit the values below to suit your needs.
43##
44
45#
46# Set these to wherever you want "gmake install" to put your
47# newly built perl.
48#
49INST_DRV := c:
50INST_TOP := $(INST_DRV)\perl
51
52#
53# Uncomment if you want to build a 32-bit Perl using a 32-bit compiler
54# on a 64-bit version of Windows.
55#
56#WIN64		:= undef
57
58#
59# Comment this out if you DON'T want your perl installation to be versioned.
60# This means that the new installation will overwrite any files from the
61# old installation at the same INST_TOP location.  Leaving it enabled is
62# the safest route, as perl adds the extra version directory to all the
63# locations it installs files to.  If you disable it, an alternative
64# versioned installation can be obtained by setting INST_TOP above to a
65# path that includes an arbitrary version string.
66#
67#INST_VER	:= \5.28.1
68
69#
70# Comment this out if you DON'T want your perl installation to have
71# architecture specific components.  This means that architecture-
72# specific files will be installed along with the architecture-neutral
73# files.  Leaving it enabled is safer and more flexible, in case you
74# want to build multiple flavors of perl and install them together in
75# the same location.  Commenting it out gives you a simpler
76# installation that is easier to understand for beginners.
77#
78#INST_ARCH	:= \$(ARCHNAME)
79
80#
81# Uncomment this if you want perl to run
82# 	$Config{sitelibexp}\sitecustomize.pl
83# before anything else.  This script can then be set up, for example,
84# to add additional entries to @INC.
85#
86#USE_SITECUST	:= define
87
88#
89# uncomment to enable multiple interpreters.  This is needed for fork()
90# emulation and for thread support, and is auto-enabled by USE_IMP_SYS
91# and USE_ITHREADS below.
92#
93USE_MULTI	:= define
94
95#
96# Interpreter cloning/threads; now reasonably complete.
97# This should be enabled to get the fork() emulation.  This needs (and
98# will auto-enable) USE_MULTI above.
99#
100USE_ITHREADS	:= define
101
102#
103# uncomment to enable the implicit "host" layer for all system calls
104# made by perl.  This is also needed to get fork().  This needs (and
105# will auto-enable) USE_MULTI above.
106#
107USE_IMP_SYS	:= define
108
109#
110# Comment out next assign to disable perl's I/O subsystem and use compiler's
111# stdio for IO - depending on your compiler vendor and run time library you may
112# then get a number of fails from make test i.e. bugs - complain to them not us ;-).
113# You will also be unable to take full advantage of perl5.8's support for multiple
114# encodings and may see lower IO performance. You have been warned.
115#
116USE_PERLIO	:= define
117
118#
119# Comment this out if you don't want to enable large file support for
120# some reason.  Should normally only be changed to maintain compatibility
121# with an older release of perl.
122#
123USE_LARGE_FILES	:= define
124
125#
126# Uncomment this if you're building a 32-bit perl and want 64-bit integers.
127# (If you're building a 64-bit perl then you will have 64-bit integers whether
128# or not this is uncommented.)
129# Note: This option is not supported in 32-bit MSVC60 builds.
130#
131#USE_64_BIT_INT	:= define
132
133#
134# Uncomment this if you want to support the use of long doubles in GCC builds.
135# This option is not supported for MSVC builds.
136#
137#USE_LONG_DOUBLE := define
138
139#
140# Uncomment this if you want to build perl with __USE_MINGW_ANSI_STDIO defined.
141# (If you're building perl with USE_LONG_DOUBLE defined then
142# __USE_MINGW_ANSI_STDIO will be defined whether or not this is uncommented.)
143# This option is not supported for MSVC builds.
144#
145#USE_MINGW_ANSI_STDIO := define
146
147#
148# Comment this out if you want the legacy default behavior of including '.' at
149# the end of @INC.
150#
151DEFAULT_INC_EXCLUDES_DOT := define
152
153#
154# Uncomment this if you want to disable looking up values from
155# HKEY_CURRENT_USER\Software\Perl and HKEY_LOCAL_MACHINE\Software\Perl in
156# the Registry.
157#
158#USE_NO_REGISTRY := define
159
160#
161# uncomment exactly one of the following
162#
163# Visual C++ 6.0 (aka Visual C++ 98)
164#CCTYPE		:= MSVC60
165# Visual C++ .NET 2002/2003 (aka Visual C++ 7.0/7.1) (full version)
166#CCTYPE		:= MSVC70
167# Visual C++ Toolkit 2003 (aka Visual C++ 7.1) (free command-line tools)
168#CCTYPE		:= MSVC70FREE
169# Windows Server 2003 SP1 Platform SDK (April 2005)
170#CCTYPE		:= SDK2003SP1
171# Visual C++ 2005 (aka Visual C++ 8.0) (full version or Express Edition)
172#CCTYPE		:= MSVC80
173# Visual C++ 2008 (aka Visual C++ 9.0) (full version or Express Edition)
174#CCTYPE		:= MSVC90
175# Visual C++ 2010 (aka Visual C++ 10.0) (full version or Express Edition)
176#CCTYPE		:= MSVC100
177# Visual C++ 2012 (aka Visual C++ 11.0) (full version or Express Edition)
178#CCTYPE		:= MSVC110
179# Visual C++ 2013 (aka Visual C++ 12.0) (full version or Express Edition)
180#CCTYPE		:= MSVC120
181# Visual C++ 2015 (aka Visual C++ 14.0) (full version or Express Edition)
182#CCTYPE		:= MSVC140
183# Visual C++ 2017 (aka Visual C++ 14.1) (full version or Community Edition)
184#CCTYPE		:= MSVC141
185# MinGW or mingw-w64 with gcc-3.4.5 or later
186#CCTYPE		:= GCC
187
188#
189# If you are using Intel C++ Compiler uncomment this
190#
191#__ICC		:= define
192
193#
194# uncomment next line if you want debug version of perl (big/slow)
195# If not enabled, we automatically try to use maximum optimization
196# with all compilers that are known to have a working optimizer.
197#
198#CFG		:= Debug
199
200#
201# uncomment to enable linking with setargv.obj under the Visual C
202# compiler. Setting this options enables perl to expand wildcards in
203# arguments, but it may be harder to use alternate methods like
204# File::DosGlob that are more powerful.  This option is supported only with
205# Visual C.
206#
207#USE_SETARGV	:= define
208
209#
210# set this if you wish to use perl's malloc
211# WARNING: Turning this on/off WILL break binary compatibility with extensions
212# you may have compiled with/without it.  Be prepared to recompile all
213# extensions if you change the default.  Currently, this cannot be enabled
214# if you ask for USE_IMP_SYS above.
215#
216#PERL_MALLOC	:= define
217
218#
219# set this to enable debugging mstats
220# This must be enabled to use the Devel::Peek::mstat() function.  This cannot
221# be enabled without PERL_MALLOC as well.
222#
223#DEBUG_MSTATS	:= define
224
225#
226# set this to additionally provide a statically linked perl-static.exe.
227# Note that dynamic loading will not work with this perl, so you must
228# include required modules statically using the STATIC_EXT or ALL_STATIC
229# variables below. A static library perl528s.lib will also be created.
230# Ordinary perl.exe is not affected by this option.
231#
232#BUILD_STATIC	:= define
233
234#
235# in addition to BUILD_STATIC the option ALL_STATIC makes *every*
236# extension get statically built.
237# This will result in a very large perl executable, but the main purpose
238# is to have proper linking set so as to be able to create miscellaneous
239# executables with different built-in extensions. It implies BUILD_STATIC.
240#
241#ALL_STATIC	:= define
242
243#
244# set the install locations of the compiler
245# Running VCVARS32.BAT, VCVARSALL.BAT or similar is *required* when using
246# Visual C++.
247#
248#CCHOME		:= C:\MinGW
249
250#
251# Additional compiler flags can be specified here.
252#
253BUILDOPT	:= $(BUILDOPTEXTRA)
254
255#
256# This should normally be disabled.  Enabling it will disable the File::Glob
257# implementation of CORE::glob.
258#
259#BUILDOPT	+= -DPERL_EXTERNAL_GLOB
260
261#
262# Perl needs to read scripts in text mode so that the DATA filehandle
263# works correctly with seek() and tell(), or around auto-flushes of
264# all filehandles (e.g. by system(), backticks, fork(), etc).
265#
266# The current version on the ByteLoader module on CPAN however only
267# works if scripts are read in binary mode.  But before you disable text
268# mode script reading (and break some DATA filehandle functionality)
269# please check first if an updated ByteLoader isn't available on CPAN.
270#
271BUILDOPT	+= -DPERL_TEXTMODE_SCRIPTS
272
273#
274# specify semicolon-separated list of extra directories that modules will
275# look for libraries (spaces in path names need not be quoted)
276#
277EXTRALIBDIRS	:=
278
279#
280# set this to your email address (perl will guess a value from
281# from your loginname and your hostname, which may not be right)
282#
283#EMAIL		:=
284
285##
286## Build configuration ends.
287##
288
289##################### CHANGE THESE ONLY IF YOU MUST #####################
290
291PERL_MALLOC	?= undef
292DEBUG_MSTATS	?= undef
293
294USE_SITECUST	?= undef
295USE_MULTI	?= undef
296USE_ITHREADS	?= undef
297USE_IMP_SYS	?= undef
298USE_PERLIO	?= undef
299USE_LARGE_FILES	?= undef
300USE_64_BIT_INT	?= undef
301USE_LONG_DOUBLE	?= undef
302DEFAULT_INC_EXCLUDES_DOT ?= undef
303USE_NO_REGISTRY	?= undef
304
305ifeq ($(USE_IMP_SYS),define)
306PERL_MALLOC	= undef
307endif
308
309ifeq ($(PERL_MALLOC),undef)
310DEBUG_MSTATS	= undef
311endif
312
313ifeq ($(DEBUG_MSTATS),define)
314BUILDOPT	+= -DPERL_DEBUGGING_MSTATS
315endif
316
317ifeq ("$(USE_IMP_SYS) $(USE_MULTI)","define undef")
318USE_MULTI	= define
319endif
320
321ifeq ("$(USE_ITHREADS) $(USE_MULTI)","define undef")
322USE_MULTI	= define
323endif
324
325ifeq ($(USE_SITECUST),define)
326BUILDOPT	+= -DUSE_SITECUSTOMIZE
327endif
328
329ifneq ($(USE_MULTI),undef)
330BUILDOPT	+= -DPERL_IMPLICIT_CONTEXT
331endif
332
333ifneq ($(USE_IMP_SYS),undef)
334BUILDOPT	+= -DPERL_IMPLICIT_SYS
335endif
336
337ifeq ($(USE_NO_REGISTRY),define)
338BUILDOPT	+= -DWIN32_NO_REGISTRY
339endif
340
341ifeq ($(CCTYPE),GCC)
342GCCTARGET	:= $(shell $(GCCBIN) -dumpmachine)
343endif
344
345#no explicit CCTYPE given, do auto detection
346ifeq ($(CCTYPE),)
347GCCTARGET	:= $(shell $(GCCBIN) -dumpmachine 2>NUL)
348#do we have a GCC?
349ifneq ($(GCCTARGET),)
350CCTYPE		:= GCC
351else
352#use var to capture 1st line only, not 8th token of lines 2 & 3 in cl.exe output
353#rmving the cmd /c causes the var2b undef4echo but!4"set MSVCVER", cmd.exe bug?
354MSVCVER		:= $(shell (set MSVCVER=) & (for /f "tokens=8 delims=.^ " \
355	%%i in ('cl ^2^>^&1') do if not defined MSVCVER set /A "MSVCVER=%%i-6") \
356	& cmd /c echo %%MSVCVER%%)
357CCTYPE		:= MSVC$(MSVCVER)0
358endif
359endif
360
361# Versions of Visual C++ up to VC++ 7.1 define $(MSVCDir); versions since then
362# define $(VCINSTALLDIR) instead, but for VC++ 14.1 we need the subfolder given
363# by $(VCToolsInstallDir).
364ifeq ($(CCHOME),)
365ifeq ($(CCTYPE),GCC)
366CCHOME		:= C:\MinGW
367else ifeq ($(CCTYPE),MSVC60)
368CCHOME		:= $(MSVCDir)
369else ifeq ($(CCTYPE),MSVC70)
370CCHOME		:= $(MSVCDir)
371else ifeq ($(CCTYPE),MSVC70FREE)
372CCHOME		:= $(MSVCDir)
373else ifeq ($(CCTYPE),MSVC141)
374CCHOME		:= $(VCToolsInstallDir)
375else
376CCHOME		:= $(VCINSTALLDIR)
377endif
378endif
379
380ifeq ($(CCTYPE),GCC)
381ifeq ($(GCCTARGET),x86_64-w64-mingw32)
382WIN64 := define
383PROCESSOR_ARCHITECTURE := x64
384endif
385ifeq ($(GCCTARGET),i686-w64-mingw32)
386WIN64 := undef
387PROCESSOR_ARCHITECTURE := x86
388endif
389endif
390
391PROCESSOR_ARCHITECTURE  ?= x86
392
393ifeq ($(WIN64),undef)
394PROCESSOR_ARCHITECTURE	= x86
395endif
396
397ifeq ($(WIN64),)
398# When we are running from a 32bit cmd.exe on AMD64 then
399# PROCESSOR_ARCHITECTURE is set to x86 and PROCESSOR_ARCHITEW6432
400# is set to AMD64
401ifneq ($(PROCESSOR_ARCHITEW6432),)
402PROCESSOR_ARCHITECTURE	= $(PROCESSOR_ARCHITEW6432)
403WIN64			= define
404else ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
405WIN64			= define
406else ifeq ($(PROCESSOR_ARCHITECTURE),IA64)
407WIN64			= define
408else
409WIN64			= undef
410endif
411endif
412
413ifeq ($(WIN64),define)
414USE_64_BIT_INT	= define
415endif
416
417# Treat 64-bit MSVC60 (doesn't really exist) as SDK2003SP1 because
418# both link against MSVCRT.dll (which is part of Windows itself) and
419# not against a compiler specific versioned runtime.
420ifeq ("$(WIN64) $(CCTYPE)","define MSVC60")
421CCTYPE		= SDK2003SP1
422endif
423
424# Disable the 64-bit-int option for (32-bit) MSVC60 builds since that compiler
425# does not support it.
426ifeq ($(CCTYPE),MSVC60)
427USE_64_BIT_INT	= undef
428endif
429
430# Disable the long double option for MSVC builds since that compiler
431# does not support it.
432ifneq ($(CCTYPE),GCC)
433USE_LONG_DOUBLE	= undef
434endif
435
436ARCHITECTURE = $(PROCESSOR_ARCHITECTURE)
437ifeq ($(ARCHITECTURE),AMD64)
438ARCHITECTURE	= x64
439endif
440ifeq ($(ARCHITECTURE),IA64)
441ARCHITECTURE	= ia64
442endif
443
444ifeq ($(USE_MULTI),define)
445ARCHNAME	= MSWin32-$(ARCHITECTURE)-multi
446else
447ifeq ($(USE_PERLIO),define)
448ARCHNAME	= MSWin32-$(ARCHITECTURE)-perlio
449else
450ARCHNAME	= MSWin32-$(ARCHITECTURE)
451endif
452endif
453
454ifeq ($(USE_PERLIO),define)
455BUILDOPT	+= -DUSE_PERLIO
456endif
457
458ifeq ($(USE_ITHREADS),define)
459ARCHNAME	:= $(ARCHNAME)-thread
460endif
461
462ifneq ($(WIN64),define)
463ifeq ($(USE_64_BIT_INT),define)
464ARCHNAME	:= $(ARCHNAME)-64int
465endif
466endif
467
468ifeq ($(USE_LONG_DOUBLE),define)
469ARCHNAME	:= $(ARCHNAME)-ld
470endif
471
472# Set the install location of the compiler headers/libraries.
473# These are saved into $Config{incpath} and $Config{libpth}.
474ifneq ($(GCCCROSS),)
475CCINCDIR := $(CCHOME)\$(GCCCROSS)\include
476CCLIBDIR := $(CCHOME)\$(GCCCROSS)\lib
477ARCHPREFIX := $(GCCCROSS)-
478else ifeq ($(CCTYPE),GCC)
479CCINCDIR := $(CCHOME)\include
480CCLIBDIR := $(CCHOME)\lib
481ARCHPREFIX :=
482else
483CCINCDIR := $(CCHOME)\include
484ifeq ($(CCTYPE),MSVC141)
485ifeq ($(WIN64),define)
486CCLIBDIR := $(CCHOME)\lib\x64
487else
488CCLIBDIR := $(CCHOME)\lib\x86
489endif
490else
491ifeq ($(WIN64),define)
492CCLIBDIR := $(CCHOME)\lib\amd64
493else
494CCLIBDIR := $(CCHOME)\lib
495endif
496endif
497ARCHPREFIX :=
498endif
499
500# Set DLL location for GCC compilers.
501ifeq ($(CCTYPE),GCC)
502ifneq ($(GCCCROSS),)
503CCDLLDIR := $(CCLIBDIR)
504else
505CCDLLDIR := $(CCHOME)\bin
506endif
507endif
508
509ARCHDIR		= ..\lib\$(ARCHNAME)
510COREDIR		= ..\lib\CORE
511AUTODIR		= ..\lib\auto
512LIBDIR		= ..\lib
513EXTDIR		= ..\ext
514DISTDIR		= ..\dist
515CPANDIR		= ..\cpan
516PODDIR		= ..\pod
517HTMLDIR		= .\html
518
519INST_SCRIPT	= $(INST_TOP)$(INST_VER)\bin
520INST_BIN	= $(INST_SCRIPT)$(INST_ARCH)
521INST_LIB	= $(INST_TOP)$(INST_VER)\lib
522INST_ARCHLIB	= $(INST_LIB)$(INST_ARCH)
523INST_COREDIR	= $(INST_ARCHLIB)\CORE
524INST_HTML	= $(INST_TOP)$(INST_VER)\html
525
526#
527# Programs to compile, build .lib files and link
528#
529
530MINIBUILDOPT    :=
531
532ifeq ($(CCTYPE),GCC)
533
534CC		= $(ARCHPREFIX)gcc
535LINK32		= $(ARCHPREFIX)g++
536LIB32		= $(ARCHPREFIX)ar rc
537IMPLIB		= $(ARCHPREFIX)dlltool
538RSC		= $(ARCHPREFIX)windres
539
540ifeq ($(USE_LONG_DOUBLE),define)
541BUILDOPT        += -D__USE_MINGW_ANSI_STDIO
542MINIBUILDOPT    += -D__USE_MINGW_ANSI_STDIO
543else ifeq ($(USE_MINGW_ANSI_STDIO),define)
544BUILDOPT        += -D__USE_MINGW_ANSI_STDIO
545MINIBUILDOPT    += -D__USE_MINGW_ANSI_STDIO
546endif
547
548GCCVER1   := $(shell for /f "delims=. tokens=1,2,3" %%i in ('gcc -dumpversion') do echo %%i)
549GCCVER2   := $(shell for /f "delims=. tokens=1,2,3" %%i in ('gcc -dumpversion') do echo %%j)
550GCCVER3   := $(shell for /f "delims=. tokens=1,2,3" %%i in ('gcc -dumpversion') do echo %%k)
551
552# If you are using GCC, 4.3 or later by default we add the -fwrapv option.
553# See https://rt.perl.org/Ticket/Display.html?id=121505
554#
555GCCWRAPV := $(shell if "$(GCCVER1)"=="4" (if "$(GCCVER2)" geq "3" echo define) else if "$(GCCVER1)" geq "5" (echo define))
556
557ifeq ($(GCCWRAPV),define)
558BUILDOPT        += -fwrapv
559MINIBUILDOPT    += -fwrapv
560endif
561
562i = .i
563o = .o
564a = .a
565
566#
567# Options
568#
569
570INCLUDES	= -I.\include -I. -I..
571DEFINES		= -DWIN32
572ifeq ($(WIN64),define)
573DEFINES		+= -DWIN64 -DCONSERVATIVE
574endif
575LOCDEFS		= -DPERLDLL -DPERL_CORE
576CXX_FLAG	= -xc++
577LIBC		=
578LIBFILES	= $(LIBC) -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool \
579	-lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 \
580	-luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
581
582ifeq ($(CFG),Debug)
583OPTIMIZE	= -g -O2 -DDEBUGGING
584LINK_DBG	= -g
585else
586OPTIMIZE	= -s -O2
587LINK_DBG	= -s
588endif
589
590EXTRACFLAGS	=
591CFLAGS		= $(EXTRACFLAGS) $(INCLUDES) $(DEFINES) $(LOCDEFS) $(OPTIMIZE)
592LINK_FLAGS	= $(LINK_DBG) -L"$(INST_COREDIR)" -L"$(CCLIBDIR)"
593OBJOUT_FLAG	= -o
594EXEOUT_FLAG	= -o
595LIBOUT_FLAG	=
596PDBOUT		=
597
598BUILDOPT	+= -fno-strict-aliasing -mms-bitfields
599MINIBUILDOPT	+= -fno-strict-aliasing
600
601TESTPREPGCC	= test-prep-gcc
602
603else
604
605o = .obj
606
607# All but the free version of VC++ 7.1 can load DLLs on demand.  Makes the test
608# suite run in about 10% less time.
609ifneq ($(CCTYPE),MSVC70FREE)
610# If no registry, advapi32 is only used for Perl_pp_getlogin/getlogin/GetUserNameA
611# which is rare to execute
612ifneq ($(USE_NO_REGISTRY),undef)
613DELAYLOAD	= -DELAYLOAD:ws2_32.dll -DELAYLOAD:advapi32.dll delayimp.lib
614MINIDELAYLOAD	=
615else
616DELAYLOAD	= -DELAYLOAD:ws2_32.dll delayimp.lib
617#miniperl never does any registry lookups
618MINIDELAYLOAD	= -DELAYLOAD:advapi32.dll
619endif
620endif
621
622# Visual C++ 2005 and 2008 (VC++ 8.0 and 9.0) create manifest files for EXEs and
623# DLLs. These either need copying everywhere with the binaries, or else need
624# embedding in them otherwise MSVCR80.dll or MSVCR90.dll won't be found. For
625# simplicity, embed them if they exist (and delete them afterwards so that they
626# don't get installed too).
627EMBED_EXE_MANI	= if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;1 && \
628		  if exist $@.manifest del $@.manifest
629EMBED_DLL_MANI	= if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2 && \
630		  if exist $@.manifest del $@.manifest
631
632# Most relevant compiler-specific options fall into two groups:
633# either pre-MSVC80 or MSVC80 onwards, so define a macro for this.
634ifeq ($(CCTYPE),MSVC60)
635PREMSVC80	= define
636else ifeq ($(CCTYPE),MSVC70)
637PREMSVC80	= define
638else ifeq ($(CCTYPE),MSVC70FREE)
639PREMSVC80	= define
640else
641PREMSVC80	= undef
642endif
643
644ifneq ($(__ICC),define)
645CC		= cl
646LINK32		= link
647else
648CC		= icl
649LINK32		= xilink
650endif
651LIB32		= $(LINK32) -lib
652RSC		= rc
653
654#
655# Options
656#
657
658INCLUDES	= -I.\include -I. -I..
659#PCHFLAGS	= -Fpc:\temp\vcmoduls.pch -YX
660DEFINES		= -DWIN32 -D_CONSOLE -DNO_STRICT
661LOCDEFS		= -DPERLDLL -DPERL_CORE
662CXX_FLAG	= -TP -EHsc
663
664ifeq ($(CCTYPE),MSVC140)
665LIBC		= ucrt.lib
666else ifeq ($(CCTYPE),MSVC141)
667LIBC		= ucrt.lib
668else
669LIBC		= msvcrt.lib
670endif
671
672ifeq ($(CFG),Debug)
673OPTIMIZE	= -Od -MD -Zi -DDEBUGGING
674LINK_DBG	= -debug
675else ifeq ($(CFG),DebugSymbols)
676OPTIMIZE	= -Od -MD -Zi
677LINK_DBG	= -debug
678else ifeq ($(CFG),DebugFull)
679ifeq ($(CCTYPE),MSVC140)
680LIBC		= ucrtd.lib
681else ifeq ($(CCTYPE),MSVC141)
682LIBC		= ucrtd.lib
683else
684LIBC		= msvcrtd.lib
685endif
686OPTIMIZE	= -Od -MDd -Zi -D_DEBUG -DDEBUGGING
687LINK_DBG	= -debug
688else
689# -O1 yields smaller code, which turns out to be faster than -O2 on x86 and x64
690OPTIMIZE	= -O1 -MD -Zi -DNDEBUG
691# we enable debug symbols in release builds also
692LINK_DBG	= -debug -opt:ref,icf
693# you may want to enable this if you want COFF symbols in the executables
694# in addition to the PDB symbols.  The default Dr. Watson that ships with
695# Windows can use the the former but not latter.  The free WinDbg can be
696# installed to get better stack traces from just the PDB symbols, so we
697# avoid the bloat of COFF symbols by default.
698#LINK_DBG	= $(LINK_DBG) -debugtype:both
699ifneq ($(CCTYPE),MSVC60)
700# enable Whole Program Optimizations (WPO) and Link Time Code Generation (LTCG)
701OPTIMIZE	+= -GL
702LINK_DBG	+= -ltcg
703LIB_FLAGS	= -ltcg
704endif
705endif
706
707ifeq ($(WIN64),define)
708DEFINES		+= -DWIN64 -DCONSERVATIVE
709OPTIMIZE	+= -fp:precise
710endif
711
712# For now, silence warnings from VC++ 8.0 onwards about "unsafe" CRT functions
713# and POSIX CRT function names being deprecated.
714ifeq ($(PREMSVC80),undef)
715DEFINES		+= -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
716endif
717
718# Likewise for deprecated Winsock APIs in VC++ 14.0 onwards for now.
719ifeq ($(CCTYPE),MSVC140)
720DEFINES		+= -D_WINSOCK_DEPRECATED_NO_WARNINGS
721else ifeq ($(CCTYPE),MSVC141)
722DEFINES		+= -D_WINSOCK_DEPRECATED_NO_WARNINGS
723endif
724
725# In VS 2005 (VC++ 8.0) Microsoft changes time_t from 32-bit to
726# 64-bit, even in 32-bit mode.  It also provides the _USE_32BIT_TIME_T
727# preprocessor option to revert back to the old functionality for
728# backward compatibility.  We define this symbol here for older 32-bit
729# compilers only (which aren't using it at all) for the sole purpose
730# of getting it into $Config{ccflags}.  That way if someone builds
731# Perl itself with e.g. VC6 but later installs an XS module using VC8
732# the time_t types will still be compatible.
733ifeq ($(WIN64),undef)
734ifeq ($(PREMSVC80),define)
735BUILDOPT	+= -D_USE_32BIT_TIME_T
736endif
737endif
738
739LIBBASEFILES	= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib \
740	comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
741	netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib \
742	odbc32.lib odbccp32.lib comctl32.lib
743
744ifeq ($(CCTYPE),MSVC140)
745ifeq ($(CFG),DebugFull)
746LIBBASEFILES	+= msvcrtd.lib vcruntimed.lib
747else
748LIBBASEFILES	+= msvcrt.lib vcruntime.lib
749endif
750else ifeq ($(CCTYPE),MSVC141)
751ifeq ($(CFG),DebugFull)
752LIBBASEFILES	+= msvcrtd.lib vcruntimed.lib
753else
754LIBBASEFILES	+= msvcrt.lib vcruntime.lib
755endif
756endif
757
758# Avoid __intel_new_proc_init link error for libircmt.
759# libmmd is /MD equivelent, other variants exist.
760# libmmd is Intel C's math addon funcs to MS CRT, contains long doubles, C99,
761# and optimized C89 funcs
762ifeq ($(__ICC),define)
763LIBBASEFILES	+= libircmt.lib libmmd.lib
764endif
765
766# The 64 bit Windows Server 2003 SP1 SDK compilers link against MSVCRT.dll, which
767# doesn't include the buffer overrun verification code used by the /GS switch.
768# Since the code links against libraries that are compiled with /GS, this
769# "security cookie verification" code must be included via bufferoverflow.lib.
770ifeq ("$(WIN64) $(CCTYPE)","define SDK2003SP1")
771LIBBASEFILES    += bufferoverflowU.lib
772endif
773
774LIBFILES	= $(LIBBASEFILES) $(LIBC)
775
776EXTRACFLAGS	= -nologo -GF -W3
777ifeq ($(__ICC),define)
778EXTRACFLAGS	+= -Qstd=c99
779endif
780ifeq ($(USE_CPLUSPLUS),define)
781EXTRACFLAGS	+= $(CXX_FLAG)
782endif
783CFLAGS		= $(EXTRACFLAGS) $(INCLUDES) $(DEFINES) $(LOCDEFS) \
784		$(PCHFLAGS) $(OPTIMIZE)
785LINK_FLAGS	= -nologo -nodefaultlib $(LINK_DBG) \
786		-libpath:"$(INST_COREDIR)" \
787		-machine:$(PROCESSOR_ARCHITECTURE)
788LIB_FLAGS	+= -nologo
789OBJOUT_FLAG	= -Fo
790EXEOUT_FLAG	= -Fe
791LIBOUT_FLAG	= /out:
792PDBOUT		= -Fd$(*).pdb
793TESTPREPGCC	=
794
795endif
796
797CFLAGS_O	= $(CFLAGS) $(BUILDOPT)
798
799ifeq ($(PREMSVC80),undef)
800PRIV_LINK_FLAGS	+= "/manifestdependency:type='Win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'"
801else
802RSC_FLAGS	= -DINCLUDE_MANIFEST
803endif
804
805# VS 2017 (VC++ 14.1) requires at minimum Windows 7 SP1 (with latest Windows Updates)
806
807# For XP support in >= VS 2013 (VC++ 12.0), subsystem is always in Config.pm
808# LINK_FLAGS else subsystem is only needed for EXE building, not XS DLL building
809# Console vs GUI makes no difference for DLLs, so use default for cleaner
810# building cmd lines
811
812ifeq ($(CCTYPE),MSVC120)
813ifeq ($(WIN64),define)
814LINK_FLAGS	+= -subsystem:console,"5.02"
815else
816LINK_FLAGS	+= -subsystem:console,"5.01"
817endif
818
819else ifeq ($(CCTYPE),MSVC140)
820ifeq ($(WIN64),define)
821LINK_FLAGS	+= -subsystem:console,"5.02"
822else
823LINK_FLAGS	+= -subsystem:console,"5.01"
824endif
825
826else ifneq ($(CCTYPE),GCC)
827PRIV_LINK_FLAGS	+= -subsystem:console
828endif
829
830BLINK_FLAGS	= $(PRIV_LINK_FLAGS) $(LINK_FLAGS)
831
832#################### do not edit below this line #######################
833############# NO USER-SERVICEABLE PARTS BEYOND THIS POINT ##############
834
835#prevent -j from reaching EUMM/make_ext.pl/"sub makes", Win32 EUMM not parallel
836#compatible yet
837unexport MAKEFLAGS
838
839a ?= .lib
840
841.SUFFIXES : .c .i $(o) .dll $(a) .exe .rc .res
842
843%$(o): %.c
844	$(CC) -c -I$(<D) $(CFLAGS_O) $(OBJOUT_FLAG)$@ $(PDBOUT) $<
845
846%.i: %.c
847	$(CC) -c -I$(<D) $(CFLAGS_O) -E $< >$@
848
849%.c: %.y
850	$(NOOP)
851
852%.dll: %$(o)
853	$(LINK32) -o $@ $(BLINK_FLAGS) $< $(LIBFILES)
854	$(IMPLIB) --input-def $(*F).def --output-lib $(*F).a $@
855
856%.res: %.rc
857ifeq ($(CCTYPE),GCC)
858	$(RSC) --use-temp-file --include-dir=. --include-dir=.. -O COFF -D INCLUDE_MANIFEST -i $< -o $@
859else
860	$(RSC) -i.. -DINCLUDE_MANIFEST $<
861endif
862
863#
864# various targets
865
866#do not put $(MINIPERL) as a dep/prereq in a rule, instead put $(HAVEMINIPERL)
867#$(MINIPERL) is not a buildable target, use "gmake mp" if you want to just build
868#miniperl alone
869MINIPERL	= ..\miniperl.exe
870HAVEMINIPERL	= ..\lib\buildcustomize.pl
871MINIDIR		= mini
872PERLEXE		= ..\perl.exe
873WPERLEXE	= ..\wperl.exe
874PERLEXESTATIC	= ..\perl-static.exe
875STATICDIR	= .\static.tmp
876GLOBEXE		= ..\perlglob.exe
877CONFIGPM	= ..\lib\Config.pm
878GENUUDMAP	= ..\generate_uudmap.exe
879ifeq ($(BUILD_STATIC),define)
880PERLSTATIC	= static
881else
882ifeq ($(ALL_STATIC),define)
883PERLSTATIC	= static
884else
885PERLSTATIC	=
886endif
887endif
888
889# Unicode data files generated by mktables
890UNIDATAFILES	 = ..\lib\unicore\Decomposition.pl ..\lib\unicore\TestProp.pl \
891		   ..\lib\unicore\CombiningClass.pl ..\lib\unicore\Name.pl \
892		   ..\lib\unicore\UCD.pl ..\lib\unicore\Name.pm            \
893		   ..\lib\unicore\Heavy.pl ..\lib\unicore\mktables.lst
894
895# Directories of Unicode data files generated by mktables
896UNIDATADIR1	= ..\lib\unicore\To
897UNIDATADIR2	= ..\lib\unicore\lib
898
899PERLEXE_MANIFEST= .\perlexe.manifest
900PERLEXE_ICO	= .\perlexe.ico
901PERLEXE_RES	= .\perlexe.res
902PERLDLL_RES	=
903
904# Nominate a target which causes extensions to be re-built
905# This used to be $(PERLEXE), but at worst it is the .dll that they depend
906# on and really only the interface - i.e. the .def file used to export symbols
907# from the .dll
908PERLDEP = $(PERLIMPLIB)
909
910
911PL2BAT		= bin\pl2bat.pl
912
913UTILS		=			\
914		..\utils\h2ph		\
915		..\utils\splain		\
916		..\utils\perlbug	\
917		..\utils\pl2pm 		\
918		..\utils\h2xs		\
919		..\utils\perldoc	\
920		..\utils\perlivp	\
921		..\utils\libnetcfg	\
922		..\utils\enc2xs		\
923		..\utils\encguess	\
924		..\utils\piconv		\
925		..\utils\corelist	\
926		..\utils\cpan		\
927		..\utils\xsubpp		\
928		..\utils\pod2html	\
929		..\utils\prove		\
930		..\utils\ptar		\
931		..\utils\ptardiff	\
932		..\utils\ptargrep	\
933		..\utils\zipdetails	\
934		..\utils\shasum		\
935		..\utils\instmodsh	\
936		..\utils\json_pp	\
937		bin\exetype.pl		\
938		bin\runperl.pl		\
939		bin\pl2bat.pl		\
940		bin\perlglob.pl		\
941		bin\search.pl
942
943ifeq ($(CCTYPE),GCC)
944
945CFGSH_TMPL	= config.gc
946CFGH_TMPL	= config_H.gc
947PERLIMPLIB	= $(COREDIR)\libperl528$(a)
948PERLIMPLIBBASE	= libperl528$(a)
949PERLSTATICLIB	= ..\libperl528s$(a)
950INT64		= long long
951
952else
953
954CFGSH_TMPL	= config.vc
955CFGH_TMPL	= config_H.vc
956INT64		= __int64
957
958endif
959
960# makedef.pl must be updated if this changes, and this should normally
961# only change when there is an incompatible revision of the public API.
962PERLIMPLIB	?= $(COREDIR)\perl528$(a)
963PERLIMPLIBBASE	?= perl528$(a)
964PERLEXPLIB	?= $(COREDIR)\perl528.exp
965PERLSTATICLIB	?= ..\perl528s$(a)
966PERLDLL		= ..\perl528.dll
967PERLDLLBASE	= perl528.dll
968
969# don't let "gmake -n all" try to run "miniperl.exe make_ext.pl"
970PLMAKE		= gmake
971
972XCOPY		= xcopy /f /r /i /d /y
973RCOPY		= xcopy /f /r /i /e /d /y
974NOOP		= @rem
975
976#first ones are arrange in compile time order for faster parallel building
977#see #123867 for details
978MICROCORE_SRC	=		\
979		..\toke.c	\
980		..\regcomp.c	\
981		..\regexec.c	\
982		..\op.c		\
983		..\sv.c		\
984		..\pp.c		\
985		..\pp_ctl.c	\
986		..\pp_sys.c	\
987		..\pp_pack.c	\
988		..\pp_hot.c	\
989		..\gv.c		\
990		..\perl.c	\
991		..\utf8.c	\
992		..\dump.c	\
993		..\hv.c		\
994		..\av.c		\
995		..\caretx.c	\
996		..\deb.c	\
997		..\doio.c	\
998		..\doop.c	\
999		..\dquote.c	\
1000		..\globals.c	\
1001		..\mro_core.c	\
1002		..\locale.c	\
1003		..\keywords.c	\
1004		..\mathoms.c    \
1005		..\mg.c		\
1006		..\numeric.c	\
1007		..\pad.c	\
1008		..\perlapi.c	\
1009		..\perly.c	\
1010		..\pp_sort.c	\
1011		..\reentr.c	\
1012		..\run.c	\
1013		..\scope.c	\
1014		..\taint.c	\
1015		..\time64.c	\
1016		..\universal.c	\
1017		..\util.c
1018
1019EXTRACORE_SRC	+= perllib.c
1020
1021ifeq ($(PERL_MALLOC),define)
1022EXTRACORE_SRC	+= ..\malloc.c
1023endif
1024
1025EXTRACORE_SRC	+= ..\perlio.c
1026
1027WIN32_SRC	=		\
1028		.\win32.c	\
1029		.\win32sck.c	\
1030		.\win32thread.c	\
1031		.\fcrypt.c
1032
1033# We need this for miniperl build unless we override canned
1034# config.h #define building mini\*
1035#ifeq ($(USE_PERLIO)" == "define"
1036WIN32_SRC	+= .\win32io.c
1037#endif
1038
1039CORE_NOCFG_H	=		\
1040		..\av.h		\
1041		..\cop.h	\
1042		..\cv.h		\
1043		..\dosish.h	\
1044		..\embed.h	\
1045		..\form.h	\
1046		..\gv.h		\
1047		..\handy.h	\
1048		..\hv.h		\
1049		..\hv_func.h	\
1050		..\iperlsys.h	\
1051		..\mg.h		\
1052		..\nostdio.h	\
1053		..\op.h		\
1054		..\opcode.h	\
1055		..\perl.h	\
1056		..\perlapi.h	\
1057		..\perlsdio.h	\
1058		..\perly.h	\
1059		..\pp.h		\
1060		..\proto.h	\
1061		..\regcomp.h	\
1062		..\regexp.h	\
1063		..\scope.h	\
1064		..\sv.h		\
1065		..\thread.h	\
1066		..\unixish.h	\
1067		..\utf8.h	\
1068		..\util.h	\
1069		..\warnings.h	\
1070		..\XSUB.h	\
1071		..\EXTERN.h	\
1072		..\perlvars.h	\
1073		..\intrpvar.h	\
1074		.\include\dirent.h	\
1075		.\include\netdb.h	\
1076		.\include\sys\errno2.h	\
1077		.\include\sys\socket.h	\
1078		.\win32.h
1079
1080CORE_H		= $(CORE_NOCFG_H) .\config.h ..\git_version.h
1081
1082UUDMAP_H	= ..\uudmap.h
1083BITCOUNT_H	= ..\bitcount.h
1084MG_DATA_H	= ..\mg_data.h
1085GENERATED_HEADERS = $(UUDMAP_H) $(BITCOUNT_H) $(MG_DATA_H)
1086
1087HAVE_COREDIR	= .coreheaders
1088
1089MICROCORE_OBJ	= $(MICROCORE_SRC:.c=$(o))
1090CORE_OBJ	= $(MICROCORE_OBJ) $(EXTRACORE_SRC:.c=$(o))
1091WIN32_OBJ	= $(WIN32_SRC:.c=$(o))
1092
1093MINICORE_OBJ	= $(subst ..\,mini\,$(MICROCORE_OBJ))	\
1094		  $(MINIDIR)\miniperlmain$(o)	\
1095		  $(MINIDIR)\perlio$(o)
1096MINIWIN32_OBJ	= $(subst .\,mini\,$(WIN32_OBJ))
1097MINI_OBJ	= $(MINICORE_OBJ) $(MINIWIN32_OBJ)
1098DLL_OBJ		= $(DYNALOADER)
1099
1100PERLDLL_OBJ	= $(CORE_OBJ)
1101PERLEXE_OBJ	= perlmain$(o)
1102PERLEXEST_OBJ	= perlmainst$(o)
1103
1104PERLDLL_OBJ	+= $(WIN32_OBJ) $(DLL_OBJ)
1105
1106ifneq ($(USE_SETARGV),)
1107SETARGV_OBJ	= setargv$(o)
1108endif
1109
1110ifeq ($(ALL_STATIC),define)
1111# some exclusions, unfortunately, until fixed:
1112#  - MakeMaker isn't capable enough for SDBM_File (small bug)
1113STATIC_EXT	= * !SDBM_File
1114NORMALIZE_STATIC = Normalize_static
1115else
1116# specify static extensions here, for example:
1117# (be sure to include Win32CORE to load Win32 on demand)
1118#STATIC_EXT	= Win32CORE Cwd Compress/Raw/Zlib
1119STATIC_EXT	= Win32CORE
1120NORMALIZE_DYN	= Normalize_dyn
1121endif
1122
1123DYNALOADER	= ..\DynaLoader$(o)
1124
1125# vars must be separated by "\t+~\t+", since we're using the tempfile
1126# version of config_sh.pl (we were overflowing someone's buffer by
1127# trying to fit them all on the command line)
1128#	-- BKS 10-17-1999
1129CFG_VARS	=					\
1130		"INST_TOP=$(INST_TOP)"			\
1131		"INST_VER=$(INST_VER)"			\
1132		"INST_ARCH=$(INST_ARCH)"		\
1133		"archname=$(ARCHNAME)"			\
1134		"cc=$(CC)"				\
1135		"ld=$(LINK32)"				\
1136		"ccflags=$(subst ",\",$(EXTRACFLAGS) $(OPTIMIZE) $(DEFINES) $(BUILDOPT))" \
1137		"usecplusplus=$(USE_CPLUSPLUS)"		\
1138		"cf_email=$(EMAIL)"			\
1139		"d_mymalloc=$(PERL_MALLOC)"		\
1140		"libs=$(LIBFILES)"			\
1141		"incpath=$(subst ",\",$(CCINCDIR))"			\
1142		"libperl=$(subst ",\",$(PERLIMPLIBBASE))"		\
1143		"libpth=$(subst ",\",$(CCLIBDIR);$(EXTRALIBDIRS))"	\
1144		"libc=$(LIBC)"				\
1145		"make=$(PLMAKE)"				\
1146		"_o=$(o)"				\
1147		"obj_ext=$(o)"				\
1148		"_a=$(a)"				\
1149		"lib_ext=$(a)"				\
1150		"static_ext=$(STATIC_EXT)"		\
1151		"usethreads=$(USE_ITHREADS)"		\
1152		"useithreads=$(USE_ITHREADS)"		\
1153		"usemultiplicity=$(USE_MULTI)"		\
1154		"useperlio=$(USE_PERLIO)"		\
1155		"use64bitint=$(USE_64_BIT_INT)"		\
1156		"uselongdouble=$(USE_LONG_DOUBLE)"	\
1157		"uselargefiles=$(USE_LARGE_FILES)"	\
1158		"usesitecustomize=$(USE_SITECUST)"	\
1159		"default_inc_excludes_dot=$(DEFAULT_INC_EXCLUDES_DOT)"	\
1160		"LINK_FLAGS=$(subst ",\",$(LINK_FLAGS))"\
1161		"optimize=$(subst ",\",$(OPTIMIZE))"	\
1162		"ARCHPREFIX=$(ARCHPREFIX)"		\
1163		"WIN64=$(WIN64)"
1164
1165#
1166# Top targets
1167#
1168
1169.PHONY: all info
1170
1171all : info rebasePE Extensions_nonxs $(PERLSTATIC) PostExt
1172
1173info :
1174	@echo # CCTYPE=$(CCTYPE)
1175ifeq ($(CCTYPE),GCC)
1176	@echo # GCCBIN=$(GCCBIN)
1177	@echo # GCCVER=$(GCCVER1).$(GCCVER2).$(GCCVER3)
1178	@echo # GCCTARGET=$(GCCTARGET)
1179	@echo # GCCCROSS=$(GCCCROSS)
1180endif
1181	@echo # WIN64=$(WIN64)
1182	@echo # ARCHITECTURE=$(ARCHITECTURE)
1183	@echo # ARCHNAME=$(ARCHNAME)
1184	@echo # MAKE=$(PLMAKE)
1185ifeq ($(CCTYPE),)
1186	@echo Unable to detect gcc and/or architecture!
1187	@exit 1
1188endif
1189
1190
1191..\regcomp$(o) : ..\regnodes.h ..\regcharclass.h
1192
1193..\regexec$(o) : ..\regnodes.h ..\regcharclass.h
1194
1195reonly : ..\regnodes.h .\config.h ..\git_version.h $(GLOBEXE) $(HAVEMINIPERL)\
1196	$(CONFIGPM) $(UNIDATAFILES) $(PERLEXE)				\
1197	Extensions_reonly
1198
1199static: $(PERLEXESTATIC)
1200
1201#----------------------------------------------------------------
1202
1203$(GLOBEXE) : perlglob.c
1204ifeq ($(CCTYPE),GCC)
1205	$(LINK32) $(OPTIMIZE) $(BLINK_FLAGS) -mconsole -o $@ perlglob.c $(LIBFILES)
1206else
1207	$(CC) $(OPTIMIZE) $(PDBOUT) -Fe$@ perlglob.c -link $(BLINK_FLAGS) \
1208	setargv$(o) $(LIBFILES) && $(EMBED_EXE_MANI)
1209endif
1210
1211..\git_version.h : $(HAVEMINIPERL) ..\make_patchnum.pl
1212	$(MINIPERL) -I..\lib ..\make_patchnum.pl
1213
1214# make sure that we recompile perl.c if the git version changes
1215..\perl$(o) : ..\git_version.h
1216
1217..\config.sh : $(CFGSH_TMPL) config_sh.PL FindExt.pm $(HAVEMINIPERL)
1218	$(MINIPERL) -I..\lib config_sh.PL $(CFG_VARS) $(CFGSH_TMPL) > ..\config.sh
1219
1220# This target is for when changes to the main config.sh happen.
1221# Edit config.gc, then make perl using GCC in a minimal configuration (i.e.
1222# with MULTI, ITHREADS, IMP_SYS, LARGE_FILES and PERLIO off), then make
1223# this target to regenerate config_H.gc.
1224regen_config_h:
1225	$(MINIPERL) -I..\lib config_sh.PL $(CFG_VARS) $(CFGSH_TMPL) > ..\config.sh
1226	$(MINIPERL) -I..\lib ..\configpm --chdir=..
1227	-del /f $(CFGH_TMPL)
1228	-$(MINIPERL) -I..\lib config_h.PL "ARCHPREFIX=$(ARCHPREFIX)"
1229	rename config.h $(CFGH_TMPL)
1230
1231$(CONFIGPM): ..\config.sh config_h.PL
1232	$(MINIPERL) -I..\lib ..\configpm --chdir=..
1233	-$(MINIPERL) -I..\lib config_h.PL "ARCHPREFIX=$(ARCHPREFIX)"
1234
1235.\config.h : $(CONFIGPM)
1236
1237# See the comment in Makefile.SH explaining this seemingly cranky ordering
1238..\lib\buildcustomize.pl : $(MINI_OBJ) ..\write_buildcustomize.pl
1239ifeq ($(CCTYPE),GCC)
1240	$(LINK32) -mconsole -o $(MINIPERL) $(BLINK_FLAGS) $(MINI_OBJ) $(LIBFILES)
1241else
1242	$(LINK32) -out:$(MINIPERL) $(BLINK_FLAGS) \
1243	    $(DELAYLOAD) $(MINIDELAYLOAD) $(LIBFILES) $(MINI_OBJ)
1244	$(subst $@,$(MINIPERL),$(EMBED_EXE_MANI))
1245
1246endif
1247	$(MINIPERL) -I..\lib -f ..\write_buildcustomize.pl ..
1248
1249#convinence target, get a working miniperl
1250mp : $(CONFIGPM)
1251
1252$(MINIDIR)\.exists : $(CFGH_TMPL)
1253	if not exist "$(MINIDIR)" mkdir "$(MINIDIR)"
1254#
1255# Copy the template config.h and set configurables at the end of it
1256# as per the options chosen and compiler used.
1257# Note: This config.h is only used to build miniperl.exe anyway, but
1258# it's as well to have its options correct to be sure that it builds
1259# and so that it's "-V" options are correct for use by makedef.pl. The
1260# real config.h used to build perl.exe is generated from the top-level
1261# config_h.SH by config_h.PL (run by miniperl.exe).
1262#
1263# MINIDIR generates config.h so miniperl.exe is not rebuilt when the 2nd
1264# config.h is generated in CONFIGPM target, see also the comments for $(MINI_OBJ).
1265	copy $(CFGH_TMPL) config.h
1266	@(echo.&& \
1267	echo #ifndef _config_h_footer_&& \
1268	echo #define _config_h_footer_&& \
1269	echo #undef Off_t&& \
1270	echo #undef LSEEKSIZE&& \
1271	echo #undef Off_t_size&& \
1272	echo #undef PTRSIZE&& \
1273	echo #undef SSize_t&& \
1274	echo #undef HAS_ATOLL&& \
1275	echo #undef HAS_STRTOLL&& \
1276	echo #undef HAS_STRTOULL&& \
1277	echo #undef Size_t_size&& \
1278	echo #undef IVTYPE&& \
1279	echo #undef UVTYPE&& \
1280	echo #undef IVSIZE&& \
1281	echo #undef UVSIZE&& \
1282	echo #undef NV_PRESERVES_UV&& \
1283	echo #undef NV_PRESERVES_UV_BITS&& \
1284	echo #undef IVdf&& \
1285	echo #undef UVuf&& \
1286	echo #undef UVof&& \
1287	echo #undef UVxf&& \
1288	echo #undef UVXf&& \
1289	echo #undef USE_64_BIT_INT&& \
1290	echo #undef Gconvert&& \
1291	echo #undef HAS_FREXPL&& \
1292	echo #undef HAS_ISNANL&& \
1293	echo #undef HAS_MODFL&& \
1294	echo #undef HAS_MODFL_PROTO&& \
1295	echo #undef HAS_SQRTL&& \
1296	echo #undef HAS_STRTOLD&& \
1297	echo #undef PERL_PRIfldbl&& \
1298	echo #undef PERL_PRIgldbl&& \
1299	echo #undef PERL_PRIeldbl&& \
1300	echo #undef PERL_SCNfldbl&& \
1301	echo #undef NVTYPE&& \
1302	echo #undef NVSIZE&& \
1303	echo #undef LONG_DOUBLESIZE&& \
1304	echo #undef NV_OVERFLOWS_INTEGERS_AT&& \
1305	echo #undef NVef&& \
1306	echo #undef NVff&& \
1307	echo #undef NVgf&& \
1308	echo #undef USE_LONG_DOUBLE)>> config.h
1309ifeq ($(CCTYPE),MSVC140)
1310	@(echo #undef FILE_ptr&& \
1311	echo #undef FILE_cnt&& \
1312	echo #undef FILE_base&& \
1313	echo #undef FILE_bufsiz&& \
1314	echo #define FILE_ptr^(fp^) PERLIO_FILE_ptr^(fp^)&& \
1315	echo #define FILE_cnt^(fp^) PERLIO_FILE_cnt^(fp^)&& \
1316	echo #define FILE_base^(fp^) PERLIO_FILE_base^(fp^)&& \
1317	echo #define FILE_bufsiz^(fp^) ^(PERLIO_FILE_cnt^(fp^) + PERLIO_FILE_ptr^(fp^) - PERLIO_FILE_base^(fp^)^)&& \
1318	echo #define I_STDBOOL)>> config.h
1319else ifeq ($(CCTYPE),MSVC141)
1320	@(echo #undef FILE_ptr&& \
1321	echo #undef FILE_cnt&& \
1322	echo #undef FILE_base&& \
1323	echo #undef FILE_bufsiz&& \
1324	echo #define FILE_ptr^(fp^) PERLIO_FILE_ptr^(fp^)&& \
1325	echo #define FILE_cnt^(fp^) PERLIO_FILE_cnt^(fp^)&& \
1326	echo #define FILE_base^(fp^) PERLIO_FILE_base^(fp^)&& \
1327	echo #define FILE_bufsiz^(fp^) ^(PERLIO_FILE_cnt^(fp^) + PERLIO_FILE_ptr^(fp^) - PERLIO_FILE_base^(fp^)^)&& \
1328	echo #define I_STDBOOL)>> config.h
1329endif
1330ifeq ($(USE_LARGE_FILES),define)
1331	@(echo #define Off_t $(INT64)&& \
1332	echo #define LSEEKSIZE ^8&& \
1333	echo #define Off_t_size ^8)>> config.h
1334else
1335	@(echo #define Off_t long&& \
1336	echo #define LSEEKSIZE ^4&& \
1337	echo #define Off_t_size ^4)>> config.h
1338endif
1339ifeq ($(WIN64),define)
1340ifeq ($(CCTYPE),GCC)
1341	@(echo #define LONG_DOUBLESIZE ^16)>> config.h
1342else
1343	@(echo #define LONG_DOUBLESIZE ^8)>> config.h
1344endif
1345	@(echo #define PTRSIZE ^8&& \
1346	echo #define SSize_t $(INT64)&& \
1347	echo #define HAS_ATOLL&& \
1348	echo #define HAS_STRTOLL&& \
1349	echo #define HAS_STRTOULL&& \
1350	echo #define Size_t_size ^8)>> config.h
1351else
1352ifeq ($(CCTYPE),GCC)
1353	@(echo #define LONG_DOUBLESIZE ^12)>> config.h
1354else
1355	@(echo #define LONG_DOUBLESIZE ^8)>> config.h
1356endif
1357	@(echo #define PTRSIZE ^4&& \
1358	echo #define SSize_t int&& \
1359	echo #undef HAS_ATOLL&& \
1360	echo #undef HAS_STRTOLL&& \
1361	echo #undef HAS_STRTOULL&& \
1362	echo #define Size_t_size ^4)>> config.h
1363endif
1364ifeq ($(USE_64_BIT_INT),define)
1365	@(echo #define IVTYPE $(INT64)&& \
1366	echo #define UVTYPE unsigned $(INT64)&& \
1367	echo #define IVSIZE ^8&& \
1368	echo #define UVSIZE ^8)>> config.h
1369ifeq ($(USE_LONG_DOUBLE),define)
1370	@(echo #define NV_PRESERVES_UV&& \
1371	echo #define NV_PRESERVES_UV_BITS 64)>> config.h
1372else
1373	@(echo #undef NV_PRESERVES_UV&& \
1374	echo #define NV_PRESERVES_UV_BITS 53)>> config.h
1375endif
1376	@(echo #define IVdf "I64d"&& \
1377	echo #define UVuf "I64u"&& \
1378	echo #define UVof "I64o"&& \
1379	echo #define UVxf "I64x"&& \
1380	echo #define UVXf "I64X"&& \
1381	echo #define USE_64_BIT_INT)>> config.h
1382else
1383	@(echo #define IVTYPE long&& \
1384	echo #define UVTYPE unsigned long&& \
1385	echo #define IVSIZE ^4&& \
1386	echo #define UVSIZE ^4&& \
1387	echo #define NV_PRESERVES_UV&& \
1388	echo #define NV_PRESERVES_UV_BITS 32&& \
1389	echo #define IVdf "ld"&& \
1390	echo #define UVuf "lu"&& \
1391	echo #define UVof "lo"&& \
1392	echo #define UVxf "lx"&& \
1393	echo #define UVXf "lX"&& \
1394	echo #undef USE_64_BIT_INT)>> config.h
1395endif
1396ifeq ($(USE_LONG_DOUBLE),define)
1397	@(echo #define Gconvert^(x,n,t,b^) sprintf^(^(b^),"%%.*""Lg",^(n^),^(x^)^)&& \
1398	echo #define HAS_FREXPL&& \
1399	echo #define HAS_ISNANL&& \
1400	echo #define HAS_MODFL&& \
1401	echo #define HAS_MODFL_PROTO&& \
1402	echo #define HAS_SQRTL&& \
1403	echo #define HAS_STRTOLD&& \
1404	echo #define PERL_PRIfldbl "Lf"&& \
1405	echo #define PERL_PRIgldbl "Lg"&& \
1406	echo #define PERL_PRIeldbl "Le"&& \
1407	echo #define PERL_SCNfldbl "Lf"&& \
1408	echo #define NVTYPE long double&& \
1409	echo #define NVSIZE LONG_DOUBLESIZE&& \
1410	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&& \
1411	echo #define NVef "Le"&& \
1412	echo #define NVff "Lf"&& \
1413	echo #define NVgf "Lg"&& \
1414	echo #define USE_LONG_DOUBLE)>> config.h
1415else
1416	@(echo #define Gconvert^(x,n,t,b^) sprintf^(^(b^),"%%.*g",^(n^),^(x^)^)&& \
1417	echo #undef HAS_FREXPL&& \
1418	echo #undef HAS_ISNANL&& \
1419	echo #undef HAS_MODFL&& \
1420	echo #undef HAS_MODFL_PROTO&& \
1421	echo #undef HAS_SQRTL&& \
1422	echo #undef HAS_STRTOLD&& \
1423	echo #undef PERL_PRIfldbl&& \
1424	echo #undef PERL_PRIgldbl&& \
1425	echo #undef PERL_PRIeldbl&& \
1426	echo #undef PERL_SCNfldbl&& \
1427	echo #define NVTYPE double&& \
1428	echo #define NVSIZE ^8&& \
1429	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&& \
1430	echo #define NVef "e"&& \
1431	echo #define NVff "f"&& \
1432	echo #define NVgf "g"&& \
1433	echo #undef USE_LONG_DOUBLE)>> config.h
1434endif
1435ifeq ($(USE_CPLUSPLUS),define)
1436	@(echo #define USE_CPLUSPLUS&& \
1437	echo #endif)>> config.h
1438else
1439	@(echo #undef USE_CPLUSPLUS&& \
1440	echo #endif)>> config.h
1441endif
1442#separate line since this is sentinal that this target is done
1443	rem. > $(MINIDIR)\.exists
1444
1445$(MINICORE_OBJ) : $(CORE_NOCFG_H)
1446	$(CC) -c $(CFLAGS) $(MINIBUILDOPT) -DPERL_EXTERNAL_GLOB -DPERL_IS_MINIPERL $(OBJOUT_FLAG)$@ $(PDBOUT) ..\$(*F).c
1447
1448$(MINIWIN32_OBJ) : $(CORE_NOCFG_H)
1449	$(CC) -c $(CFLAGS) $(MINIBUILDOPT) -DPERL_IS_MINIPERL $(OBJOUT_FLAG)$@ $(PDBOUT) $(*F).c
1450
1451# -DPERL_IMPLICIT_SYS needs C++ for perllib.c
1452# rules wrapped in .IFs break Win9X build (we end up with unbalanced []s unless
1453# unless the .IF is true), so instead we use a .ELSE with the default.
1454# This is the only file that depends on perlhost.h, vmem.h, and vdir.h
1455
1456perllib$(o)	: perllib.c perllibst.h .\perlhost.h .\vdir.h .\vmem.h
1457ifeq ($(USE_IMP_SYS),define)
1458	$(CC) -c -I. $(CFLAGS_O) $(CXX_FLAG) $(OBJOUT_FLAG)$@ $(PDBOUT) perllib.c
1459else
1460	$(CC) -c -I. $(CFLAGS_O) $(OBJOUT_FLAG)$@ $(PDBOUT) perllib.c
1461endif
1462
1463# 1. we don't want to rebuild miniperl.exe when config.h changes
1464# 2. we don't want to rebuild miniperl.exe with non-default config.h
1465# 3. we can't have miniperl.exe depend on git_version.h, as miniperl creates it
1466$(MINI_OBJ)	: $(MINIDIR)\.exists $(CORE_NOCFG_H)
1467
1468$(WIN32_OBJ)	: $(CORE_H)
1469
1470$(CORE_OBJ)	: $(CORE_H)
1471
1472$(DLL_OBJ)	: $(CORE_H)
1473
1474
1475perllibst.h : $(HAVEMINIPERL) $(CONFIGPM) create_perllibst_h.pl
1476	$(MINIPERL) -I..\lib create_perllibst_h.pl
1477
1478perldll.def : $(HAVEMINIPERL) $(CONFIGPM) ..\embed.fnc ..\makedef.pl
1479	$(MINIPERL) -I..\lib -w ..\makedef.pl PLATFORM=win32 $(OPTIMIZE) $(DEFINES) \
1480	$(BUILDOPT) CCTYPE=$(CCTYPE) TARG_DIR=..\ > perldll.def
1481
1482$(PERLEXPLIB) : $(PERLIMPLIB)
1483
1484$(PERLIMPLIB) : perldll.def
1485ifeq ($(CCTYPE),GCC)
1486	$(IMPLIB) -k -d perldll.def -D $(PERLDLLBASE) -l $(PERLIMPLIB) -e $(PERLEXPLIB)
1487else
1488	lib -def:perldll.def -machine:$(ARCHITECTURE) /OUT:$(PERLIMPLIB)
1489endif
1490
1491$(PERLDLL): $(PERLEXPLIB) $(PERLDLL_OBJ) $(PERLDLL_RES) Extensions_static
1492ifeq ($(CCTYPE),GCC)
1493	$(LINK32) -mdll -o $@ $(BLINK_FLAGS) \
1494	   $(PERLDLL_OBJ) $(shell type Extensions_static) $(LIBFILES) $(PERLEXPLIB)
1495else
1496	$(LINK32) -dll -out:$@ $(BLINK_FLAGS) \
1497	    @Extensions_static \
1498	    -base:0x28000000 $(DELAYLOAD) $(LIBFILES) \
1499	    $(PERLDLL_RES) $(PERLDLL_OBJ) $(PERLEXPLIB)
1500	$(EMBED_DLL_MANI)
1501endif
1502
1503$(PERLSTATICLIB): $(PERLDLL_OBJ) Extensions_static
1504ifeq ($(CCTYPE),GCC)
1505	$(LIB32) $(LIB_FLAGS) $@ $(PERLDLL_OBJ)
1506	if exist $(STATICDIR) rmdir /s /q $(STATICDIR)
1507	for %%i in ($(shell type Extensions_static)) do \
1508		@mkdir $(STATICDIR) && cd $(STATICDIR) && \
1509		$(ARCHPREFIX)ar x ..\%%i && \
1510		$(ARCHPREFIX)ar q ..\$@ *$(o) && \
1511		cd .. && rmdir /s /q $(STATICDIR)
1512else
1513	$(LIB32) $(LIB_FLAGS) -out:$@ @Extensions_static \
1514	    $(PERLDLL_OBJ)
1515endif
1516	$(XCOPY) $(PERLSTATICLIB) $(COREDIR)
1517
1518$(PERLEXE_RES): perlexe.rc $(PERLEXE_MANIFEST) $(PERLEXE_ICO)
1519
1520$(MINIDIR)\globals$(o) : $(GENERATED_HEADERS)
1521
1522$(UUDMAP_H) $(MG_DATA_H) : $(BITCOUNT_H)
1523
1524$(BITCOUNT_H) : $(GENUUDMAP)
1525	$(GENUUDMAP) $(GENERATED_HEADERS)
1526
1527$(GENUUDMAP) : ..\mg_raw.h
1528ifeq ($(CCTYPE),GCC)
1529	$(LINK32) $(CFLAGS_O) -o..\generate_uudmap.exe ..\generate_uudmap.c \
1530	$(BLINK_FLAGS) $(LIBFILES)
1531else
1532	$(CC) $(CFLAGS_O) $(PDBOUT) -Fe..\generate_uudmap.exe ..\generate_uudmap.c -link $(LIBFILES) $(BLINK_FLAGS)
1533	$(EMBED_EXE_MANI)
1534endif
1535
1536.PHONY: MakePPPort
1537
1538MakePPPort : $(HAVEMINIPERL) $(CONFIGPM)
1539	$(MINIPERL) -I..\lib ..\mkppport
1540
1541# also known as $(HAVE_COREDIR)
1542.coreheaders : $(CORE_H)
1543	$(XCOPY) *.h $(COREDIR)\\*.*
1544	$(RCOPY) include $(COREDIR)\\*.*
1545	$(XCOPY) ..\\*.h $(COREDIR)\\*.*
1546	rem. > $@
1547
1548perlmain$(o) : runperl.c $(CONFIGPM)
1549	$(CC) $(subst -DPERLDLL,-UPERLDLL,$(CFLAGS_O)) $(OBJOUT_FLAG)$@ $(PDBOUT) -c runperl.c
1550
1551perlmainst$(o) : runperl.c $(CONFIGPM)
1552	$(CC) $(CFLAGS_O) $(OBJOUT_FLAG)$@ $(PDBOUT) -c runperl.c
1553
1554$(PERLEXE): $(CONFIGPM) $(PERLEXE_OBJ) $(PERLEXE_RES) $(PERLIMPLIB)
1555ifeq ($(CCTYPE),GCC)
1556	$(LINK32) -mconsole -o $@ $(BLINK_FLAGS)  \
1557	    $(PERLEXE_OBJ) $(PERLEXE_RES) $(PERLIMPLIB) $(LIBFILES)
1558else
1559	$(LINK32) -out:$@ $(BLINK_FLAGS) \
1560	    $(PERLEXE_OBJ) $(PERLEXE_RES) $(PERLIMPLIB) $(LIBFILES) $(SETARGV_OBJ)
1561	$(EMBED_EXE_MANI)
1562endif
1563	copy $(PERLEXE) $(WPERLEXE)
1564	$(MINIPERL) -I..\lib bin\exetype.pl $(WPERLEXE) WINDOWS
1565
1566$(PERLEXESTATIC): $(PERLSTATICLIB) $(CONFIGPM) $(PERLEXEST_OBJ) $(PERLEXE_RES)
1567ifeq ($(CCTYPE),GCC)
1568	$(LINK32) -mconsole -o $@ $(BLINK_FLAGS) \
1569	    $(PERLEXEST_OBJ) $(PERLEXE_RES) $(PERLSTATICLIB) $(LIBFILES)
1570else
1571	$(LINK32) -out:$@ $(BLINK_FLAGS) \
1572	    $(PERLEXEST_OBJ) $(PERLEXE_RES) $(PERLSTATICLIB) $(LIBFILES) $(SETARGV_OBJ)
1573	$(EMBED_EXE_MANI)
1574endif
1575
1576#-------------------------------------------------------------------------------
1577# There's no direct way to mark a dependency on
1578# DynaLoader.pm, so this will have to do
1579
1580#most of deps of this target are in DYNALOADER and therefore omitted here
1581Extensions : $(PERLDEP) $(DYNALOADER) Extension_lib $(GLOBEXE) MakePPPort
1582	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic !Unicode/Normalize
1583
1584Normalize_static : $(CONFIGPM) $(GLOBEXE) $(HAVE_COREDIR) $(UNIDATAFILES)
1585	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --static +Unicode/Normalize
1586
1587Normalize_dyn : $(PERLDEP) $(DYNALOADER) $(GLOBEXE) $(UNIDATAFILES)
1588	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic +Unicode/Normalize
1589
1590Extensions_reonly : $(PERLDEP) $(DYNALOADER)
1591	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --dynamic +re
1592
1593Exts_static_general : ..\make_ext.pl $(CONFIGPM) Extension_lib $(GLOBEXE) $(HAVE_COREDIR) MakePPPort
1594	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --static !Unicode/Normalize
1595
1596Extensions_static : list_static_libs.pl Exts_static_general $(NORMALIZE_STATIC)
1597	$(MINIPERL) -I..\lib list_static_libs.pl > Extensions_static
1598
1599Extensions_nonxs : ..\make_ext.pl ..\pod\perlfunc.pod $(CONFIGPM) $(GLOBEXE)
1600	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --nonxs !libs
1601
1602Extension_lib : ..\make_ext.pl $(CONFIGPM)
1603	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) lib
1604
1605#lib must be built, it can't be buildcustomize.pl-ed, and is required for XS building
1606$(DYNALOADER) : ..\make_ext.pl $(CONFIGPM) $(HAVE_COREDIR)
1607	$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(EXTDIR) --dir=$(DISTDIR) --dynaloader
1608
1609Extensions_clean :
1610	-if exist $(MINIPERL) $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --all --target=clean
1611
1612Extensions_realclean :
1613	-if exist $(MINIPERL) $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --all --target=realclean
1614
1615PostExt : ..\lib\Storable\Limit.pm
1616
1617# we need the exe, perl(ver).dll, and the Exporter, Storable, Win32 extensions
1618# rebasePE most of that, including adjustment for static builds, so we
1619# just need non-xs extensions
1620..\lib\Storable\Limit.pm : rebasePE Extensions_nonxs
1621	$(PLMAKE) -C ..\dist\Storable lib\Storable\Limit.pm
1622	if not exist ..\lib\Storable mkdir ..\lib\Storable
1623	copy ..\dist\Storable\lib\Storable\Limit.pm ..\lib\Storable\Limit.pm
1624
1625# all PE files need to be built by the time this target runs, PP files can still
1626# be running in parallel like UNIDATAFILES, this target a placeholder for the
1627# future
1628ifeq ($(PERLSTATIC),static)
1629rebasePE : Extensions $(PERLDLL) $(PERLEXE) $(PERLEXESTATIC)
1630else
1631rebasePE : Extensions $(PERLDLL) $(NORMALIZE_DYN) $(PERLEXE)
1632endif
1633	$(NOOP)
1634
1635#-------------------------------------------------------------------------------
1636
1637doc: $(PERLEXE) $(PERLDLL) ..\pod\perltoc.pod
1638	$(PERLEXE) -I..\lib ..\installhtml --podroot=.. --htmldir=$(HTMLDIR) \
1639	    --podpath=pod:lib:utils --htmlroot="file://$(subst :,|,$(INST_HTML))"\
1640	    --recurse
1641
1642..\utils\Makefile: $(CONFIGPM) ..\utils\Makefile.PL
1643	$(MINIPERL) -I..\lib ..\utils\Makefile.PL ..
1644
1645# Note that this next section is parsed (and regenerated) by pod/buildtoc
1646# so please check that script before making structural changes here
1647utils: $(HAVEMINIPERL) ..\utils\Makefile
1648	cd ..\utils && $(PLMAKE) PERL=$(MINIPERL)
1649	copy ..\README.aix      ..\pod\perlaix.pod
1650	copy ..\README.amiga    ..\pod\perlamiga.pod
1651	copy ..\README.android  ..\pod\perlandroid.pod
1652	copy ..\README.bs2000   ..\pod\perlbs2000.pod
1653	copy ..\README.ce       ..\pod\perlce.pod
1654	copy ..\README.cn       ..\pod\perlcn.pod
1655	copy ..\README.cygwin   ..\pod\perlcygwin.pod
1656	copy ..\README.dos      ..\pod\perldos.pod
1657	copy ..\README.freebsd  ..\pod\perlfreebsd.pod
1658	copy ..\README.haiku    ..\pod\perlhaiku.pod
1659	copy ..\README.hpux     ..\pod\perlhpux.pod
1660	copy ..\README.hurd     ..\pod\perlhurd.pod
1661	copy ..\README.irix     ..\pod\perlirix.pod
1662	copy ..\README.jp       ..\pod\perljp.pod
1663	copy ..\README.ko       ..\pod\perlko.pod
1664	copy ..\README.linux    ..\pod\perllinux.pod
1665	copy ..\README.macos    ..\pod\perlmacos.pod
1666	copy ..\README.macosx   ..\pod\perlmacosx.pod
1667	copy ..\README.netware  ..\pod\perlnetware.pod
1668	copy ..\README.openbsd  ..\pod\perlopenbsd.pod
1669	copy ..\README.os2      ..\pod\perlos2.pod
1670	copy ..\README.os390    ..\pod\perlos390.pod
1671	copy ..\README.os400    ..\pod\perlos400.pod
1672	copy ..\README.plan9    ..\pod\perlplan9.pod
1673	copy ..\README.qnx      ..\pod\perlqnx.pod
1674	copy ..\README.riscos   ..\pod\perlriscos.pod
1675	copy ..\README.solaris  ..\pod\perlsolaris.pod
1676	copy ..\README.symbian  ..\pod\perlsymbian.pod
1677	copy ..\README.synology ..\pod\perlsynology.pod
1678	copy ..\README.tru64    ..\pod\perltru64.pod
1679	copy ..\README.tw       ..\pod\perltw.pod
1680	copy ..\README.vos      ..\pod\perlvos.pod
1681	copy ..\README.win32    ..\pod\perlwin32.pod
1682	copy ..\pod\perldelta.pod ..\pod\perl5281delta.pod
1683	$(MINIPERL) -I..\lib $(PL2BAT) $(UTILS)
1684	$(MINIPERL) -I..\lib ..\autodoc.pl ..
1685	$(MINIPERL) -I..\lib ..\pod\perlmodlib.PL -q ..
1686
1687..\pod\perltoc.pod: $(PERLEXE) $(PERLDLL) Extensions Extensions_nonxs $(NORMALIZE_DYN) utils
1688	$(PERLEXE) -f ..\pod\buildtoc -q
1689
1690# Note that the pod cleanup in this next section is parsed (and regenerated
1691# by pod/buildtoc so please check that script before making changes here
1692
1693distclean: realclean
1694	-del /f $(MINIPERL) $(PERLEXE) $(PERLDLL) $(GLOBEXE) \
1695		$(PERLIMPLIB) ..\miniperl$(a) $(PERLEXESTATIC) $(PERLSTATICLIB)
1696	-del /f $(LIBDIR)\Encode.pm $(LIBDIR)\encoding.pm $(LIBDIR)\Errno.pm
1697	-del /f $(LIBDIR)\Config.pod $(LIBDIR)\POSIX.pod $(LIBDIR)\threads.pm
1698	-del /f $(LIBDIR)\.exists $(LIBDIR)\attributes.pm $(LIBDIR)\DynaLoader.pm
1699	-del /f $(LIBDIR)\Fcntl.pm $(LIBDIR)\IO.pm $(LIBDIR)\Opcode.pm
1700	-del /f $(LIBDIR)\ops.pm $(LIBDIR)\Safe.pm
1701	-del /f $(LIBDIR)\SDBM_File.pm $(LIBDIR)\Socket.pm $(LIBDIR)\POSIX.pm
1702	-del /f $(LIBDIR)\B.pm $(LIBDIR)\O.pm $(LIBDIR)\re.pm
1703	-del /f $(LIBDIR)\File\Glob.pm
1704	-del /f $(LIBDIR)\Sys\Hostname.pm
1705	-del /f $(LIBDIR)\Time\HiRes.pm
1706	-del /f $(LIBDIR)\Unicode\Normalize.pm
1707	-del /f $(LIBDIR)\Math\BigInt\FastCalc.pm
1708	-del /f $(LIBDIR)\Storable.pm $(LIBDIR)\Storable\Limit.pm
1709	-del /f $(LIBDIR)\Win32.pm
1710	-del /f $(LIBDIR)\Win32CORE.pm
1711	-del /f $(LIBDIR)\Win32API\File.pm
1712	-del /f $(LIBDIR)\Win32API\File\cFile.pc
1713	-del /f $(LIBDIR)\buildcustomize.pl
1714	-del /f $(DISTDIR)\XSLoader\XSLoader.pm
1715	-del /f *.def *.map
1716	-if exist $(LIBDIR)\Amiga rmdir /s /q $(LIBDIR)\Amiga
1717	-if exist $(LIBDIR)\App rmdir /s /q $(LIBDIR)\App
1718	-if exist $(LIBDIR)\Archive rmdir /s /q $(LIBDIR)\Archive
1719	-if exist $(LIBDIR)\Attribute rmdir /s /q $(LIBDIR)\Attribute
1720	-if exist $(LIBDIR)\autodie rmdir /s /q $(LIBDIR)\autodie
1721	-if exist $(LIBDIR)\Carp rmdir /s /q $(LIBDIR)\Carp
1722	-if exist $(LIBDIR)\Compress rmdir /s /q $(LIBDIR)\Compress
1723	-if exist $(LIBDIR)\Config\Perl rmdir /s /q $(LIBDIR)\Config\Perl
1724	-if exist $(LIBDIR)\CPAN rmdir /s /q $(LIBDIR)\CPAN
1725	-if exist $(LIBDIR)\Data rmdir /s /q $(LIBDIR)\Data
1726	-if exist $(LIBDIR)\Devel rmdir /s /q $(LIBDIR)\Devel
1727	-if exist $(LIBDIR)\Digest rmdir /s /q $(LIBDIR)\Digest
1728	-if exist $(LIBDIR)\Encode rmdir /s /q $(LIBDIR)\Encode
1729	-if exist $(LIBDIR)\encoding rmdir /s /q $(LIBDIR)\encoding
1730	-if exist $(LIBDIR)\Exporter rmdir /s /q $(LIBDIR)\Exporter
1731	-if exist $(LIBDIR)\ExtUtils\CBuilder rmdir /s /q $(LIBDIR)\ExtUtils\CBuilder
1732	-if exist $(LIBDIR)\ExtUtils\Command rmdir /s /q $(LIBDIR)\ExtUtils\Command
1733	-if exist $(LIBDIR)\ExtUtils\Constant rmdir /s /q $(LIBDIR)\ExtUtils\Constant
1734	-if exist $(LIBDIR)\ExtUtils\Liblist rmdir /s /q $(LIBDIR)\ExtUtils\Liblist
1735	-if exist $(LIBDIR)\ExtUtils\MakeMaker rmdir /s /q $(LIBDIR)\ExtUtils\MakeMaker
1736	-if exist $(LIBDIR)\ExtUtils\ParseXS rmdir /s /q $(LIBDIR)\ExtUtils\ParseXS
1737	-if exist $(LIBDIR)\ExtUtils\Typemaps rmdir /s /q $(LIBDIR)\ExtUtils\Typemaps
1738	-if exist $(LIBDIR)\File\Spec rmdir /s /q $(LIBDIR)\File\Spec
1739	-if exist $(LIBDIR)\Filter rmdir /s /q $(LIBDIR)\Filter
1740	-if exist $(LIBDIR)\Hash rmdir /s /q $(LIBDIR)\Hash
1741	-if exist $(LIBDIR)\HTTP rmdir /s /q $(LIBDIR)\HTTP
1742	-if exist $(LIBDIR)\I18N rmdir /s /q $(LIBDIR)\I18N
1743	-if exist $(LIBDIR)\inc rmdir /s /q $(LIBDIR)\inc
1744	-if exist $(LIBDIR)\IO rmdir /s /q $(LIBDIR)\IO
1745	-if exist $(LIBDIR)\IPC rmdir /s /q $(LIBDIR)\IPC
1746	-if exist $(LIBDIR)\JSON rmdir /s /q $(LIBDIR)\JSON
1747	-if exist $(LIBDIR)\List rmdir /s /q $(LIBDIR)\List
1748	-if exist $(LIBDIR)\Locale rmdir /s /q $(LIBDIR)\Locale
1749	-if exist $(LIBDIR)\Math rmdir /s /q $(LIBDIR)\Math
1750	-if exist $(LIBDIR)\Memoize rmdir /s /q $(LIBDIR)\Memoize
1751	-if exist $(LIBDIR)\MIME rmdir /s /q $(LIBDIR)\MIME
1752	-if exist $(LIBDIR)\Module rmdir /s /q $(LIBDIR)\Module
1753	-if exist $(LIBDIR)\Net\FTP rmdir /s /q $(LIBDIR)\Net\FTP
1754	-if exist $(LIBDIR)\Params rmdir /s /q $(LIBDIR)\Params
1755	-if exist $(LIBDIR)\Parse rmdir /s /q $(LIBDIR)\Parse
1756	-if exist $(LIBDIR)\Perl rmdir /s /q $(LIBDIR)\Perl
1757	-if exist $(LIBDIR)\PerlIO rmdir /s /q $(LIBDIR)\PerlIO
1758	-if exist $(LIBDIR)\Pod\Perldoc rmdir /s /q $(LIBDIR)\Pod\Perldoc
1759	-if exist $(LIBDIR)\Pod\Simple rmdir /s /q $(LIBDIR)\Pod\Simple
1760	-if exist $(LIBDIR)\Pod\Text rmdir /s /q $(LIBDIR)\Pod\Text
1761	-if exist $(LIBDIR)\Scalar rmdir /s /q $(LIBDIR)\Scalar
1762	-if exist $(LIBDIR)\Search rmdir /s /q $(LIBDIR)\Search
1763	-if exist $(LIBDIR)\Sub rmdir /s /q $(LIBDIR)\Sub
1764	-if exist $(LIBDIR)\Sys rmdir /s /q $(LIBDIR)\Sys
1765	-if exist $(LIBDIR)\TAP rmdir /s /q $(LIBDIR)\TAP
1766	-if exist $(LIBDIR)\Term rmdir /s /q $(LIBDIR)\Term
1767	-if exist $(LIBDIR)\Test rmdir /s /q $(LIBDIR)\Test
1768	-if exist $(LIBDIR)\Test2 rmdir /s /q $(LIBDIR)\Test2
1769	-if exist $(LIBDIR)\Text rmdir /s /q $(LIBDIR)\Text
1770	-if exist $(LIBDIR)\Thread rmdir /s /q $(LIBDIR)\Thread
1771	-if exist $(LIBDIR)\threads rmdir /s /q $(LIBDIR)\threads
1772	-if exist $(LIBDIR)\Tie\Hash rmdir /s /q $(LIBDIR)\Tie\Hash
1773	-if exist $(LIBDIR)\Unicode\Collate rmdir /s /q $(LIBDIR)\Unicode\Collate
1774	-if exist $(LIBDIR)\Unicode\Collate\Locale rmdir /s /q $(LIBDIR)\Unicode\Collate\Locale
1775	-if exist $(LIBDIR)\version rmdir /s /q $(LIBDIR)\version
1776	-if exist $(LIBDIR)\VMS rmdir /s /q $(LIBDIR)\VMS
1777	-if exist $(LIBDIR)\Win32API rmdir /s /q $(LIBDIR)\Win32API
1778	-if exist $(LIBDIR)\XS rmdir /s /q $(LIBDIR)\XS
1779	-cd $(PODDIR) && del /f *.html *.bat roffitall \
1780	    perl5281delta.pod perlaix.pod perlamiga.pod perlandroid.pod \
1781	    perlapi.pod perlbs2000.pod perlce.pod perlcn.pod perlcygwin.pod \
1782	    perldos.pod perlfreebsd.pod perlhaiku.pod perlhpux.pod \
1783	    perlhurd.pod perlintern.pod perlirix.pod perljp.pod perlko.pod \
1784	    perllinux.pod perlmacos.pod perlmacosx.pod perlmodlib.pod \
1785	    perlnetware.pod perlopenbsd.pod perlos2.pod perlos390.pod \
1786	    perlos400.pod perlplan9.pod perlqnx.pod perlriscos.pod \
1787	    perlsolaris.pod perlsymbian.pod perlsynology.pod perltoc.pod \
1788	    perltru64.pod perltw.pod perluniprops.pod perlvos.pod \
1789	    perlwin32.pod
1790	-cd ..\utils && del /f h2ph splain perlbug pl2pm h2xs \
1791	    perldoc perlivp libnetcfg enc2xs encguess piconv cpan *.bat \
1792	    xsubpp pod2html instmodsh json_pp prove ptar ptardiff ptargrep shasum corelist zipdetails
1793	-del /f ..\config.sh perlmain.c dlutils.c config.h.new \
1794	    perlmainst.c
1795	-del /f $(CONFIGPM)
1796	-del /f ..\lib\Config_git.pl
1797	-del /f "bin\*.bat"
1798	-del /f perllibst.h
1799	-del /f $(PERLEXE_RES) perl.base
1800	-cd .. && del /s *$(a) *.map *.pdb *.ilk *.bs *$(o) .exists pm_to_blib ppport.h
1801	-cd $(EXTDIR) && del /s *.def Makefile Makefile.old
1802	-cd $(DISTDIR) && del /s *.def Makefile Makefile.old
1803	-cd $(CPANDIR) && del /s *.def Makefile Makefile.old
1804	-del /s ..\utils\Makefile
1805	-if exist $(AUTODIR) rmdir /s /q $(AUTODIR)
1806	-if exist $(COREDIR) rmdir /s /q $(COREDIR)
1807	-if exist pod2htmd.tmp del pod2htmd.tmp
1808	-if exist $(HTMLDIR) rmdir /s /q $(HTMLDIR)
1809	-del /f ..\t\test_state
1810
1811install : all installbare installhtml
1812
1813installbare : utils ..\pod\perltoc.pod
1814	$(PERLEXE) ..\installperl
1815	if exist $(WPERLEXE) $(XCOPY) $(WPERLEXE) $(INST_BIN)\$(NULL)
1816	if exist $(PERLEXESTATIC) $(XCOPY) $(PERLEXESTATIC) $(INST_BIN)\$(NULL)
1817	$(XCOPY) $(GLOBEXE) $(INST_BIN)\$(NULL)
1818	if exist ..\perl*.pdb $(XCOPY) ..\perl*.pdb $(INST_BIN)\$(NULL)
1819	$(XCOPY) "bin\*.bat" $(INST_SCRIPT)\$(NULL)
1820
1821installhtml : doc
1822	$(RCOPY) $(HTMLDIR)\*.* $(INST_HTML)\$(NULL)
1823
1824inst_lib : $(CONFIGPM)
1825	$(RCOPY) ..\lib $(INST_LIB)\$(NULL)
1826
1827$(UNIDATAFILES) : ..\pod\perluniprops.pod
1828
1829..\pod\perluniprops.pod: ..\lib\unicore\mktables $(CONFIGPM)
1830	$(MINIPERL) -I..\lib ..\lib\unicore\mktables -C ..\lib\unicore -P ..\pod -maketest -makelist -p
1831
1832minitest : $(HAVEMINIPERL) $(GLOBEXE) $(CONFIGPM) $(UNIDATAFILES) utils
1833	$(XCOPY) $(MINIPERL) ..\t\$(NULL)
1834	if exist ..\t\perl.exe del /f ..\t\perl.exe
1835	rename ..\t\miniperl.exe perl.exe
1836	$(XCOPY) $(GLOBEXE) ..\t\$(NULL)
1837	attrib -r "..\t\*.*"
1838	cd ..\t && \
1839	$(MINIPERL) -I..\lib harness base/*.t comp/*.t cmd/*.t io/*.t opbasic/*.t op/*.t pragma/*.t
1840
1841test-prep : all utils ..\pod\perltoc.pod $(TESTPREPGCC)
1842	$(XCOPY) $(PERLEXE) ..\t\$(NULL)
1843	$(XCOPY) $(PERLDLL) ..\t\$(NULL)
1844	$(XCOPY) $(GLOBEXE) ..\t\$(NULL)
1845# If building with gcc versions 4.x.x or greater, then
1846# the GCC helper DLL will also need copied to the test directory.
1847# The name of the dll can change, depending upon which vendor has supplied
1848# your compiler, and upon the values of "x".
1849# libstdc++-6.dll is copied if it exists as it, too, may then be needed.
1850# Without this copying, the op/taint.t test script will fail.
1851
1852ifeq ($(CCTYPE),GCC)
1853
1854test-prep-gcc :
1855	if exist $(CCDLLDIR)\libgcc_s_seh-1.dll $(XCOPY) $(CCDLLDIR)\libgcc_s_seh-1.dll ..\t\$(NULL)
1856	if exist $(CCDLLDIR)\libgcc_s_sjlj-1.dll $(XCOPY) $(CCDLLDIR)\libgcc_s_sjlj-1.dll ..\t\$(NULL)
1857	if exist $(CCDLLDIR)\libgcc_s_dw2-1.dll $(XCOPY) $(CCDLLDIR)\libgcc_s_dw2-1.dll ..\t\$(NULL)
1858	if exist $(CCDLLDIR)\libstdc++-6.dll $(XCOPY) $(CCDLLDIR)\libstdc++-6.dll ..\t\$(NULL)
1859	if exist $(CCDLLDIR)\libwinpthread-1.dll $(XCOPY) $(CCDLLDIR)\libwinpthread-1.dll ..\t\$(NULL)
1860
1861endif
1862
1863test : test-prep
1864	set PERL_STATIC_EXT=$(STATIC_EXT) && \
1865	    cd ..\t && perl.exe harness $(TEST_SWITCHES) $(TEST_FILES)
1866
1867test_porting : test-prep
1868	set PERL_STATIC_EXT=$(STATIC_EXT) && \
1869	    cd ..\t && perl.exe harness $(TEST_SWITCHES) porting\*.t ..\lib\diagnostics.t
1870
1871test-reonly : reonly utils
1872	$(XCOPY) $(PERLEXE) ..\t\$(NULL)
1873	$(XCOPY) $(PERLDLL) ..\t\$(NULL)
1874	$(XCOPY) $(GLOBEXE) ..\t\$(NULL)
1875	cd ..\t && perl.exe harness $(OPT) -re \bpat\\/ $(EXTRA)
1876
1877regen :
1878	cd .. && regen.pl
1879
1880test-notty : test-prep
1881	set PERL_STATIC_EXT=$(STATIC_EXT) && \
1882	    set PERL_SKIP_TTY_TEST=1 && \
1883	    cd ..\t && perl.exe harness $(TEST_SWITCHES) $(TEST_FILES)
1884
1885_test :
1886	$(XCOPY) $(PERLEXE) ..\t\$(NULL)
1887	$(XCOPY) $(PERLDLL) ..\t\$(NULL)
1888	$(XCOPY) $(GLOBEXE) ..\t\$(NULL)
1889	set PERL_STATIC_EXT=$(STATIC_EXT) && \
1890	    cd ..\t && perl.exe harness $(TEST_SWITCHES) $(TEST_FILES)
1891
1892_clean :
1893	-@erase miniperlmain$(o)
1894	-@erase $(MINIPERL)
1895	-@erase perlglob$(o)
1896	-@erase perlmain$(o)
1897	-@erase perlmainst$(o)
1898	-@erase /f config.h
1899	-@erase /f ..\git_version.h
1900	-@erase $(GLOBEXE)
1901	-@erase $(PERLEXE)
1902	-@erase $(WPERLEXE)
1903	-@erase $(PERLEXESTATIC)
1904	-@erase $(PERLSTATICLIB)
1905	-@erase $(PERLDLL)
1906	-@erase $(CORE_OBJ)
1907	-@erase $(GENUUDMAP) $(GENUUDMAP_OBJ) $(GENERATED_HEADERS)
1908	-@erase .coreheaders
1909	-if exist $(MINIDIR) rmdir /s /q $(MINIDIR)
1910	-if exist $(UNIDATADIR1) rmdir /s /q $(UNIDATADIR1)
1911	-if exist $(UNIDATADIR2) rmdir /s /q $(UNIDATADIR2)
1912	-@erase $(UNIDATAFILES)
1913	-@erase $(WIN32_OBJ)
1914	-@erase $(DLL_OBJ)
1915	-@erase ..\*$(o) ..\*$(a) ..\*.exp *$(o) *$(a) *.exp *.res
1916	-@erase ..\t\*.exe ..\t\*.dll ..\t\*.bat
1917	-@erase *.ilk
1918	-@erase *.pdb ..\*.pdb
1919	-@erase Extensions_static
1920
1921clean : Extensions_clean _clean
1922
1923realclean : Extensions_realclean _clean
1924
1925# Handy way to run perlbug -ok without having to install and run the
1926# installed perlbug. We don't re-run the tests here - we trust the user.
1927# Please *don't* use this unless all tests pass.
1928# If you want to report test failures, use "gmake nok" instead.
1929ok: utils $(PERLEXE) $(PERLDLL) Extensions_nonxs Extensions
1930	$(PERLEXE) ..\utils\perlbug -ok -s "(UNINSTALLED)"
1931
1932okfile: utils $(PERLEXE) $(PERLDLL) Extensions_nonxs Extensions
1933	$(PERLEXE) ..\utils\perlbug -ok -s "(UNINSTALLED)" -F perl.ok
1934
1935nok: utils $(PERLEXE) $(PERLDLL) Extensions_nonxs Extensions
1936	$(PERLEXE) ..\utils\perlbug -nok -s "(UNINSTALLED)"
1937
1938nokfile: utils $(PERLEXE) $(PERLDLL) Extensions_nonxs Extensions
1939	$(PERLEXE) ..\utils\perlbug -nok -s "(UNINSTALLED)" -F perl.nok
1940
1941