part1: Support the standard cyg dll prefix, which is e.g. needed for FFI's.
Ctypes and C::DynaLib use DynaLoader to find dlls.
part2: With -DUSEIMPORTLIB DynaLoader symbols link against the prefixed
symbol names for the .dll.a importlib, but we need to link against the
symbols directly. We don't link Dynaloader against libperl.dll.a.
Otherwise:
$ g++-4 -o cygperl5_13_4.dll --shared perlsrc.o cygwin.o DynaLoader.o -ldl -lcrypt
Creating library file: libperl.dll.a
DynaLoader.o: In function `XS_DynaLoader_dl_undef_symbols':
ext/DynaLoader/DynaLoader.c:346: undefined reference to `__imp__PL_stack_sp'
ext/DynaLoader/DynaLoader.c:346: undefined reference to `__imp__PL_markstack_ptr'
ext/DynaLoader/DynaLoader.c:346: undefined reference to `__imp__PL_stack_base'
# these should be ordered with the most likely first
push(@names,"$_.$dl_dlext") unless m/\.$dl_dlext$/o;
push(@names,"$_.$dl_so") unless m/\.$dl_so$/o;
+ push(@names,"cyg$_.$dl_so") if !m:/: and $^O eq 'cygwin';
push(@names,"lib$_.$dl_so") unless m:/:;
push(@names,"$_.a") if !m/\.a$/ and $dlsrc eq "dl_dld.xs";
push(@names, $_);
clean => {FILES => 'DynaLoader.c DynaLoader.xs DynaLoader.pm'},
);
+sub MY::cflags {
+ package MY;
+ my $flags = shift->SUPER::cflags(@_);
+ if ($flags =~ /-DUSEIMPORTLIB/m) {
+ $flags =~ s/-DUSEIMPORTLIB/-UUSEIMPORTLIB/m;
+ }
+ $flags;
+}
+
sub MY::postamble {
my $test_xs;