Code: Select all
Index: PerlMagick/Makefile.PL
===================================================================
--- PerlMagick/Makefile.PL (revision 333)
+++ PerlMagick/Makefile.PL (working copy)
@@ -23,7 +23,105 @@
use ExtUtils::MakeMaker;
use Config;
+use File::Spec::Functions qw/catfile catdir devnull catpath splitpath/;
+use Cwd;
+sub AutodetectWin32gcc {
+ my $wrkdir = getcwd();
+ my $devnull = devnull();
+
+ my @incdir = ();
+ my @libdir = ($wrkdir);
+ my @bindir = ();
+
+ #try to get configuration info via identify or convert utilities
+ my $conf = `identify -list Configure 2>$devnull` || `convert -list Configure 2>$devnull`;
+ foreach my $line (split '\n', $conf) {
+ if ($line =~ /^Path:\s+(.*)/) {
+ my ($vol,$dir,$file) = splitpath($1);
+ next unless $dir;
+ my $dirpath = catpath( $vol, $dir);
+ my (@l,@b,@i) = ( (),(),() );
+
+ # try to detect 'lib' dir
+ push @l, catfile($dirpath,'..','lib');
+ push @l, catfile($dirpath,'..','..','lib');
+ push @l, catfile($dirpath,'..','..','..','lib');
+ foreach (@l) { push @libdir, $_ if (-d $_) };
+
+ # try to detect 'bin' dir
+ push @b, catfile($dirpath,'..');
+ push @b, catfile($dirpath,'..','bin');
+ push @b, catfile($dirpath,'..','..');
+ push @b, catfile($dirpath,'..','..','bin');
+ push @b, catfile($dirpath,'..','..','..');
+ push @b, catfile($dirpath,'..','..','..','bin');
+ foreach (@b) { push @bindir, $_ if (-e "$_/convert.exe" || -e "$_/identify.exe") };
+
+ # try to detect 'include' dir
+ push @i, catfile($dirpath,'..','include');
+ push @i, catfile($dirpath,'..','include','ImageMagick');
+ push @i, catfile($dirpath,'..','..','include');
+ push @i, catfile($dirpath,'..','..','include','ImageMagick');
+ push @i, catfile($dirpath,'..','..','..','include');
+ push @i, catfile($dirpath,'..','..','..','include','ImageMagick');
+ foreach (@i) { push @incdir, $_ if (-e "$_/magick/MagickCore.h") };
+ }
+ };
+
+ foreach my $bin (@bindir) {
+ opendir(my $bindir, $bin) or die qq{Cannot opendir $bin: $!};
+ my @dlls = map {catfile($bin, $_)} grep /^\S*magick[^\+]\S*?\.dll$/i, readdir $bindir;
+ foreach my $d (@dlls) {
+ unlink "$wrkdir/libMagickCore.def", "$wrkdir/libMagickCore.a";
+ system("pexports \"$d\" >\"$wrkdir/libMagickCore.def\" 2>$devnull");
+ open(DEF, "<$wrkdir/libMagickCore.def");
+ my @found = grep(/InitializeMagickResources/, <DEF>); #checking if we have taken the right DLL
+ close(DEF);
+ next unless(@found);
+ print STDERR "Gonna create 'libMagickCore.a' from '$d'\n";
+ system("dlltool -D \"$d\" -d \"$wrkdir/libMagickCore.def\" -l \"$wrkdir/libMagickCore.a\" 2>$devnull");
+ last if -s "$wrkdir/libMagickCore.a";
+ }
+ last if -s "$wrkdir/libMagickCore.a";
+ }
+
+ unless(@incdir && @libdir && @bindir && (-s "$wrkdir/libMagickCore.a")) {
+ print STDERR <<EOF
+################################### WARNING! ###################################
+# It seems that you are trying to install Perl::Magick on a MS Windows box with
+# perl + gcc compiler (e.g. strawberry perl), however we cannot find ImageMagick
+# binaries installed on your system.
+#
+# Please check the following prerequisites:
+#
+# 1) You need to have installed ImageMagick Windows binaries from
+# http://www.imagemagick.org/script/binary-releases.php#windows
+#
+# 2) We only support dynamic (DLL) ImageMagick binaries
+# note: it is not possible to mix 32/64-bit binaries of perl and ImageMagick
+#
+# 3) During installation select that you want to install ImageMagick's
+# development files (libraries+headers)
+#
+# 4) You also need to have ImageMagick's directory in your PATH
+# note: we are checking the presence of convert.exe and/or identify.exe tools
+#
+# 5) You might need Visual C++ Redistributable Package installed on your system
+# see instructions on ImageMagick's Binary Release webpage
+#
+# We are gonna continue, but chances for successful build are very low!
+################################################################################
+EOF
+ }
+
+ my $inc = join ' ', map "-I\"$_\"", @incdir;
+ my $lib = join ' ', map "-L\"$_\"", @libdir;
+ $lib .= " -lMagickCore";
+
+ return ($inc, $lib, '-O2');
+}
+
# Compute test specification
my $delegate_tests='t/*.t';
my $delegate;
@@ -39,6 +137,16 @@
}
}
+# defaults for LIBS & INC & CCFLAGS params that we later pass to Writemakefile
+my $INC_val = '-I../ -I.. -I/usr/include/freetype2 -I/usr/include/libxml2 -I"' . $Config{'usrinc'} . '/ImageMagick"';
+my $LIBS_val = '-L../magick/.libs -lMagickCore -L../wand/.libs -lperl -lm';
+my $CCFLAGS_val = "$Config{'ccflags'} -fopenmp -g -O2 -Wall -W -pthread";
+
+if (($^O eq 'MSWin32') && ($Config{cc} =~ /gcc/)) {
+ # a special setup for strawberry perl
+ ($INC_val, $LIBS_val, $CCFLAGS_val) = AutodetectWin32gcc();
+}
+
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile
@@ -59,7 +167,7 @@
'DEFINE' => ' -D_LARGE_FILES=1 -DHAVE_CONFIG_H', # e.g., '-DHAVE_SOMETHING'
# Header search specfication and preprocessor flags
- 'INC' => '-I../ -I.. -I/usr/include/freetype2 -I/usr/include/libxml2 -I"' . $Config{'usrinc'} . '/ImageMagick"',
+ 'INC' => $INC_val,
# C compiler
#'CC' => 'gcc -std=gnu99',
@@ -68,7 +176,7 @@
# 'CPPFLAGS' => "$Config{'cppflags'} -I/usr/include/freetype2 -I/usr/include/libxml2",
# C compiler flags (e.g. -O -g)
- 'CCFLAGS' => "$Config{'ccflags'} -fopenmp -g -O2 -Wall -W -pthread",
+ 'CCFLAGS' => $CCFLAGS_val,
# Linker
#'LD' => $Config{'ld'} == $Config{'cc'} ? 'gcc -std=gnu99' : $Config{'ld'},
@@ -83,7 +191,7 @@
'INSTALLBIN' => '/usr/local/bin',
# Library specification
- 'LIBS' => [ '-L../magick/.libs -lMagickCore -L../wand/.libs -lperl -lm' ],
+ 'LIBS' => [ $LIBS_val ],
# Perl binary name (if a Perl binary is built)
'MAP_TARGET' => 'PerlMagick',
With current SVN trunk version there are still some warnings during compilation:
With current SVN trunk version there is one failing test on Win32/strawberry in t/x11/write.t (all other tests pass):