diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-09-17 11:35:14 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-09-17 11:35:14 +0100 |
commit | 281da5eaa82c552216e167aece73c3f8df066bd4 (patch) | |
tree | 2c1d9ffab18972a69bcc1c399fb17a4a5caddb01 /win32 | |
parent | f58022876005bfeea1653994a1075151b3f2a25a (diff) | |
download | perl-281da5eaa82c552216e167aece73c3f8df066bd4.tar.gz |
Convert win32 to build DynaLoader with EU::MM in ext/DynaLoader
With help from Steve Hay. This converges the win32 build process with the
./Configure-based approach.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/Makefile | 38 | ||||
-rw-r--r-- | win32/dl_win32.xs | 205 | ||||
-rw-r--r-- | win32/makefile.mk | 35 |
3 files changed, 18 insertions, 260 deletions
diff --git a/win32/Makefile b/win32/Makefile index d4eb178f86..fa02e3bd4e 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -713,8 +713,6 @@ WIN32_SRC = $(WIN32_SRC) .\win32io.c WIN32_SRC = $(WIN32_SRC) .\$(CRYPT_SRC) !ENDIF -DLL_SRC = $(DYNALOADER).c - X2P_SRC = \ ..\x2p\a2p.c \ ..\x2p\hash.c \ @@ -775,7 +773,7 @@ MINICORE_OBJ = $(MICROCORE_OBJ:..\=.\mini\) \ $(MINIDIR)\perlio$(o) MINIWIN32_OBJ = $(WIN32_OBJ:.\=.\mini\) MINI_OBJ = $(MINICORE_OBJ) $(MINIWIN32_OBJ) -DLL_OBJ = $(DLL_SRC:.c=.obj) +DLL_OBJ = $(DYNALOADER) X2P_OBJ = $(X2P_SRC:.c=.obj) GENUUDMAP_OBJ = $(GENUUDMAP:.exe=.obj) @@ -801,7 +799,7 @@ STATIC_EXT = * !Win32 !SDBM_File !Encode STATIC_EXT = Win32CORE !ENDIF -DYNALOADER = $(EXTDIR)\DynaLoader\DynaLoader +DYNALOADER = ..\DynaLoader$(o) CFG_VARS = \ "INST_DRV=$(INST_DRV)" \ @@ -856,8 +854,6 @@ reonly : regnodes .\config.h ..\git_version.h $(GLOBEXE) $(MINIMOD) $(CONFIGPM) $(UNIDATAFILES) $(PERLEXE) $(X2P) Extensions_reonly @echo Perl and 're' are up to date. -$(DYNALOADER)$(o) : $(DYNALOADER).c $(CORE_H) $(EXTDIR)\DynaLoader\dlutils.c - static: $(PERLEXESTATIC) #------------------------------------------------------------ @@ -1035,21 +1031,6 @@ $(PERLEXESTATIC): $(PERLSTATICLIB) $(CONFIGPM) $(PERLEXEST_OBJ) $(PERLEXE_RES) $(LIBFILES) $(PERLEXEST_OBJ) $(SETARGV_OBJ) $(PERLEXE_RES) $(EMBED_EXE_MANI) -$(DYNALOADER).c: $(MINIPERL) $(EXTDIR)\DynaLoader\dl_win32.xs $(CONFIGPM) Extensions_nonxs - if not exist $(AUTODIR) mkdir $(AUTODIR) - cd $(EXTDIR)\$(*B) - ..\$(MINIPERL) -I..\..\lib $(*B)_pm.PL - ..\$(MINIPERL) -I..\..\lib XSLoader_pm.PL - cd ..\..\win32 - $(XCOPY) $(EXTDIR)\$(*B)\$(*B).pm $(LIBDIR)\$(NULL) - $(XCOPY) $(EXTDIR)\$(*B)\XSLoader.pm $(LIBDIR)\$(NULL) - cd $(EXTDIR)\$(*B) - $(XSUBPP) dl_win32.xs > $(*B).c - cd ..\..\win32 - -$(EXTDIR)\DynaLoader\dl_win32.xs: dl_win32.xs - copy dl_win32.xs $(EXTDIR)\DynaLoader\dl_win32.xs - MakePPPort: $(MINIPERL) $(CONFIGPM) Extensions_nonxs $(MINIPERL) -I..\lib $(ICWD) ..\mkppport @@ -1057,14 +1038,13 @@ MakePPPort_clean: -if exist $(MINIPERL) $(MINIPERL) -I..\lib ..\mkppport --clean #------------------------------------------------------------------------------- -# The rule for $(DYNALOADER).c makes DynaLoader.pm, and that is needed for -# ExtUtils::Mkbootstrap. There's no direct way to mark a dependency on +# There's no direct way to mark a dependency on # DynaLoader.pm, so this will have to do -Extensions: ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER).c +Extensions: ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --dynamic -Extensions_reonly: ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER).c +Extensions_reonly: ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --dynamic +re @@ -1077,6 +1057,10 @@ Extensions_nonxs: ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --nonxs +$(DYNALOADER) : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs + $(XCOPY) ..\*.h $(COREDIR)\*.* + $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --dynaloader + Extensions_clean: -if exist $(MINIPERL) $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --all --target=clean @@ -1155,10 +1139,6 @@ distclean: realclean $(PERLIMPLIB) ..\miniperl.lib $(MINIMOD) \ $(PERLEXESTATIC) $(PERLSTATICLIB) -del /f *.def *.map - -del /f $(DYNALOADER).c - -del /f $(EXTDIR)\DynaLoader\dl_win32.xs - -del /f $(EXTDIR)\DynaLoader\DynaLoader.pm - -del /f $(EXTDIR)\DynaLoader\XSLoader.pm -del /f $(LIBDIR)\Encode.pm $(LIBDIR)\encoding.pm $(LIBDIR)\Errno.pm -del /f $(LIBDIR)\Config.pod $(LIBDIR)\POSIX.pod $(LIBDIR)\threads.pm -del /f $(LIBDIR)\.exists $(LIBDIR)\attributes.pm $(LIBDIR)\DynaLoader.pm diff --git a/win32/dl_win32.xs b/win32/dl_win32.xs deleted file mode 100644 index 60ec703b92..0000000000 --- a/win32/dl_win32.xs +++ /dev/null @@ -1,205 +0,0 @@ -/* dl_win32.xs - * - * Platform: Win32 (Windows NT/Windows 95) - * Author: Wei-Yuen Tan (wyt@hip.com) - * Created: A warm day in June, 1995 - * - * Modified: - * August 23rd 1995 - rewritten after losing everything when I - * wiped off my NT partition (eek!) - */ - -/* Porting notes: - -I merely took Paul's dl_dlopen.xs, took out extraneous stuff and -replaced the appropriate SunOS calls with the corresponding Win32 -calls. - -*/ - -#define WIN32_LEAN_AND_MEAN -#ifdef __GNUC__ -#define Win32_Winsock -#endif -#include <windows.h> -#include <string.h> - -#define PERL_NO_GET_CONTEXT - -#include "EXTERN.h" -#include "perl.h" -#include "win32.h" - -#include "XSUB.h" - -typedef struct { - SV * x_error_sv; -} my_cxtx_t; /* this *must* be named my_cxtx_t */ - -#define DL_CXT_EXTRA /* ask for dl_cxtx to be defined in dlutils.c */ -#include "dlutils.c" /* SaveError() etc */ - -#define dl_error_sv (dl_cxtx.x_error_sv) - -static char * -OS_Error_String(pTHX) -{ - dMY_CXT; - DWORD err = GetLastError(); - STRLEN len; - if (!dl_error_sv) - dl_error_sv = newSVpvn("",0); - PerlProc_GetOSError(dl_error_sv,err); - return SvPV(dl_error_sv,len); -} - -static void -dl_private_init(pTHX) -{ - (void)dl_generic_private_init(aTHX); -} - -/* - This function assumes the list staticlinkmodules - will be formed from package names with '::' replaced - with '/'. Thus Win32::OLE is in the list as Win32/OLE -*/ -static int -dl_static_linked(char *filename) -{ - char **p; - char *ptr, *hptr; - static char subStr[] = "/auto/"; - char szBuffer[MAX_PATH]; - - /* change all the '\\' to '/' */ - strcpy(szBuffer, filename); - for(ptr = szBuffer; ptr = strchr(ptr, '\\'); ++ptr) - *ptr = '/'; - - /* delete the file name */ - ptr = strrchr(szBuffer, '/'); - if(ptr != NULL) - *ptr = '\0'; - - /* remove leading lib path */ - ptr = strstr(szBuffer, subStr); - if(ptr != NULL) - ptr += sizeof(subStr)-1; - else - ptr = szBuffer; - - for (p = staticlinkmodules; *p;p++) { - if (hptr = strstr(ptr, *p)) { - /* found substring, need more detailed check if module name match */ - if (hptr==ptr) { - return strcmp(ptr, *p)==0; - } - if (hptr[strlen(*p)] == 0) - return hptr[-1]=='/'; - } - }; - return 0; -} - -MODULE = DynaLoader PACKAGE = DynaLoader - -BOOT: - (void)dl_private_init(aTHX); - -void * -dl_load_file(filename,flags=0) - char * filename - int flags - PREINIT: - CODE: - { - DLDEBUG(1,PerlIO_printf(Perl_debug_log,"dl_load_file(%s):\n", filename)); - if (dl_static_linked(filename) == 0) { - RETVAL = PerlProc_DynaLoad(filename); - } - else - RETVAL = (void*) Win_GetModuleHandle(NULL); - DLDEBUG(2,PerlIO_printf(Perl_debug_log," libref=%x\n", RETVAL)); - ST(0) = sv_newmortal() ; - if (RETVAL == NULL) - SaveError(aTHX_ "load_file:%s", - OS_Error_String(aTHX)) ; - else - sv_setiv( ST(0), (IV)RETVAL); - } - -int -dl_unload_file(libref) - void * libref - CODE: - DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_unload_file(%lx):\n", PTR2ul(libref))); - RETVAL = FreeLibrary(libref); - if (!RETVAL) - SaveError(aTHX_ "unload_file:%s", OS_Error_String(aTHX)) ; - DLDEBUG(2,PerlIO_printf(Perl_debug_log, " retval = %d\n", RETVAL)); - OUTPUT: - RETVAL - -void * -dl_find_symbol(libhandle, symbolname) - void * libhandle - char * symbolname - CODE: - DLDEBUG(2,PerlIO_printf(Perl_debug_log,"dl_find_symbol(handle=%x, symbol=%s)\n", - libhandle, symbolname)); - RETVAL = (void*) GetProcAddress((HINSTANCE) libhandle, symbolname); - DLDEBUG(2,PerlIO_printf(Perl_debug_log," symbolref = %x\n", RETVAL)); - ST(0) = sv_newmortal() ; - if (RETVAL == NULL) - SaveError(aTHX_ "find_symbol:%s", - OS_Error_String(aTHX)) ; - else - sv_setiv( ST(0), (IV)RETVAL); - - -void -dl_undef_symbols() - PPCODE: - - - -# These functions should not need changing on any platform: - -void -dl_install_xsub(perl_name, symref, filename="$Package") - char * perl_name - void * symref - char * filename - CODE: - DLDEBUG(2,PerlIO_printf(Perl_debug_log,"dl_install_xsub(name=%s, symref=%x)\n", - perl_name, symref)); - ST(0) = sv_2mortal(newRV((SV*)newXS(perl_name, - (void(*)(pTHX_ CV *))symref, - filename))); - - -char * -dl_error() - CODE: - dMY_CXT; - RETVAL = dl_last_error; - OUTPUT: - RETVAL - -#if defined(USE_ITHREADS) - -void -CLONE(...) - CODE: - MY_CXT_CLONE; - - /* MY_CXT_CLONE just does a memcpy on the whole structure, so to avoid - * using Perl variables that belong to another thread, we create our - * own for this thread. - */ - MY_CXT.x_dl_last_error = newSVpvn("", 0); - -#endif - -# end. diff --git a/win32/makefile.mk b/win32/makefile.mk index a4dc36ab3a..af0cb3f21f 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -874,8 +874,6 @@ WIN32_SRC += .\win32io.c WIN32_SRC += .\$(CRYPT_SRC) .ENDIF -DLL_SRC = $(DYNALOADER).c - X2P_SRC = \ ..\x2p\a2p.c \ ..\x2p\hash.c \ @@ -934,7 +932,7 @@ WIN32_OBJ = $(WIN32_SRC:db:+$(o)) MINICORE_OBJ = $(MINIDIR)\{$(MICROCORE_OBJ:f) miniperlmain$(o) perlio$(o)} MINIWIN32_OBJ = $(MINIDIR)\{$(WIN32_OBJ:f)} MINI_OBJ = $(MINICORE_OBJ) $(MINIWIN32_OBJ) -DLL_OBJ = $(DLL_SRC:db:+$(o)) +DLL_OBJ = $(DYNALOADER) X2P_OBJ = $(X2P_SRC:db:+$(o)) GENUUDMAP_OBJ = $(GENUUDMAP:db:+$(o)) @@ -960,7 +958,7 @@ STATIC_EXT = * !Win32 !SDBM_File !Encode STATIC_EXT = Win32CORE .ENDIF -DYNALOADER = $(EXTDIR)\DynaLoader\DynaLoader +DYNALOADER = ..\DynaLoader$(o) # vars must be separated by "\t+~\t+", since we're using the tempfile # version of config_sh.pl (we were overflowing someone's buffer by @@ -1044,8 +1042,6 @@ reonly : regnodes .\config.h ..\git_version.h $(GLOBEXE) $(MINIPERL) $(MK2) \ $(RIGHTMAKE) $(MINIMOD) $(CONFIGPM) $(UNIDATAFILES) $(PERLEXE) \ $(X2P) Extensions_reonly -$(DYNALOADER)$(o) : $(DYNALOADER).c $(CORE_H) $(EXTDIR)\DynaLoader\dlutils.c - static: $(PERLEXESTATIC) #---------------------------------------------------------------- @@ -1367,18 +1363,6 @@ $(PERLEXESTATIC): $(PERLSTATICLIB) $(CONFIGPM) $(PERLEXEST_OBJ) $(PERLEXE_RES) $(EMBED_EXE_MANI) .ENDIF -$(DYNALOADER).c: $(MINIPERL) $(EXTDIR)\DynaLoader\dl_win32.xs $(CONFIGPM) Extensions_nonxs - if not exist $(AUTODIR) mkdir $(AUTODIR) - cd $(EXTDIR)\$(*B) && ..\$(MINIPERL) -I..\..\lib $(*B)_pm.PL - cd $(EXTDIR)\$(*B) && ..\$(MINIPERL) -I..\..\lib XSLoader_pm.PL - $(XCOPY) $(EXTDIR)\$(*B)\$(*B).pm $(LIBDIR)\$(NULL) - $(XCOPY) $(EXTDIR)\$(*B)\XSLoader.pm $(LIBDIR)\$(NULL) - cd $(EXTDIR)\$(*B) && $(XSUBPP) dl_win32.xs > $(*B).c - $(XCOPY) $(EXTDIR)\$(*B)\dlutils.c . - -$(EXTDIR)\DynaLoader\dl_win32.xs: dl_win32.xs - copy dl_win32.xs $(EXTDIR)\DynaLoader\dl_win32.xs - MakePPPort: $(MINIPERL) $(CONFIGPM) Extensions_nonxs $(MINIPERL) -I..\lib $(ICWD) ..\mkppport @@ -1386,14 +1370,13 @@ MakePPPort_clean: -if exist $(MINIPERL) $(MINIPERL) -I..\lib $(ICWD) ..\mkppport --clean #------------------------------------------------------------------------------- -# The rule for $(DYNALOADER).c makes DynaLoader.pm, and that is needed for -# ExtUtils::Mkbootstrap. There's no direct way to mark a dependency on +# There's no direct way to mark a dependency on # DynaLoader.pm, so this will have to do -Extensions : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER).c +Extensions : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --dynamic -Extensions_reonly : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER).c +Extensions_reonly : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(DYNALOADER) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --dynamic +re @@ -1406,6 +1389,10 @@ Extensions_nonxs : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) $(XCOPY) ..\*.h $(COREDIR)\*.* $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --nonxs +$(DYNALOADER) : ..\make_ext.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs + $(XCOPY) ..\*.h $(COREDIR)\*.* + $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --dynaloader + Extensions_clean : -if exist $(MINIPERL) $(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(EXTDIR) --all --target=clean @@ -1480,10 +1467,6 @@ distclean: realclean $(PERLIMPLIB) ..\miniperl$(a) $(MINIMOD) \ $(PERLEXESTATIC) $(PERLSTATICLIB) -del /f *.def *.map - -del /f $(DYNALOADER).c - -del /f $(EXTDIR)\DynaLoader\dl_win32.xs - -del /f $(EXTDIR)\DynaLoader\DynaLoader.pm - -del /f $(EXTDIR)\DynaLoader\XSLoader.pm -del /f $(LIBDIR)\Encode.pm $(LIBDIR)\encoding.pm $(LIBDIR)\Errno.pm -del /f $(LIBDIR)\Config.pod $(LIBDIR)\POSIX.pod $(LIBDIR)\threads.pm -del /f $(LIBDIR)\.exists $(LIBDIR)\attributes.pm $(LIBDIR)\DynaLoader.pm |