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