]> git.imager.perl.org - imager.git/blobdiff - PNG/Makefile.PL
map() would corrupt a channel if there was a gap in the arrayref of channels.
[imager.git] / PNG / Makefile.PL
index b610d96531023fe24db91c2fed87fee049459a4f..dc17470e929dcbbbaa7c71c7898fe10d2c3e8a03 100644 (file)
@@ -15,8 +15,6 @@ GetOptions("incpath=s", \@incpaths,
 our $BUILDING_IMAGER;
 our %IMAGER_LIBS;
 
-my $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
-
 my %opts = 
   (
    NAME => 'Imager::File::PNG',
@@ -25,6 +23,35 @@ my %opts =
    clean => { FILES => 'testout' },
   );
 
+if (eval { ExtUtils::MakeMaker->VERSION('6.46'); 1 }) {
+  $opts{LICENSE} = "perl_5";
+  $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
+  $opts{ABSTRACT} = 'PNG Image file support for Imager';
+  $opts{META_MERGE} =
+    {
+     'meta-spec' =>
+     {
+      version => "2",
+      url => "https://metacpan.org/pod/CPAN::Meta::Spec",
+     },
+     resources =>
+     {
+      homepage => "http://imager.perl.org/",
+      repository =>
+      {
+       type => "git",
+       url => "git://git.imager.perl.org/imager.git",
+       web => "http://git.imager.perl.org/imager.git",
+      },
+      bugtracker =>
+      {
+       web => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager",
+       mailto => 'bug-Imager@rt.cpan.org',
+      },
+     },
+    };
+}
+
 my @inc;
 if ($BUILDING_IMAGER) {
   push @inc, "-I..";
@@ -38,24 +65,38 @@ else {
   $opts{TYPEMAPS} = [ Imager::ExtUtils->typemap ];
 
   # Imager required configure through use
-  my @Imager_req = ( Imager => "0.86" );
-  if ($MM_ver >= 6.46) {
-    $opts{META_MERGE} =
+  my @Imager_req = ( Imager => "0.90" );
+  if (eval { ExtUtils::MakeMaker->VERSION('6.46'); 1 }) {
+    $opts{META_MERGE}{prereqs} =
       {
-       configure_requires => 
+       configure =>
+       {
+       requires =>
+       {
+        @Imager_req,
+       },
+       },
+       build =>
        {
-       @Imager_req,
+       requires =>
+       {
+        @Imager_req,
+        "Test::More" => "0.47",
+       }
        },
-       build_requires => 
+       runtime =>
        {
-       @Imager_req,
-       "Test::More" => "0.47",
+       requires =>
+       {
+        @Imager_req,
+       }
        },
-       resources =>
+       test =>
        {
-       homepage => "http://imager.perl.org/",
-       repository => "git://git.imager.perl.org/imager.git",
-       bugtracker => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager",
+       requires =>
+       {
+        "Test::More" => "0.47",
+       }
        },
       };
     $opts{PREREQ_PM} =
@@ -68,34 +109,62 @@ else {
 
 require Imager::Probe;
 
+# these are mostly needed when pkg-config isn't available
+my @alts =
+  (
+   {
+    altname => "v1.6",
+    incsuffix => "libpng16",
+    libbase => "png16",
+   },
+   {
+    altname => "v1.5",
+    incsuffix => "libpng15",
+    libbase => "png15",
+   },
+   {
+    altname => "v1.4",
+    incsuffix => "libpng14",
+    libbase => "png14",
+   },
+   {
+    altname => "v1.2",
+    incsuffix => "libpng12",
+    libbase => "png12",
+   },
+   {
+    altname => "v1.0",
+    incsuffix => "libpng10",
+    libbase => "png10",
+   },
+  );
+
 my %probe =
   (
    name => "PNG",
    altname => "Generic",
-   pkg => [ qw/libpng14 libpng12 libpng10 libpng/ ],
+   pkg => [ qw/libpng libpng16 libpng15 libpng14 libpng12 libpng10/ ],
    inccheck => sub { -e File::Spec->catfile($_[0], "png.h") },
    libbase => "png",
    testcode => _png_test_code(),
    testcodeheaders => [ "png.h", "stdio.h" ],
    incpath => \@incpaths,
    libpath => \@libpaths,
+   verbose => $verbose,
    alternatives =>
    [
+    @alts,
     {
-     altname => "v1.4",
-     incsuffix => "libpng14",
-     libbase => "png14",
-    },
-    {
-     altname => "v1.2",
-     incsuffix => "libpng12",
-     libbase => "png12",
-    },
-    {
-     altname => "v1.0",
-     incsuffix => "libpng10",
-     libbase => "png10",
+     altname => "base (+libz)",
+     libbase => [ "png", "z" ],
     },
+    ( # a static libpng may require libz too
+     map +{
+          %$_,
+          altname => "$_->{altname} (+libz)",
+          libbase => [ $_->{libbase}, "z" ],
+         }, @alts
+    ),
    ],
   );
 
@@ -107,12 +176,7 @@ if ($probe_res) {
   $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} = 'PNG Image file support';
-  }
-  
+
   WriteMakefile(%opts);
 }
 else {
@@ -131,6 +195,11 @@ sub _png_test_code {
   return <<'CODE';
 
 fprintf(stderr, "PNG: library version %ld, header version %ld\n", (long)png_access_version_number(),  (long)PNG_LIBPNG_VER);
+
+  if (png_access_version_number() != PNG_LIBPNG_VER) {
+     fprintf(stderr, "PNG: Your header version number doesn't match the library version number\n");
+     return 1;
+  }
 return 0;
 CODE
 }