From bef060c33110de5d3579248dff9a2c0f1f60dfe7 Mon Sep 17 00:00:00 2001
From: Ash Berlin <ash_github@firemirror.com>
Date: Fri, 1 May 2009 12:42:48 +0100
Subject: [PATCH] Fix linking of modules on Win32 (they need a .lib there at compile time)
---
Changes | 3 +++
lib/ExtUtils/Depends.pm | 37 ++++++++++++++++++++++++++++++++++---
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/Changes b/Changes
index 522ad41..5dff481 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
Revision history for Perl extension ExtUtils::Depends.
+ - Support linking against .dll files correctly for Strawbery perl (needed
+ for Devel::Declare. Patch by Ash Berlin)
+
0.301 Sat Sep 6 20:11:01 CEST 2008
- On Cygwin, link directly against the DLLs of dependencies. Patch by
Yaakov.
diff --git a/lib/ExtUtils/Depends.pm b/lib/ExtUtils/Depends.pm
index adc9d79..50b4317 100644
--- a/lib/ExtUtils/Depends.pm
+++ b/lib/ExtUtils/Depends.pm
@@ -7,6 +7,7 @@ package ExtUtils::Depends;
use strict;
use warnings;
use Carp;
+use Config;
use File::Find;
use File::Spec;
use Data::Dumper;
@@ -241,7 +242,7 @@ sub get_makefile_vars {
# collect and uniquify things from the dependencies.
# first, ensure they are completely loaded.
$self->load_deps;
-
+
##my @defbits = map { split } @{ $self->{defines} };
my @incbits = map { split } @{ $self->{inc} };
my @libsbits = split /\s+/, $self->{libs};
@@ -282,6 +283,8 @@ sub get_makefile_vars {
TYPEMAPS => [@typemaps],
);
+ $self->build_dll_lib(\%vars) if $^O =~ /MSWin32/;
+
# we don't want to provide these if there is no data in them;
# that way, the caller can still get default behavior out of
# MakeMaker when INC, LIBS and TYPEMAPS are all that are required.
@@ -297,12 +300,20 @@ sub get_makefile_vars {
%vars;
}
+sub build_dll_lib {
+ my ($self, $vars) = @_;
+ (my $stem = $self->{name}) =~ s/^.*:://;
+ my $ext = $Config{lib_ext};
+ $vars->{macro} ||= {};
+ $vars->{macro}{'INST_DNYAMIC_LIB'} = '$(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT)';
+}
+
sub find_extra_libs {
my $self = shift;
my %mappers = (
- MSWin32 => sub { $_[0] . '.lib' },
- cygwin => sub { $_[0] . '.dll'},
+ MSWin32 => sub { $_[0] . '\.(?:lib|a)' },
+ cygwin => sub { $_[0] . '\.dll'},
);
my $mapper = $mappers{$^O};
return () unless defined $mapper;
@@ -331,6 +342,26 @@ sub find_extra_libs {
return @found_libs;
}
+
+require ExtUtils::MY;
+package #
+ ExtUtils::MM;
+
+
+# This isn't actualy a static lib. it just has the same name on Win32
+sub static_lib {
+
+ my $base = shift->SUPER::static_lib(@_);
+
+ return $base
+ unless $^O =~ /MSWin32/;
+
+ return "# This isn't actualy a static lib. it just has the same name on Win32\n" .
+ $(INST_DNYAMIC_LIB): $(INST_DYNAMIC)'. "\n\t" .
+ 'dlltool --def $(EXPORT_LIST) --output-lib $@ --dllname $(BASEEXT).$(SO) $(INST_DYNAMIC)' .
+ "\n\ndynamic:: \$(INST_DNYAMIC_LIB)\n";
+}
+
1;
__END__
--
1.6.0.2+GitX