]> git.imager.perl.org - imager.git/blobdiff - GIF/Makefile.PL
add missing va_end() in bmp.c's write_packed()
[imager.git] / GIF / Makefile.PL
index 378dd435eef6db190b527b30062bd5b207321dff..bc3841638eb42ede75cbba27aa065597e5fd72c8 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::GIF',
@@ -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} = 'GIF 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) {
   unshift @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.94" );
+  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} =
@@ -74,9 +115,10 @@ my %probe =
    inccheck => sub { -e File::Spec->catfile($_[0], "gif_lib.h") },
    libbase => "gif",
    testcode => _gif_test_code(),
-   testcodeheaders => [ "stddef.h", "gif_lib.h", "stdio.h" ],
+   testcodeheaders => [ "stddef.h", "gif_lib.h", "stdio.h", "errno.h", "string.h" ],
    incpath => \@incpaths,
    libpath => \@libpaths,
+   verbose => $verbose,
   );
 
 my $probe_res = Imager::Probe->probe(\%probe);
@@ -87,12 +129,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} = 'GIF Image file support';
-  }
-  
+
   WriteMakefile(%opts);
 }
 else {
@@ -119,8 +156,13 @@ int ver_min;
 #else
 int ver_maj = GIFLIB_MAJOR;
 int ver_min = GIFLIB_MINOR;
-int error;
 #endif
+GifColorType colors[2];
+ColorMapObject *map;
+FILE *fh;
+char buf[6];
+int mode;
+int error;
 #if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
 gf=DGifOpenFileName("testimg/expected.gif", &error);
 #else
@@ -172,6 +214,56 @@ if (ver_maj == 4 && ver_min < 1) {
   fprintf(stderr, "GIF: you need at least giflib 4.1\n");
   return 1;
 }
+
+/* test we write both GIF87a and GIF89a files */
+for (mode = 0; mode < 2; ++mode) {
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+  gf=EGifOpenFileName("probe.gif", 0, &error);
+  EGifSetGifVersion(gf, mode);
+
+#else
+  gf=EGifOpenFileName("probe.gif", 0);
+  EGifSetGifVersion(mode ? "89a" : "87a");
+#endif
+  if (!gf) {
+    fprintf(stderr, "GIF: cannot create probe.gif for testing\n");
+    return 1;
+  }
+  colors[0].Red = colors[0].Green = colors[0].Blue = 0;
+  colors[1].Red = colors[1].Green = colors[1].Blue = 0;
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+  map = GifMakeMapObject(2, colors);
+#else
+  map = MakeMapObject(2, colors);
+#endif
+  EGifPutScreenDesc(gf, 1, 1, 1, 0, map);
+  EGifPutImageDesc(gf, 0, 0, 1, 1, 0, NULL);
+  EGifPutPixel(gf, 0);
+#if defined(GIFLIB_MAJOR) && ((GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1) || GIFLIB_MAJOR >= 6)
+  EGifCloseFile(gf, &error);
+#else
+  EGifCloseFile(gf);
+#endif
+
+  fh = fopen("probe.gif", "r");
+  if (!fh) {
+    fprintf(stderr, "GIF: cannot open probe.gif for reading\n");
+    return 1;
+  }
+  errno = 0;
+  memset(buf, 0, sizeof(buf));
+  if (fread(buf, 1, 6, fh) != 6) {
+    fprintf(stderr, "GIF: cannot read probe.gif header (%d)\n", errno);
+    return 1;
+  }
+  fclose(fh);
+  remove("probe.gif");
+  if (memcmp(buf, mode ? "GIF89a" : "GIF87a", 6)) {
+    fprintf(stderr, "GIF: incorrect header on test - 4.2.0 bug? (mode %d, buf %-6s)\n", mode, buf);
+    return 1;
+  }
+}
+
 fprintf(stderr, "GIF: Major %d, Minor %d\n", ver_maj, ver_min);
 return 0;
 CODE