Debian Codegraph @

JPEG/Makefile.PL

raw
1 #!perl -w
2 use strict;
3 use ExtUtils::MakeMaker;
4 use Getopt::Long;
5 use Config;
6
7 my $verbose = $ENV{IM_VERBOSE};
8 my @libpaths;
9 my @incpaths;
10
11 GetOptions("incpath=s", \@incpaths,
12 "libpath=s" => \@libpaths,
13 "verbose|v" => \$verbose);
14
15 our $BUILDING_IMAGER;
16 our %IMAGER_LIBS;
17
18 my %opts =
19 (
20 NAME => 'Imager::File::JPEG',
21 VERSION_FROM => 'JPEG.pm',
22 OBJECT => 'JPEG.o imjpeg.o',
23 clean => { FILES => 'testout' },
24 );
25
26 if (eval { ExtUtils::MakeMaker->VERSION('6.46'); 1 }) {
27 $opts{LICENSE} = "perl_5";
28 $opts{AUTHOR} = 'Tony Cook <[email protected]>';
29 $opts{ABSTRACT} = 'JPEG Image file support for Imager';
30 $opts{META_MERGE} =
31 {
32 'meta-spec' =>
33 {
34 version => "2",
35 url => "https://metacpan.org/pod/CPAN::Meta::Spec",
36 },
37 resources =>
38 {
39 homepage => "http://imager.perl.org/",
40 repository =>
41 {
42 type => "git",
43 url => "git://github.com/tonycoz/imager.git",
44 web => "https://github.com/tonycoz/imager.git",
45 },
46 bugtracker =>
47 {
48 web => "https://github.com/tonycoz/imager/issues",
49 },
50 },
51 };
52 }
53
54 my @inc;
55 if ($BUILDING_IMAGER) {
56 push @inc, "-I..";
57 unshift @INC, "../lib";
58 }
59 else {
60 unshift @INC, "inc";
61 print "JPEG: building independently\n";
62 require Imager::ExtUtils;
63 push @inc, Imager::ExtUtils->includes;
64 $opts{TYPEMAPS} = [ Imager::ExtUtils->typemap ];
65
66 # Imager required configure through use
67 my @Imager_req = ( Imager => "1.034" );
68 if (eval { ExtUtils::MakeMaker->VERSION('6.46'); 1 }) {
69 $opts{META_MERGE}{prereqs} =
70 {
71 configure =>
72 {
73 requires =>
74 {
75 @Imager_req,
76 },
77 },
78 build =>
79 {
80 requires =>
81 {
82 @Imager_req,
83 "Test::More" => "0.47",
84 }
85 },
86 runtime =>
87 {
88 requires =>
89 {
90 @Imager_req,
91 }
92 },
93 test =>
94 {
95 requires =>
96 {
97 "Test::More" => "0.47",
98 }
99 },
100 };
101 $opts{PREREQ_PM} =
102 {
103 @Imager_req,
104 XSLoader => 0,
105 };
106 }
107 }
108
109 require Imager::Probe;
110
111 my %probe =
112 (
113 name => "JPEG",
114 pkg => [ "libjpeg" ],
115 inccheck => sub { -e File::Spec->catfile($_[0], "jpeglib.h") },
116 libbase => "jpeg",
117 testcode => _jpeg_test_code(),
118 testcodeheaders => [ "stdio.h", "stddef.h", "jpeglib.h" ],
119 incpath => \@incpaths,
120 libpath => \@libpaths,
121 verbose => $verbose,
122 );
123
124 my $probe_res = Imager::Probe->probe(\%probe);
125 if ($probe_res) {
126 $IMAGER_LIBS{JPEG} = 1;
127
128 push @inc, $probe_res->{INC};
129 $opts{LIBS} = $probe_res->{LIBS};
130 $opts{DEFINE} = $probe_res->{DEFINE};
131 $opts{INC} = "@inc";
132
133 WriteMakefile(%opts);
134 }
135 else {
136 $IMAGER_LIBS{JPEG} = 0;
137
138 if ($BUILDING_IMAGER) {
139 ExtUtils::MakeMaker::WriteEmptyMakefile(%opts);
140 }
141 else {
142 # fail in good way
143 die "OS unsupported: JPEG libraries or headers not found\n";
144 }
145 }
146
147 sub _jpeg_test_code {
148 return <<'CODE';
149 struct jpeg_decompress_struct cinfo;
150 struct jpeg_error_mgr jerr;
151
152 cinfo.err = jpeg_std_error(&jerr);
153 jpeg_create_decompress(&cinfo);
154
155 jpeg_destroy_decompress(&cinfo);
156 return 0;
157 CODE
158 }