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