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