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