- Modifications to compile ImageMagick

This commit is contained in:
Santi Noreña 2013-02-19 18:37:48 +01:00
parent 615ec83706
commit 83522c16c3
3442 changed files with 57 additions and 412926 deletions

View file

@ -0,0 +1,270 @@
# Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization
# dedicated to making software imaging solutions freely available.
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at
#
# http://www.imagemagick.org/script/license.php
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Exercise all regression tests:
#
# make test
#
# Exersise one regression test:
#
# make TEST_VERBOSE=1 TEST_FILES=t/filter.t test
#
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');
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');
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');
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(/MagickCoreGenesis/, <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;
return ($inc, $lib);
}
sub AutodetectDelegates {
#try to get configuration info via identify or convert utilities
my $devnull = devnull();
my $conf = `identify -list Configure 2>$devnull` || `convert -list Configure 2>$devnull`;
my @delegates = ();
foreach my $line (split '\n', $conf) {
next unless $line =~ /^DELEGATES\s+/;
(undef, @delegates) = split /\s+/, $line;
last;
};
return @delegates;
}
# Compute test specification
my $delegate_tests='t/*.t';
my @tested_delegates = qw/bzlib djvu fftw fontconfig freetype jpeg jng jp2 lcms mpeg png rsvg tiff x11 xml wmf zlib/;
my @supported_delegates = AutodetectDelegates();
# find the intersection of tested and supported delegates
my %seen_delegates = ();
$seen_delegates{$_}++ for @supported_delegates;
foreach my $delegate (@tested_delegates) {
if ( $seen_delegates{$delegate} ) {
if ( -d "t/$delegate" ) {
if ( defined($ENV{'DISPLAY'}) && ($^O ne 'MSWin32') ) {
if ( defined $ENV{'DISPLAY'} ) {
$delegate_tests .= " t/$delegate/*.t";
}
next;
}
$delegate_tests .= " t/$delegate/*.t";
}
}
}
# defaults for LIBS & INC & CCFLAGS params that we later pass to Writemakefile
my $INC_magick = '-I../ -I@top_srcdir@ @CPPFLAGS@ -I"' . $Config{'usrinc'} . '/ImageMagick"';
my $LIBS_magick = '-L../../magick/.libs -lMagickCore-@MAGICK_MAJOR_VERSION@.@MAGICK_ABI_SUFFIX@ -lperl @MATH_LIBS@';
my $CCFLAGS_magick = "$Config{'ccflags'} @CFLAGS@";
my $LDFLAGS_magick = "-L../../magick/.libs -lMagickCore-@MAGICK_MAJOR_VERSION@.@MAGICK_ABI_SUFFIX@ $Config{'ldflags'} @LDFLAGS@";
my $LDDLFLAGS_magick = "-L../../magick/.libs -lMagickCore-@MAGICK_MAJOR_VERSION@.@MAGICK_ABI_SUFFIX@ $Config{'lddlflags'} @LDFLAGS@";
if (($^O eq 'MSWin32') && ($Config{cc} =~ /gcc/)) {
my($Ipaths, $Lpaths) = AutodetectWin32gcc();
#
# Setup for strawberry perl.
#
$INC_magick = "$Ipaths";
$LIBS_magick = "-lMagickCore-@MAGICK_MAJOR_VERSION@.@MAGICK_ABI_SUFFIX@";
$CCFLAGS_magick = "$Config{'ccflags'}";
$LDFLAGS_magick = "$Config{'ldflags'} $Lpaths ";
$LDDLFLAGS_magick = "$Config{'lddlflags'} $Lpaths ";
}
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile
(
# Module description
'ABSTRACT' => 'ImageMagick PERL Extension (@MAGICK_ABI_SUFFIX@)',
# Perl module name is Image::Magick
'NAME' => 'Image::Magick::@MAGICK_ABI_SUFFIX@',
# Module author
'AUTHOR' => 'ImageMagick Studio LLC',
# Module version
'VERSION' => '@PACKAGE_PERL_VERSION@',
# Preprocessor defines
'DEFINE' => '@LFS_CPPFLAGS@ @DEFS@', # e.g., '-DHAVE_SOMETHING'
# Header search specfication and preprocessor flags
'INC' => $INC_magick,
# C compiler
#'CC' => '@CC@',
# C pre-processor flags (e.g. -I & -D options)
# 'CPPFLAGS' => "$Config{'cppflags'} @CPPFLAGS@",
# C compiler flags (e.g. -O -g)
'CCFLAGS' => $CCFLAGS_magick,
# Linker
#'LD' => $Config{'ld'} == $Config{'cc'} ? '@CC@' : $Config{'ld'},
# Linker flags for building an executable
'LDFLAGS' => $LDFLAGS_magick,
# Linker flags for building a dynamically loadable module
'LDDLFLAGS' => $LDDLFLAGS_magick,
# Install PerlMagick binary into ImageMagick bin directory
'INSTALLBIN' => '@BIN_DIR@',
# Library specification
'LIBS' => [ $LIBS_magick ],
# Perl binary name (if a Perl binary is built)
'MAP_TARGET' => 'PerlMagick',
# Let CFLAGS drive optimization flags by setting OPTIMIZE to empty
# 'OPTIMIZE' => '',
# Use same compiler as ImageMagick
'PERLMAINCC' => '@PERLMAINCC@ @OPENMP_CFLAGS@',
'PM' => { '@MAGICK_ABI_SUFFIX@.pm' => '$(INST_LIBDIR)/@MAGICK_ABI_SUFFIX@.pm' },
'XS' => { '@MAGICK_ABI_SUFFIX@.xs' => '@MAGICK_ABI_SUFFIX@.xs' },
'AR' => '@AR@',
'LD' => '@PERLMAINCC@',
# Set Perl installation prefix to ImageMagick installation prefix
# 'PREFIX' => '@prefix@',
# Include delegate directories in tests
test => { TESTS => $delegate_tests},
($Config{'archname'} =~ /-object$/i ? ('CAPI' => 'TRUE') : ()),
# sane vesion
depend => { '$(FIRST_MAKEFILE)' => '$(VERSION_FROM)' }
);
#
# Substitutions for "makeaperl" section.
#
sub MY::makeaperl {
package MY; # so that "SUPER" works right
my $inherited = shift->SUPER::makeaperl(@_);
# Stinky ExtUtils::MM_Unix likes to append its own library path to $(CC),
# prior to any user-specified library path so that an installed library is
# used rather than the library just built. This substitution function
# tries to insert our library path first. Also, use the same compiler used
# to build perlmain.c to link so that a C++ compiler may be used if
# necessary.
$inherited =~ s:MAP_LINKCMD\s.*\s*\$\(CC\):MAP_LINKCMD = \$(PERLMAINCC) -L@MAGICKCORE_PATH@: ;
$inherited;
}

View file

@ -0,0 +1,144 @@
package Image::Magick::@MAGICK_ABI_SUFFIX@;
# Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization
# dedicated to making software imaging solutions freely available.
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at
#
# http://www.imagemagick.org/script/license.php
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Initial version, written by Kyle Shorter.
use strict;
use Carp;
use vars qw($VERSION @ISA @EXPORT $AUTOLOAD);
require 5.002;
require Exporter;
require DynaLoader;
require AutoLoader;
@ISA = qw(Exporter DynaLoader);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
@EXPORT =
qw(
Success Transparent Opaque QuantumDepth QuantumRange MaxRGB
WarningException ResourceLimitWarning TypeWarning OptionWarning
DelegateWarning MissingDelegateWarning CorruptImageWarning
FileOpenWarning BlobWarning StreamWarning CacheWarning CoderWarning
ModuleWarning DrawWarning ImageWarning XServerWarning RegistryWarning
ConfigureWarning ErrorException ResourceLimitError TypeError
OptionError DelegateError MissingDelegateError CorruptImageError
FileOpenError BlobError StreamError CacheError CoderError
ModuleError DrawError ImageError XServerError RegistryError
ConfigureError FatalErrorException
);
$VERSION = '@PACKAGE_PERL_VERSION@';
sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
# XS function. If a constant is not found then control is passed
# to the AUTOLOAD in AutoLoader.
my $constname;
($constname = $AUTOLOAD) =~ s/.*:://;
die "&${AUTOLOAD} not defined. The required ImageMagick libraries are not installed or not installed properly.\n" if $constname eq 'constant';
my $val = constant($constname, @_ ? $_[0] : 0);
if ($! != 0) {
if ($! =~ /Invalid/) {
$AutoLoader::AUTOLOAD = $AUTOLOAD;
goto &AutoLoader::AUTOLOAD;
}
else {
my($pack,$file,$line) = caller;
die "Your vendor has not defined PerlMagick macro $pack\:\:$constname, used at $file line $line.\n";
}
}
eval "sub $AUTOLOAD { $val }";
goto &$AUTOLOAD;
}
bootstrap Image::Magick::@MAGICK_ABI_SUFFIX@ $VERSION;
# Preloaded methods go here.
sub new
{
my $this = shift;
my $class = ref($this) || $this || "Image::Magick::@MAGICK_ABI_SUFFIX@";
my $self = [ ];
bless $self, $class;
$self->set(@_) if @_;
return $self;
}
sub New
{
my $this = shift;
my $class = ref($this) || $this || "Image::Magick::@MAGICK_ABI_SUFFIX@";
my $self = [ ];
bless $self, $class;
$self->set(@_) if @_;
return $self;
}
# Autoload methods go after =cut, and are processed by the autosplit program.
END { UNLOAD () };
1;
__END__
=head1 NAME
Image::Magick::@MAGICK_ABI_SUFFIX@ - objected-oriented Perl interface to ImageMagick (@MAGICK_ABI_SUFFIX@). Use it to read, manipulate, or write an image or image sequence from within a Perl script.
=head1 SYNOPSIS
use Image::Magick::@MAGICK_ABI_SUFFIX@;
$p = new Image::Magick::@MAGICK_ABI_SUFFIX@;
$p->Read("imagefile");
$p->Set(attribute => value, ...)
($a, ...) = $p->Get("attribute", ...)
$p->routine(parameter => value, ...)
$p->Mogrify("Routine", parameter => value, ...)
$p->Write("filename");
=head1 DESCRIPTION
This Perl extension allows the reading, manipulation and writing of
a large number of image file formats using the ImageMagick library.
It was originally developed to be used by CGI scripts for Web pages.
A web page has been set up for this extension. See:
file://@DOCUMENTATION_PATH@/www/perl-magick.html
http://www.imagemagick.org/script/perl-magick.php
If you have problems, go to
http://www.imagemagick.org/discourse-server/viewforum.php?f=7
=head1 AUTHOR
Kyle Shorter magick-users@imagemagick.org
=head1 BUGS
Has all the bugs of ImageMagick and much, much more!
=head1 SEE ALSO
perl(1).
=cut

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
Image::Magick::@MAGICK_ABI_SUFFIX@ T_PTROBJ