This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
force linkage of the function wrappers for globals in change#4878
[perl5.git] / win32 / makefile.mk
index 592588a..75f6a5c 100644 (file)
@@ -1,9 +1,9 @@
 #
 # Makefile to build perl on Windows NT using DMAKE.
 # Supported compilers:
-#      Visual C++ 2.0 thro 5.0
+#      Visual C++ 2.0 thro 6.0
 #      Borland C++ 5.02
-#      Mingw32 with gcc-2.8.1 or egcs-1.0.2  **experimental**
+#      Mingw32 with gcc-2.95.2 or better  **experimental**
 #
 # This is set up to build a perl.exe that runs off a shared library
 # (perl.dll).  Also makes individual DLLs for the XS extensions.
@@ -33,7 +33,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.00563
+INST_VER       *= \5.5.640
 
 #
 # Comment this out if you DON'T want your perl installation to have
@@ -51,7 +51,7 @@ INST_ARCH     *= \$(ARCHNAME)
 #
 # uncomment to enable threads-capabilities
 #
-#USE_THREADS   *= define
+#USE_5005THREADS       *= define
 
 #
 # XXX WARNING! This option currently undergoing changes.  May be broken.
@@ -73,14 +73,15 @@ INST_ARCH   *= \$(ARCHNAME)
 # XXX WARNING! This option currently undergoing changes.  May be broken.
 #
 # Beginnings of interpreter cloning/threads: still rather rough, fails
-# tests.  This should be enabled to get the fork() emulation.  Do not
-# enable unless you know what you're doing!
+# tests.  This should be enabled to get the fork() emulation.  This needs
+# one of USE_MULTI or USE_OBJECT enabled as well.
 #
 #USE_ITHREADS  *= define
 
 #
 # uncomment to enable the implicit "host" layer for all system calls
-# made by perl.  This is needed and auto-enabled by USE_OBJECT above.
+# made by perl.  This needs one of USE_MULTI or USE_OBJECT above.
+# This is also needed to get fork().
 #
 #USE_IMP_SYS   *= define
 
@@ -95,7 +96,7 @@ INST_ARCH     *= \$(ARCHNAME)
 #CCTYPE                *= MSVC60
 # Borland 5.02 or later
 CCTYPE         *= BORLAND
-# mingw32/egcs or mingw32/gcc
+# mingw32/gcc-2.95.2 or better
 #CCTYPE                *= GCC
 
 #
@@ -111,13 +112,14 @@ CCTYPE            *= BORLAND
 #CFG           *= Debug
 
 #
-# uncomment to enable use of PerlCRT.DLL when using the Visual C compiler
-# or GCC/Mingw32. Highly recommended. It has patches that fix known bugs in 
-# MSVCRT.DLL. This currently requires VC 5.0 with Service Pack 3 or later
-# or GCC/Mingw32.
+# uncomment to enable use of PerlCRT.DLL when using the Visual C compiler.
+# It has patches that fix known bugs in older versions of MSVCRT.DLL.
+# This currently requires VC 5.0 with Service Pack 3 or later.
 # Get it from CPAN at http://www.perl.com/CPAN/authors/id/D/DO/DOUGL/
 # and follow the directions in the package to install.
 #
+# Not recommended if you have VC 6.x and you're not running Windows 9x.
+#
 #USE_PERLCRT   *= define
 
 #
@@ -159,29 +161,40 @@ CCTYPE            *= BORLAND
 # so you may have to set CCHOME explicitly (spaces in the path name should
 # not be quoted)
 #
-CCHOME         *= d:\bc5
+CCHOME         *= c:\bc5
 #CCHOME                *= $(MSVCDIR)
 #CCHOME                *= D:\packages\mingw32
 CCINCDIR       *= $(CCHOME)\include
 CCLIBDIR       *= $(CCHOME)\lib
 
 #
-# additional compiler flags can be specified here.
+# Additional compiler flags can be specified here.
+#
+
 #
-# Adding -DPERL_POLLUTE enables support for old symbols, at the expense of
-# extreme pollution. You most probably want this if you're compiling modules
-# from CPAN, or other such serious uses of this experimental perl release.
-# We don't enable this by default because we want the modules to get fixed
-# instead of clinging to shortcuts like this one.
+# This should normally be disabled.  Adding -DPERL_POLLUTE enables support
+# for old symbols by default, at the expense of extreme pollution.  You most
+# probably just want to build modules that won't compile with
+#         perl Makefile.PL POLLUTE=1
+# instead of enabling this.  Please report such modules to the respective
+# authors.
 #
 #BUILDOPT      += -DPERL_POLLUTE
 
 #
-# enable this to disable the File::Glob implementation of CORE::glob
+# This should normally be disabled.  Enabling it will disable the File::Glob
+# implementation of CORE::glob.
 #
 #BUILDOPT      += -DPERL_EXTERNAL_GLOB
 
-# Enabling this runs a cloned toplevel interpreter (fails tests)
+#
+# This should normally be disabled.  Enabling it causes perl to read scripts
+# in text mode (which is the 5.005 behavior) and will break ByteLoader.
+#BUILDOPT      += -DPERL_TEXTMODE_SCRIPTS
+
+#
+# This should normally be disabled.  Enabling it runs a cloned toplevel
+# interpreter (*EXPERIMENTAL*, fails tests)
 #BUILDOPT      += -DTOP_CLONE
 
 #
@@ -217,16 +230,16 @@ CRYPT_FLAG        = -DHAVE_DES_FCRYPT
 
 .IF "$(USE_OBJECT)" == "define"
 PERL_MALLOC    != undef
-USE_THREADS    != undef
+USE_5005THREADS        != undef
 USE_MULTI      != undef
 USE_IMP_SYS    != define
 .ENDIF
 
 PERL_MALLOC    *= undef
 
-USE_THREADS    *= undef
+USE_5005THREADS        *= undef
 
-.IF "$(USE_THREADS)" == "define"
+.IF "$(USE_5005THREADS)" == "define"
 USE_ITHREADS   != undef
 .ENDIF
 
@@ -234,13 +247,19 @@ USE_MULTI *= undef
 USE_OBJECT     *= undef
 USE_ITHREADS   *= undef
 USE_IMP_SYS    *= undef
+USE_PERLCRT    *= undef
 
-.IF "$(USE_MULTI)$(USE_THREADS)$(USE_OBJECT)" != "undefundefundef"
-BUILDOPT       += -DPERL_IMPLICIT_CONTEXT
+.IF "$(USE_IMP_SYS)$(USE_MULTI)$(USE_5005THREADS)$(USE_OBJECT)" == "defineundefundefundef"
+USE_MULTI      != define
+.ENDIF
+
+.IF "$(USE_ITHREADS)$(USE_MULTI)$(USE_OBJECT)" == "defineundefundef"
+USE_MULTI      != define
+USE_5005THREADS        != undef
 .ENDIF
 
-.IF "$(USE_ITHREADS)" != "undef"
-BUILDOPT       += -DUSE_ITHREADS
+.IF "$(USE_MULTI)$(USE_5005THREADS)$(USE_OBJECT)" != "undefundefundef"
+BUILDOPT       += -DPERL_IMPLICIT_CONTEXT
 .ENDIF
 
 .IF "$(USE_IMP_SYS)" != "undef"
@@ -253,7 +272,7 @@ PROCESSOR_ARCHITECTURE *= x86
 
 .IF "$(USE_OBJECT)" == "define"
 ARCHNAME       = MSWin32-$(PROCESSOR_ARCHITECTURE)-object
-.ELIF "$(USE_THREADS)" == "define"
+.ELIF "$(USE_5005THREADS)" == "define"
 ARCHNAME       = MSWin32-$(PROCESSOR_ARCHITECTURE)-thread
 .ELIF "$(USE_MULTI)" == "define"
 ARCHNAME       = MSWin32-$(PROCESSOR_ARCHITECTURE)-multi
@@ -261,6 +280,10 @@ ARCHNAME   = MSWin32-$(PROCESSOR_ARCHITECTURE)-multi
 ARCHNAME       = MSWin32-$(PROCESSOR_ARCHITECTURE)
 .ENDIF
 
+.IF "$(USE_OBJECT)" == "define"
+ARCHNAME       = $(ARCHNAME)-thread
+.ENDIF
+
 # Visual Studio 98 specific
 .IF "$(CCTYPE)" == "MSVC60"
 
@@ -302,6 +325,7 @@ CC          = bcc32
 LINK32         = tlink32
 LIB32          = tlib /P128
 IMPLIB         = implib -c
+RSC            = rc
 
 #
 # Options
@@ -338,6 +362,7 @@ CC          = gcc
 LINK32         = gcc
 LIB32          = ar rc
 IMPLIB         = dlltool
+RSC            = rc
 
 o = .o
 a = .a
@@ -346,30 +371,21 @@ a = .a
 # Options
 #
 
-# GCC headers need to know that we're using MSVCRT (or a clone thereof)
-RUNTIME                = -D__MSVCRT__
+RUNTIME                =
 INCLUDES       = -I$(COREDIR) -I.\include -I. -I..
 DEFINES                = -DWIN32 $(CRYPT_FLAG)
 LOCDEFS                = -DPERLDLL -DPERL_CORE
 SUBSYS         = console
 CXX_FLAG       = -xc++
 
-.IF "$(USE_PERLCRT)" == ""
-LIBCDLL        = msvcrt.dll
-CRTIMPLIBS     = $(OLDNAMES_A)
-.ELSE
-LIBCDLL        = PerlCRT.dll
-CRTIMPLIBS     = $(PERLCRT_A) $(OLDNAMES_A)
-.ENDIF
-
-LIBC           = -l$(LIBCDLL:s/.dll//)
-GCCLIBS                = -lmingw32 -lgcc
+LIBC           = -lmsvcrt
 
-# same libs as MSVC, but no -luuid32 or -lodbccp32 yet
-LIBFILES       =  $(GCCLIBS) $(CRYPT_LIB) $(LIBC) -loldnames -lkernel32 \
-               -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 \
-               -lole32 -loleaut32 -lnetapi32 -lwsock32 -lmpr -lwinmm \
-               -lversion -lodbc32
+# same libs as MSVC
+LIBFILES       = $(CRYPT_LIB) $(LIBC) \
+                 -lmoldname -lkernel32 -luser32 -lgdi32 \
+                 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 \
+                 -loleaut32 -lnetapi32 -luuid -lwsock32 -lmpr \
+                 -lwinmm -lversion -lodbc32
 
 .IF  "$(CFG)" == "Debug"
 OPTIMIZE       = -g $(RUNTIME) -DDEBUGGING
@@ -385,14 +401,12 @@ OBJOUT_FLAG       = -o
 EXEOUT_FLAG    = -o
 LIBOUT_FLAG    = 
 
-# tack COREDIR on for perl build
-PRIV_LINK_FLAGS = -L"$(COREDIR)"
-
 .ELSE
 
 CC             = cl
 LINK32         = link
 LIB32          = $(LINK32) -lib
+RSC            = rc
 
 #
 # Options
@@ -406,7 +420,7 @@ LOCDEFS             = -DPERLDLL -DPERL_CORE
 SUBSYS         = console
 CXX_FLAG       = -TP -GX
 
-.IF "$(USE_PERLCRT)" == ""
+.IF "$(USE_PERLCRT)" != "define"
 .IF  "$(CFG)" == "Debug"
 PERLCRTLIBC    = msvcrtd.lib
 .ELSE
@@ -420,6 +434,9 @@ PERLCRTLIBC = PerlCRT.lib
 .ENDIF
 .ENDIF
 
+PERLEXE_RES    =
+PERLDLL_RES    =
+
 .IF "$(RUNTIME)" == "-MD"
 LIBC           = $(PERLCRTLIBC)
 .ELSE
@@ -445,10 +462,10 @@ LINK_DBG  = -release
 .ENDIF
 
 LIBBASEFILES   = $(DELAYLOAD) $(CRYPT_LIB) \
-               oldnames.lib kernel32.lib user32.lib gdi32.lib \
-               winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib \
-               oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib \
-               winmm.lib version.lib odbc32.lib odbccp32.lib
+               oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib \
+               comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
+               netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib \
+               version.lib odbc32.lib odbccp32.lib
 
 # we add LIBC here, since we may be using PerlCRT.dll
 LIBFILES       = $(LIBBASEFILES) $(LIBC)
@@ -462,6 +479,10 @@ OBJOUT_FLAG        = -Fo
 EXEOUT_FLAG    = -Fe
 LIBOUT_FLAG    = /out:
 
+.IF "$(USE_PERLCRT)" != "define"
+BUILDOPT       += -DPERL_MSVCRT_READFIX
+.ENDIF
+
 .ENDIF
 
 .IF "$(USE_OBJECT)" == "define"
@@ -469,16 +490,11 @@ OPTIMIZE  += $(CXX_FLAG)
 BUILDOPT       += -DPERL_OBJECT
 .ENDIF
 
-CRTIMPLIBS     *= __not_needed
-PERLCRT_A      *= $(COREDIR)\libPerlCRT.a
-PERLCRT_DEF    *= PerlCRT.def
-OLDNAMES_A     *= $(COREDIR)\liboldnames.a
-OLDNAMES_DEF   *= oldnames.def
-
 CFLAGS_O       = $(CFLAGS) $(BUILDOPT)
 
-# used to allow local linking flags that are not propogated into Config.pm
-#   -- BKS, 11-15-1999
+# used to allow local linking flags that are not propogated into Config.pm,
+# currently unused
+#   -- BKS, 12-12-1999
 PRIV_LINK_FLAGS        *=
 BLINK_FLAGS    = $(PRIV_LINK_FLAGS) $(LINK_FLAGS)
 
@@ -495,7 +511,7 @@ LKPOST              = )
 # Rules
 # 
 
-.SUFFIXES : .c $(o) .dll $(a) .exe 
+.SUFFIXES : .c $(o) .dll $(a) .exe .rc .res
 
 .c$(o):
        $(CC) -c $(null,$(<:d) $(NULL) -I$(<:d)) $(CFLAGS_O) $(OBJOUT_FLAG)$@ $<
@@ -509,12 +525,15 @@ $(o).dll:
        $(IMPLIB) $(*B).lib $@
 .ELIF "$(CCTYPE)" == "GCC"
        $(LINK32) -o $@ $(BLINK_FLAGS) $< $(LIBFILES)
-       $(IMPLIB) -def $(*B).def $(*B).a $@
+       $(IMPLIB) --input-def $(*B).def --output-lib $(*B).a $@
 .ELSE
        $(LINK32) -dll -subsystem:windows -implib:$(*B).lib -def:$(*B).def \
            -out:$@ $(BLINK_FLAGS) $(LIBFILES) $< $(LIBPERL)  
 .ENDIF
 
+.rc.res:
+       $(RSC) $<
+
 #
 # various targets
 MINIPERL       = ..\miniperl.exe
@@ -573,7 +592,7 @@ PERLIMPLIB  = ..\libperl$(a)
 
 CFGSH_TMPL     = config.vc
 CFGH_TMPL      = config_H.vc
-.IF "$(USE_PERLCRT)" == ""
+.IF "$(USE_PERLCRT)" != "define"
 PERL95EXE      = ..\perl95.exe
 .ENDIF
 
@@ -641,7 +660,7 @@ WIN32_SRC   =               \
                .\win32.c       \
                .\win32sck.c
 
-.IF "$(USE_THREADS)" == "define"
+.IF "$(USE_5005THREADS)" == "define"
 WIN32_SRC      += .\win32thread.c 
 .ENDIF
 
@@ -725,12 +744,6 @@ X2P_OBJ            = $(X2P_SRC:db:+$(o))
 PERLDLL_OBJ    = $(CORE_OBJ)
 PERLEXE_OBJ    = perlmain$(o)
 
-.IF "$(CCTYPE)" == "GCC"
-PERLEXE_OBJ    += .\gcrt0$(o)
-MINI_OBJ       += $(MINIDIR)\gcrt0$(o)
-DLL_OBJ                += .\gdllcrt0$(o)
-.ENDIF
-
 PERLDLL_OBJ    += $(WIN32_OBJ) $(DLL_OBJ)
 
 .IF "$(USE_SETARGV)" != ""
@@ -846,7 +859,9 @@ CFG_VARS    =                                       \
                static_ext=$(STATIC_EXT)        ~       \
                dynamic_ext=$(DYNAMIC_EXT)      ~       \
                nonxs_ext=$(NONXS_EXT)          ~       \
-               usethreads=$(USE_THREADS)       ~       \
+               use5005threads=$(USE_5005THREADS)       ~       \
+               useithreads=$(USE_ITHREADS)     ~       \
+               usethreads=$(USE_5005THREADS)   ~       \
                usemultiplicity=$(USE_MULTI)    ~       \
                LINK_FLAGS=$(LINK_FLAGS:s/\/\\/)                ~       \
                optimize=$(OPTIMIZE)
@@ -868,7 +883,7 @@ RIGHTMAKE   = __not_needed
 # Top targets
 #
 
-all : $(CRTIMPLIBS) .\config.h $(GLOBEXE) $(MINIPERL) $(MK2)           \
+all : .\config.h $(GLOBEXE) $(MINIPERL) $(MK2)         \
        $(RIGHTMAKE) $(MINIMOD) $(CONFIGPM) $(PERLEXE) $(PERL95EXE)     \
        $(X2P) $(EXTENSION_DLL) $(EXTENSION_PM)
 
@@ -880,7 +895,7 @@ $(DYNALOADER)$(o) : $(DYNALOADER).c $(CORE_H) $(EXTDIR)\DynaLoader\dlutils.c
 
 # this target is a jump-off point for Win95
 #  1. it switches to the Win95-specific makefile if it exists
-#     (__do_switc_makefiles)
+#     (__do_switch_makefiles)
 #  2. it prints a message when the Win95-specific one finishes (__done)
 #  3. it then kills this makefile by trying to make __no_such_target
 
@@ -916,36 +931,6 @@ __no_such_target:
 
 #--------------------- END Win95 SPECIFIC ---------------------
 
-#--------------------- BEGIN GCC/Mingw32 SPECIFIC -------------
-
-# make GCC-ish implib for PerlCRT.dll if needed
-$(PERLCRT_A): $(PERLCRT_DEF)
-       if not exist $(COREDIR) mkdir $(COREDIR)
-       $(IMPLIB) --def $(PERLCRT_DEF)  \
-               --dllname $(LIBCDLL)            \
-               --output-lib $(PERLCRT_A)
-
-# make GCC-ish oldnames implib for our CRT (whether it's MSVCRT or PerlCRT)
-$(OLDNAMES_A): $(OLDNAMES_DEF)
-       $(IMPLIB) --def $(OLDNAMES_DEF) \
-               --dllname $(LIBCDLL)            \
-               --output-lib $(OLDNAMES_A)      \
-               --add-underscore
-
-# MSVCRT-using runtime startup files
-$(MINIDIR)\gcrt0$(o): .\gstartup.c
-       $(CC) -c $(CFLAGS) -DEXESTARTUP $(OBJOUT_FLAG)$@ .\gstartup.c
-
-.\gcrt0$(o): .\gstartup.c
-       $(CC) -c $(CFLAGS) -DEXESTARTUP $(OBJOUT_FLAG)$@ .\gstartup.c
-
-.\gdllcrt0$(o): .\gstartup.c
-       $(CC) -c $(CFLAGS) -DDLLSTARTUP $(OBJOUT_FLAG)$@ .\gstartup.c
-       $(XCOPY) $@ $(COREDIR)
-
-
-#--------------------- END GCC/Mingw32 SPECIFIC ---------------
-
 # a blank target for when builds don't need to do certain things
 # this target added for Win95 port but used to keep the WinNT port able to 
 # use this file
@@ -958,7 +943,7 @@ $(GLOBEXE) : perlglob$(o)
        $(LINK32) -Tpe -ap $(BLINK_FLAGS) c0x32$(o) perlglob$(o) \
            "$(CCLIBDIR)\32BIT\wildargs$(o)",$@,,import32.lib cw32mt.lib,
 .ELIF "$(CCTYPE)" == "GCC"
-       $(LINK32) $(BLINK_FLAGS) -o $@ perlglob$(o) $(LIBFILES)
+       $(LINK32) $(BLINK_FLAGS) -mconsole -o $@ perlglob$(o) $(LIBFILES)
 .ELSE
        $(LINK32) $(BLINK_FLAGS) $(LIBFILES) -out:$@ -subsystem:$(SUBSYS) \
            perlglob$(o) setargv$(o) 
@@ -981,7 +966,8 @@ config.w32 : $(CFGSH_TMPL)
 # edit config.{b,v,g}c and make this target once for each supported
 # compiler (e.g. `dmake CCTYPE=BORLAND regen_config_h`)
 regen_config_h:
-       perl config_sh.PL $(CFG_VARS) $(CFGSH_TMPL) > ..\config.sh
+       perl config_sh.PL --cfgsh-option-file $(mktmp $(CFG_VARS)) \
+           $(CFGSH_TMPL) > ..\config.sh
        -cd .. && del /f perl.exe
        cd .. && perl configpm
        -del /f $(CFGH_TMPL)
@@ -1004,7 +990,7 @@ $(MINIPERL) : $(MINIDIR) $(MINI_OBJ) $(CRTIPMLIBS)
        $(LINK32) -Tpe -ap $(BLINK_FLAGS) \
            @$(mktmp c0x32$(o) $(MINI_OBJ:s,\,\\),$(@:s,\,\\),,$(LIBFILES),)
 .ELIF "$(CCTYPE)" == "GCC"
-       $(LINK32) -v -nostdlib -o $@ $(BLINK_FLAGS) \
+       $(LINK32) -v -mconsole -o $@ $(BLINK_FLAGS) \
            $(mktmp $(LKPRE) $(MINI_OBJ:s,\,\\) $(LIBFILES) $(LKPOST)) 
 .ELSE
        $(LINK32) -subsystem:console -out:$@ \
@@ -1021,9 +1007,13 @@ $(MINIWIN32_OBJ) : $(CORE_NOCFG_H)
        $(CC) -c $(CFLAGS) $(OBJOUT_FLAG)$@ $(*B).c
 
 # -DPERL_IMPLICIT_SYS needs C++ for perllib.c
-.IF "$(USE_IMP_SYS)$(USE_OBJECT)" == "defineundef"
+# 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
 perllib$(o)    : perllib.c
+.IF "$(USE_IMP_SYS)$(USE_OBJECT)" == "defineundef"
        $(CC) -c -I. $(CFLAGS_O) $(CXX_FLAG) $(OBJOUT_FLAG)$@ perllib.c
+.ELSE
+       $(CC) -c -I. $(CFLAGS_O) $(OBJOUT_FLAG)$@ perllib.c
 .ENDIF
 
 # 1. we don't want to rebuild miniperl.exe when config.h changes
@@ -1040,7 +1030,7 @@ perldll.def : $(MINIPERL) $(CONFIGPM) ..\global.sym ..\pp.sym ..\makedef.pl
        $(MINIPERL) -w ..\makedef.pl PLATFORM=win32 $(OPTIMIZE) $(DEFINES) \
        $(BUILDOPT) CCTYPE=$(CCTYPE) > perldll.def
 
-$(PERLDLL): perldll.def $(PERLDLL_OBJ)
+$(PERLDLL): perldll.def $(PERLDLL_OBJ) $(PERLDLL_RES)
 .IF "$(CCTYPE)" == "BORLAND"
        $(LINK32) -Tpd -ap $(BLINK_FLAGS) \
            @$(mktmp c0d32$(o) $(PERLDLL_OBJ:s,\,\\)\n \
@@ -1052,16 +1042,16 @@ $(PERLDLL): perldll.def $(PERLDLL_OBJ)
        $(LINK32) -mdll -o $@ -Wl,--base-file -Wl,perl.base $(BLINK_FLAGS) \
            $(mktmp $(LKPRE) $(PERLDLL_OBJ:s,\,\\) $(LIBFILES) $(LKPOST))
        dlltool --output-lib $(PERLIMPLIB) \
-                --dllname $(PERLDLL:b).dll \
-                --def perldll.def \
-                --base-file perl.base \
-                --output-exp perl.exp
+               --dllname $(PERLDLL:b).dll \
+               --def perldll.def \
+               --base-file perl.base \
+               --output-exp perl.exp
        $(LINK32) -mdll -o $@ $(BLINK_FLAGS) \
            $(mktmp $(LKPRE) $(PERLDLL_OBJ:s,\,\\) $(LIBFILES) \
                perl.exp $(LKPOST))
 .ELSE
        $(LINK32) -dll -def:perldll.def -out:$@ \
-           @$(mktmp $(BLINK_FLAGS) $(LIBFILES) $(PERLDLL_OBJ:s,\,\\))
+           @$(mktmp $(BLINK_FLAGS) $(LIBFILES) $(PERLDLL_RES) $(PERLDLL_OBJ:s,\,\\))
 .ENDIF
        $(XCOPY) $(PERLIMPLIB) $(COREDIR)
 
@@ -1103,18 +1093,18 @@ perlmain.c : runperl.c
 perlmain$(o) : perlmain.c
        $(CC) $(CFLAGS_O) -UPERLDLL $(OBJOUT_FLAG)$@ -c perlmain.c
 
-$(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ)
+$(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ) $(PERLEXE_RES)
 .IF "$(CCTYPE)" == "BORLAND"
        $(LINK32) -Tpe -ap $(BLINK_FLAGS) \
            @$(mktmp c0x32$(o) $(PERLEXE_OBJ:s,\,\\)\n \
            $(@:s,\,\\),\n \
            $(PERLIMPLIB) $(LIBFILES)\n)
 .ELIF "$(CCTYPE)" == "GCC"
-       $(LINK32) -nostdlib -o $@ $(BLINK_FLAGS)  \
+       $(LINK32) -mconsole -o $@ $(BLINK_FLAGS)  \
            $(PERLEXE_OBJ) $(PERLIMPLIB) $(LIBFILES)
 .ELSE
        $(LINK32) -subsystem:console -out:$@ $(BLINK_FLAGS) $(LIBFILES) \
-           $(PERLEXE_OBJ) $(SETARGV_OBJ) $(PERLIMPLIB) 
+           $(PERLEXE_OBJ) $(SETARGV_OBJ) $(PERLIMPLIB) $(PERLEXE_RES)
        copy $(PERLEXE) $(WPERLEXE)
        editbin /subsystem:windows $(WPERLEXE)
 .ENDIF
@@ -1123,7 +1113,7 @@ $(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ)
 
 .IF "$(CCTYPE)" != "BORLAND"
 .IF "$(CCTYPE)" != "GCC"
-.IF "$(USE_PERLCRT)" == ""
+.IF "$(USE_PERLCRT)" != "define"
 
 perl95.c : runperl.c 
        copy runperl.c perl95.c