1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
#!perl -w
use strict;
use ExtUtils::MakeMaker;
use Getopt::Long;
use Config;
my $verbose = $ENV{IM_VERBOSE};
my @libpaths;
my @incpaths;
GetOptions("incpath=s", \@incpaths,
"libpath=s" => \@libpaths,
"verbose|v" => \$verbose);
our $BUILDING_IMAGER;
our %IMAGER_LIBS;
my $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
my $define = "";
my $fp_rep = unpack("H*", pack("f", 1.25));
if ($fp_rep eq "0000a03f" || $fp_rep eq "3fa00000") {
$define = "-DIEEEFP_TYPES";
}
my %opts =
(
NAME => 'Imager::File::TIFF',
VERSION_FROM => 'TIFF.pm',
OBJECT => 'TIFF.o imtiff.o',
DEFINE => $define,
clean => { FILES => 'testout' },
);
my @inc;
if ($BUILDING_IMAGER) {
push @inc, "-I..";
unshift @INC, "../lib";
}
else {
unshift @INC, "inc";
print "TIFF: building independently\n";
require Imager::ExtUtils;
push @inc, Imager::ExtUtils->includes;
$opts{TYPEMAPS} = [ Imager::ExtUtils->typemap ];
# Imager required configure through use
my @Imager_req = ( Imager => "0.94" );
if ($MM_ver >= 6.46) {
$opts{META_MERGE} =
{
configure_requires =>
{
@Imager_req,
},
build_requires =>
{
@Imager_req,
"Test::More" => "0.47",
},
resources =>
{
homepage => "http://imager.perl.org/",
repository => "git://git.imager.perl.org/imager.git",
bugtracker => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager",
},
};
$opts{PREREQ_PM} =
{
@Imager_req,
XSLoader => 0,
};
}
}
require Imager::Probe;
my %probe =
(
name => "TIFF",
inccheck => sub { -e File::Spec->catfile($_[0], "tiffio.h") },
libbase => "tiff",
testcode => _tiff_test_code(),
testcodeheaders => [ "tiffio.h", "stdio.h", "string.h" ],
incpath => \@incpaths,
libpath => \@libpaths,
verbose => $verbose,
);
my $probe_res = Imager::Probe->probe(\%probe);
if ($probe_res) {
$IMAGER_LIBS{TIFF} = 1;
push @inc, $probe_res->{INC};
$opts{LIBS} = $probe_res->{LIBS};
$opts{DEFINE} .= " $probe_res->{DEFINE}";
$opts{INC} = "@inc";
if ($MM_ver > 6.06) {
$opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
$opts{ABSTRACT} = 'TIFF image file support for Imager';
}
WriteMakefile(%opts);
}
else {
$IMAGER_LIBS{TIFF} = 0;
if ($BUILDING_IMAGER) {
ExtUtils::MakeMaker::WriteEmptyMakefile(%opts);
}
else {
# fail in good way
die "OS unsupported: TIFF libraries or headers not found\n";
}
}
sub _tiff_test_code {
return <<'CODE';
static const char ver_base[] = ", Version ";
static const size_t ver_base_len = sizeof(ver_base) - 1;
const char *ver_str = TIFFGetVersion();
const char *ver_start = strstr(ver_str, ver_base);
const char *ver_end;
int ver_len;
if (ver_start && ver_start[ver_base_len] >= '3' && ver_start[ver_base_len] < '9') {
ver_start += ver_base_len;
ver_end = ver_start;
while (*ver_end && (*ver_end == '.' || *ver_end >= '0' && *ver_end <= '9'))
++ver_end;
ver_len = ver_end - ver_start;
}
else {
ver_start = "(unknown)";
ver_len = strlen(ver_start);
}
fprintf(stderr, "TIFF: library version %.*s, header version %ld\n", ver_len, ver_start, TIFFLIB_VERSION);
if (TIFFLIB_VERSION == 20090820) {
fprintf(stderr, "TIFF: this appears to be libtiff 3.9.0 which introduced a serious bug\n");
fprintf(stderr, "TIFF: please install 3.9.1\n");
return 1;
}
return 0;
CODE
}
|