http://www.perlmonks.org?node_id=905340

patcat88 has asked for the wisdom of the Perl Monks concerning the following question:

Is there any way to get makemaker to make 2 separate XS or 1 XS and 1 pure C DLLs on Windows?

I am trying to code a makefile.pl which will compile not only the XS DLL, but a pure C DLL which is dynamically loaded and unloaded (LoadLibrary/FreeLibrary) by the XS DLL.

I tried using the XS key  XS                 =>  {'ModuleName.xs' => 'ModuleName.c', 'ModuleNameCLib.xs' => 'ModuleNameCLib.c'}, in hash that goes to WriteMakefile, but the final makefile never mentions ModuleNameCLib, only ModuleName.

Edit, reading through the final makefile, it seems impossible for more than 1 DLL to be built. It seems to me, that the only thing I can do, is to put in my own target and hook it on INST_DYNAMIC_DEP, or overload the subdirs target. Copying of PMs are unlimited though, unlike XS or C parts of the perl module.

2nd edit, I figured this is the way to build another non-xs DLL with makemaker, works for me on windows with VS. Its added to makefile.pl the module ISN'T named 2ndlib BTW. We actually compiled 2ndlib.xs, not 2ndlib.c, but 2ndlib.xs is NOT an XS file, xsubpp will complain with

Didn't find a 'MODULE ... PACKAGE ... PREFIX' line

but it can be safely ignored I guess. I put the non-XS dll in a libs folder under the module's auto folder, to prevent dynaloader from trying to accidentally run the DLL, not sure what would happen if it was in the module's auto folder, 2ndlib.dll doesn't export a boot function. 2ndlib.dll isnt a real library, its just for this code sample.
package MY; sub postamble { return <<'ENDTOKEN'; dynamic:: $(INST_ARCHAUTODIR)\libs\2ndlib.dll $(INST_ARCHAUTODIR)\libs\2ndlib.dll : 2ndlib.obj $(LD) -out:$@ $(LDDLFLAGS) 2ndlib.obj $(OTHERLDFLAGS) $(MYEXTLIB) +$(PERL_ARCHIVE) $(LDLOADLIBS) -def:2ndlib.def $(INST_ARCHAUTODIR)\libs\.exists : Makefile.PL $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR)\libs $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHAUTODIR)\libs $(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)\libs\.exists blibdirs : $(INST_ARCHAUTODIR)\libs\.exists ENDTOKEN }