0.78 release
[imager.git] / PNG / Makefile.PL
CommitLineData
1d7e3124
TC
1#!perl -w
2use strict;
3use ExtUtils::MakeMaker qw(WriteMakefile WriteEmptyMakefile);
4use Getopt::Long;
b515cc4c 5use Config;
1d7e3124
TC
6
7my $verbose = $ENV{IM_VERBOSE};
8my @libpaths;
9my @incpaths;
10
11GetOptions("incpath=s", \@incpaths,
12 "libpath=s" => \@libpaths,
13 "verbose|v" => \$verbose);
14
15our $BUILDING_IMAGER;
16
17my $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
18
19my %opts =
20 (
21 NAME => 'Imager::File::PNG',
22 VERSION_FROM => 'PNG.pm',
23 OBJECT => 'PNG.o impng.o',
30160513 24 clean => { FILES => 'testout' },
1d7e3124
TC
25 );
26
27my @inc;
28if ($BUILDING_IMAGER) {
29 push @inc, "-I..";
b515cc4c 30 unshift @INC, "../lib";
1d7e3124
TC
31}
32else {
b515cc4c 33 unshift @INC, "inc";
1d7e3124
TC
34 print "PNG: building independently\n";
35 require Imager::ExtUtils;
36 push @inc, Imager::ExtUtils->includes;
37 $opts{TYPEMAPS} = [ Imager::ExtUtils->typemap ];
38
39 # Imager required configure through use
893474f1 40 my @Imager_req = ( Imager => "0.78" );
1d7e3124
TC
41 if ($MM_ver >= 6.46) {
42 $opts{META_MERGE} =
43 {
44 configure_requires =>
45 {
46 @Imager_req,
47 },
48 build_requires =>
49 {
50 @Imager_req,
51 "Test::More" => "0.47",
b515cc4c
TC
52 },
53 resources =>
54 {
55 homepage => "http://imager.perl.org/",
56 repository =>
57 {
3a882231
TC
58 url => "http://imager.perl.org/svn/trunk/Imager/PNG",
59 web => "http://imager.perl.org/svnweb/public/browse/trunk/Imager/PNG",
b515cc4c
TC
60 type => "svn",
61 },
62 },
1d7e3124
TC
63 };
64 $opts{PREREQ_PM} =
65 {
66 @Imager_req,
67 };
68 }
69}
70
71require Imager::Probe;
72
73my %probe =
74 (
75 name => "PNG",
cac1147d 76 altname => "Generic",
1d7e3124
TC
77 pkg => [ qw/libpng14 libpng12 libpng10 libpng/ ],
78 inccheck => sub { -e File::Spec->catfile($_[0], "png.h") },
79 libbase => "png",
80 testcode => _png_test_code(),
81 testcodeheaders => [ "png.h", "stdio.h" ],
0c3c1180
TC
82 incpath => \@incpaths,
83 libpath => \@libpaths,
cac1147d
TC
84 alternatives =>
85 [
86 {
87 altname => "v1.4",
88 incsuffix => "libpng14",
89 libbase => "png14",
90 },
91 {
92 altname => "v1.2",
93 incsuffix => "libpng12",
94 libbase => "png12",
95 },
96 {
97 altname => "v1.0",
98 incsuffix => "libpng10",
99 libbase => "png10",
100 },
101 ],
1d7e3124
TC
102 );
103
104my $probe_res = Imager::Probe->probe(\%probe);
105if ($probe_res) {
106 push @inc, $probe_res->{INC};
107 $opts{LIBS} = $probe_res->{LIBS};
108
109 $opts{INC} = "@inc";
110
111 if ($MM_ver > 6.06) {
112 $opts{AUTHOR} = 'Tony Cook <tony@imager.perl.org>';
113 $opts{ABSTRACT} = 'PNG Image file support';
114 }
115
116 WriteMakefile(%opts);
117}
118else {
119 if ($BUILDING_IMAGER) {
120 WriteEmptyMakefile(%opts);
121 }
122 else {
123 # fail in good way
124 die "OS unsupported: PNG libraries or headers not found\n";
125 }
126}
127
128sub _png_test_code {
129 return <<'CODE';
130
131fprintf(stderr, "PNG: library version %ld, header version %ld\n", (long)png_access_version_number(), (long)PNG_LIBPNG_VER);
132return 0;
133CODE
134}