3 use ExtUtils::MakeMaker qw(WriteMakefile WriteEmptyMakefile);
7 my $verbose = $ENV{IM_VERBOSE};
11 GetOptions("incpath=s", \@incpaths,
12 "libpath=s" => \@libpaths,
13 "verbose|v" => \$verbose);
17 my $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
21 NAME => 'Imager::File::GIF',
22 VERSION_FROM => 'GIF.pm',
23 OBJECT => 'GIF.o imgif.o',
27 if ($BUILDING_IMAGER) {
29 unshift @INC, "../lib";
33 print "GIF: building independently\n";
34 require Imager::ExtUtils;
35 push @inc, Imager::ExtUtils->includes;
36 $opts{TYPEMAPS} = [ Imager::ExtUtils->typemap ];
38 # Imager required configure through use
39 my @Imager_req = ( Imager => "0.78" );
40 if ($MM_ver >= 6.46) {
50 "Test::More" => "0.47",
54 homepage => "http://imager.perl.org/",
57 url => "http://imager.perl.org/svn/trunk/Imager-File-GIF",
58 web => "http://imager.perl.org/svnweb/public/browse/trunk/Imager-File-GIF",
70 require Imager::Probe;
75 inccheck => sub { -e File::Spec->catfile($_[0], "gif_lib.h") },
77 testcode => _gif_test_code(),
78 testcodeheaders => [ "gif_lib.h", "stdio.h" ],
79 incpath => join($Config{path_sep}, @incpaths),
80 libpath => join($Config{path_sep}, @libpaths),
83 my $probe_res = Imager::Probe->probe(\%probe);
85 push @inc, $probe_res->{INC};
86 $opts{LIBS} = $probe_res->{LIBS};
91 $opts{AUTHOR} = 'Tony Cook <tony@imager.perl.org>';
92 $opts{ABSTRACT} = 'GIF Image file support';
98 if ($BUILDING_IMAGER) {
99 WriteEmptyMakefile(%opts);
103 die "OS unsupported: GIF libraries or headers not found\n";
109 /* TODO: test DGifOpen() and processing with callbacks */
111 const char vers[] = GIF_LIB_VERSION;
112 const char *versp = vers;
115 fprintf(stderr, "GIF: header version '%s'\n", GIF_LIB_VERSION);
116 gf=DGifOpenFileName("testimg/expected.gif");
118 fprintf(stderr, "GIF: Cannot open testimg/expected.gif\n");
121 if (gf->SWidth != 16 || gf->SHeight != 16) {
122 fprintf(stderr, "GIF: bad screen description (%d x %d)\n", gf->SWidth, gf->SHeight);
125 /* crashes in older versions of giflib */
126 EGifSetGifVersion("89a");
127 EGifSetGifVersion("87a");
129 /* skip the " Version " */
130 while (*versp && (*versp < '0' || *versp > '9'))
133 fprintf(stderr, "GIF: Cannot find version number in '%s'\n", vers);
137 while (*versp && *versp >= '0' && *versp <= '9') {
139 ver_maj += *versp++ - '0';
141 if (*versp != '.' || versp[1] < '0' || versp[1] > '9') {
142 fprintf(stderr, "Cannot parse major version number in '%s'\n", vers);
145 ++versp; /* skip '.' */
147 while (*versp && *versp >= '0' && *versp <= '9') {
149 ver_min += *versp++ - '0';
152 fprintf(stderr, "GIF: gif lib version 3 is no longer supported\n");
155 if (ver_maj == 4 && ver_min < 1) {
156 fprintf(stderr, "GIF: you need at least giflib 4.1\n");
159 fprintf(stderr, "GIF: Major %d, Minor %d\n", ver_maj, ver_min);