From: Steve Hay Date: Fri, 17 Nov 2006 15:12:12 +0000 (+0000) Subject: Add perl-static.exe support to win32/makefile.mk X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ed2eab3fc8323ad057527ec2d1e196bda907dcee;p=p5sagit%2Fp5-mst-13.2.git Add perl-static.exe support to win32/makefile.mk This applies the same changes that were made in win32/Makefile by changes #29285 and #29296, plus a tweak to win32/runperl.c to fix a linker error when using MinGW/gcc p4raw-link: @29285 on //depot/perl: 4e036e4bbba6d063b01c50038bdc634716ef4439 p4raw-id: //depot/perl@29303 --- diff --git a/win32/makefile.mk b/win32/makefile.mk index db133af..32e6b9e 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -181,6 +181,15 @@ CRYPT_SRC *= fcrypt.c #DEBUG_MSTATS *= define # +# 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 STATIC_EXT variable below. +# A static library perl59s.lib will also be created. +# Ordinary perl.exe is not affected by this option. +# +#BUILD_STATIC *= define + +# # set the install locations of the compiler include/libraries # Running VCVARS32.BAT is *required* when using Visual C. # Some versions of Visual C don't define MSVCDIR in the environment, @@ -399,7 +408,7 @@ LINK32 = ilink32 .ELSE LINK32 = tlink32 .ENDIF -LIB32 = tlib /P128 +LIB32 = tlib /a /P128 IMPLIB = implib -c RSC = brcc32 @@ -588,6 +597,7 @@ CFLAGS = $(EXTRACFLAGS) $(INCLUDES) $(DEFINES) $(LOCDEFS) \ LINK_FLAGS = -nologo -nodefaultlib $(LINK_DBG) \ -libpath:"$(INST_COREDIR)" \ -machine:$(PROCESSOR_ARCHITECTURE) +LIB_FLAGS = -nologo OBJOUT_FLAG = -Fo EXEOUT_FLAG = -Fe LIBOUT_FLAG = /out: @@ -674,10 +684,16 @@ MINIPERL = ..\miniperl.exe MINIDIR = .\mini PERLEXE = ..\perl.exe WPERLEXE = ..\wperl.exe +PERLEXESTATIC = ..\perl-static.exe GLOBEXE = ..\perlglob.exe CONFIGPM = ..\lib\Config.pm ..\lib\Config_heavy.pl MINIMOD = ..\lib\ExtUtils\Miniperl.pm X2P = ..\x2p\a2p.exe +.IF "$(BUILD_STATIC)" == "define" +PERLSTATIC = static +.ELSE +PERLSTATIC = +.ENDIF # Unicode data files generated by mktables UNIDATAFILES = ..\lib\unicore\Canonical.pl ..\lib\unicore\Exact.pl \ @@ -753,6 +769,7 @@ CFGH_TMPL = config_H.bc CFGSH_TMPL = config.gc CFGH_TMPL = config_H.gc PERLIMPLIB = ..\libperl59$(a) +PERLSTATICLIB = ..\libperl59s$(a) .ELSE @@ -769,6 +786,7 @@ CFGH_TMPL = config_H.vc # 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 *= ..\perl59$(a) +PERLSTATICLIB *= ..\perl59s$(a) PERLDLL = ..\perl59.dll XCOPY = xcopy /f /r /i /d /y @@ -904,6 +922,7 @@ X2P_OBJ = $(X2P_SRC:db:+$(o)) PERLDLL_OBJ = $(CORE_OBJ) PERLEXE_OBJ = perlmain$(o) +PERLEXEST_OBJ = perlmainst$(o) PERLDLL_OBJ += $(WIN32_OBJ) $(DLL_OBJ) @@ -987,7 +1006,7 @@ ODBCCP32_DLL = $(windir)\system\odbccp32.dll all : .\config.h $(GLOBEXE) $(MINIPERL) $(MK2) \ $(RIGHTMAKE) $(MINIMOD) $(CONFIGPM) $(UNIDATAFILES) $(PERLEXE) \ - $(X2P) MakePPPort Extensions + $(X2P) MakePPPort Extensions $(PERLSTATIC) reonly : .\config.h $(GLOBEXE) $(MINIPERL) $(MK2) \ $(RIGHTMAKE) $(MINIMOD) $(CONFIGPM) $(UNIDATAFILES) $(PERLEXE) \ @@ -995,6 +1014,8 @@ reonly : .\config.h $(GLOBEXE) $(MINIPERL) $(MK2) \ $(DYNALOADER)$(o) : $(DYNALOADER).c $(CORE_H) $(EXTDIR)\DynaLoader\dlutils.c +static: $(PERLEXESTATIC) + #---------------------------------------------------------------- #-------------------- BEGIN Win95 SPECIFIC ---------------------- @@ -1177,6 +1198,25 @@ $(PERLDLL): perldll.def $(PERLDLL_OBJ) $(PERLDLL_RES) Extensions_static .ENDIF $(XCOPY) $(PERLIMPLIB) $(COREDIR) +$(PERLSTATICLIB): Extensions_static +.IF "$(CCTYPE)" == "BORLAND" + $(LIB32) $(LIB_FLAGS) $@ \ + @$(mktmp $(subst,\,$B $(shell @type Extensions_static)) \ + $(PERLDLL_OBJ:s,\,$B,)) +.ELIF "$(CCTYPE)" == "GCC" +# XXX: It would be nice if MinGW's ar accepted a temporary file, but this +# doesn't seem to work: +# $(LIB32) $(LIB_FLAGS) $@ \ +# $(mktmp $(LKPRE) $(subst,\,$B $(shell @type Extensions_static)) \ +# $(PERLDLL_OBJ:s,\,$B,) $(LKPOST)) + $(LIB32) $(LIB_FLAGS) $@ \ + $(subst,\,$B $(shell @type Extensions_static)) \ + $(PERLDLL_OBJ:s,\,$B,) +.ELSE + $(LIB32) $(LIB_FLAGS) -out:$@ @Extensions_static \ + @$(mktmp $(PERLDLL_OBJ:s,\,$B,)) +.ENDIF + $(XCOPY) $(PERLSTATICLIB) $(COREDIR) $(PERLEXE_ICO): $(MINIPERL) makeico.pl $(MINIPERL) makeico.pl > $@ @@ -1222,6 +1262,12 @@ perlmain.c : runperl.c perlmain$(o) : perlmain.c $(CC) $(CFLAGS_O) -UPERLDLL $(OBJOUT_FLAG)$@ -c perlmain.c +perlmainst.c : runperl.c + copy runperl.c perlmainst.c + +perlmainst$(o) : perlmainst.c + $(CC) $(CFLAGS_O) -DPERLDLL $(OBJOUT_FLAG)$@ -c perlmainst.c + $(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ) $(PERLEXE_RES) .IF "$(CCTYPE)" == "BORLAND" $(LINK32) -Tpe -ap $(BLINK_FLAGS) \ @@ -1241,6 +1287,24 @@ $(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ) $(PERLEXE_RES) copy splittree.pl .. $(MINIPERL) -I..\lib ..\splittree.pl "../LIB" $(AUTODIR) +$(PERLEXESTATIC): $(PERLSTATICLIB) $(CONFIGPM) $(PERLEXEST_OBJ) $(PERLEXE_RES) +.IF "$(CCTYPE)" == "BORLAND" + $(LINK32) -Tpe -ap $(BLINK_FLAGS) \ + @$(mktmp c0x32$(o) $(PERLEXEST_OBJ:s,\,$B,)$N \ + $(@:s,\,$B,),$N \ + $(subst,\,$B $(shell @type Extensions_static)) \ + $(PERLSTATICLIB) $(LIBFILES)$N) +.ELIF "$(CCTYPE)" == "GCC" + $(LINK32) -mconsole -o $@ $(BLINK_FLAGS) \ + $(mktmp $(LKPRE) $(subst,\,$B $(shell @type Extensions_static)) \ + $(PERLSTATICLIB) $(LIBFILES) $(PERLEXEST_OBJ) $(LKPOST)) +.ELSE + $(LINK32) -subsystem:console -out:$@ -stack:0x1000000 $(BLINK_FLAGS) \ + @Extensions_static $(PERLSTATICLIB) \ + $(LIBFILES) $(PERLEXEST_OBJ) $(SETARGV_OBJ) $(PERLEXE_RES) + $(EMBED_EXE_MANI) +.ENDIF + $(DYNALOADER).c: $(MINIPERL) $(EXTDIR)\DynaLoader\dl_win32.xs $(CONFIGPM) if not exist $(AUTODIR) mkdir $(AUTODIR) cd $(EXTDIR)\$(*B) && ..\$(MINIPERL) -I..\..\lib $(*B)_pm.PL @@ -1270,7 +1334,7 @@ Extensions_reonly : buildext.pl $(PERLDEP) $(CONFIGPM) $(MINIPERL) -I..\lib buildext.pl $(MAKE) $(PERLDEP) $(EXTDIR) --dynamic +re $(MINIPERL) -I..\lib buildext.pl $(MAKE) $(PERLDEP) ext --dynamic +re -Extensions_static : buildext.pl +Extensions_static : buildext.pl $(PERLDEP) $(CONFIGPM) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib buildext.pl $(MAKE) $(PERLDEP) $(EXTDIR) --static $(MINIPERL) -I..\lib buildext.pl $(MAKE) $(PERLDEP) ext --static @@ -1347,7 +1411,8 @@ utils: $(PERLEXE) $(X2P) distclean: realclean -del /f $(MINIPERL) $(PERLEXE) $(PERLDLL) $(GLOBEXE) \ - $(PERLIMPLIB) ..\miniperl$(a) $(MINIMOD) + $(PERLIMPLIB) ..\miniperl$(a) $(MINIMOD) \ + $(PERLEXESTATIC) $(PERLSTATICLIB) -del /f *.def *.map -del /f $(DYNALOADER).c -del /f $(EXTDIR)\DynaLoader\dl_win32.xs @@ -1414,7 +1479,8 @@ distclean: realclean perldoc perlivp dprofpp libnetcfg enc2xs piconv cpan *.bat \ xsubpp instmodsh prove ptar ptardiff shasum corelist config_data -cd ..\x2p && del /f find2perl s2p psed *.bat - -del /f ..\config.sh ..\splittree.pl perlmain.c dlutils.c config.h.new + -del /f ..\config.sh ..\splittree.pl perlmain.c dlutils.c config.h.new \ + perlmainst.c -del /f $(CONFIGPM) -del /f bin\*.bat -del /f perllibst.h @@ -1507,11 +1573,14 @@ _clean : -@erase $(MINIPERL) -@erase perlglob$(o) -@erase perlmain$(o) + -@erase perlmainst$(o) -@erase config.w32 -@erase /f config.h -@erase $(GLOBEXE) -@erase $(PERLEXE) -@erase $(WPERLEXE) + -@erase $(PERLEXESTATIC) + -@erase $(PERLSTATICLIB) -@erase $(PERLDLL) -@erase $(CORE_OBJ) -if exist $(MINIDIR) rmdir /s /q $(MINIDIR) diff --git a/win32/runperl.c b/win32/runperl.c index 85fd831..b76f8ba 100644 --- a/win32/runperl.c +++ b/win32/runperl.c @@ -6,9 +6,14 @@ /* Mingw32 defaults to globing command line * This is inconsistent with other Win32 ports and * seems to cause trouble with passing -DXSVERSION=\"1.6\" - * So we turn it off like this: + * So we turn it off like this, but only when compiling + * perlmain.c: perlmainst.c is linked into the same executable + * as win32.c, which also does this, so we mustn't do it twice + * otherwise we get a multiple definition error. */ +#ifndef PERLDLL int _CRT_glob = 0; +#endif #endif