]> git.imager.perl.org - imager.git/blob - TIFF/Makefile.PL
don't supply a default for a missing channel list
[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 $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
19
20 my %opts = 
21   (
22    NAME => 'Imager::File::TIFF',
23    VERSION_FROM => 'TIFF.pm',
24    OBJECT => 'TIFF.o imtiff.o',
25    clean => { FILES => 'testout' },
26   );
27
28 my @inc;
29 if ($BUILDING_IMAGER) {
30   push @inc, "-I..";
31   unshift @INC, "../lib";
32 }
33 else {
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
41   my @Imager_req = ( Imager => "0.86" );
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 => "git://git.imager.perl.org/imager.git",
58         bugtracker => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager",
59        },
60       };
61     $opts{PREREQ_PM} =
62       {
63        @Imager_req,
64       };
65   }
66 }
67
68 require Imager::Probe;
69
70 my %probe =
71   (
72    name => "TIFF",
73    inccheck => sub { -e File::Spec->catfile($_[0], "tiffio.h") },
74    libbase => "tiff",
75    testcode => _tiff_test_code(),
76    testcodeheaders => [ "tiffio.h", "stdio.h", "string.h" ],
77    incpath => \@incpaths,
78    libpath => \@libpaths,
79   );
80
81 my $probe_res = Imager::Probe->probe(\%probe);
82 if ($probe_res) {
83   $IMAGER_LIBS{TIFF} = 1;
84
85   push @inc, $probe_res->{INC};
86   $opts{LIBS} = $probe_res->{LIBS};
87   $opts{DEFINE} = $probe_res->{DEFINE};
88   $opts{INC} = "@inc";
89
90   if ($MM_ver > 6.06) {
91     $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
92     $opts{ABSTRACT} = 'TIFF image file support for Imager';
93   }
94   
95   WriteMakefile(%opts);
96 }
97 else {
98   $IMAGER_LIBS{TIFF} = 0;
99
100   if ($BUILDING_IMAGER) {
101     ExtUtils::MakeMaker::WriteEmptyMakefile(%opts);
102   }
103   else {
104     # fail in good way
105     die "OS unsupported: TIFF libraries or headers not found\n";
106   }
107 }
108
109 sub _tiff_test_code {
110   return <<'CODE';
111 static const char ver_base[] = ", Version ";
112 static const size_t ver_base_len = sizeof(ver_base) - 1;
113 const char *ver_str = TIFFGetVersion();
114 const char *ver_start = strstr(ver_str, ver_base);
115 const char *ver_end;
116 int ver_len;
117
118 if (ver_start && ver_start[ver_base_len] >= '3' && ver_start[ver_base_len] < '9') {
119   ver_start += ver_base_len;
120   ver_end = ver_start;
121   while (*ver_end && (*ver_end == '.' || *ver_end >= '0' && *ver_end <= '9'))
122     ++ver_end;
123   ver_len = ver_end - ver_start;
124 }
125 else {
126   ver_start = "(unknown)";
127   ver_len = strlen(ver_start);
128 }
129
130 fprintf(stderr, "TIFF: library version %.*s, header version %ld\n", ver_len, ver_start, TIFFLIB_VERSION);
131 if (TIFFLIB_VERSION == 20090820) {
132   fprintf(stderr, "TIFF: this appears to be libtiff 3.9.0 which introduced a serious bug\n");
133   fprintf(stderr, "TIFF: please install 3.9.1\n");
134   return 1;
135 }
136 return 0;
137 CODE
138 }