Devel::CheckLib: handle the gcc-4 symlink on Cygwin
[imager.git] / JPEG / Makefile.PL
CommitLineData
797a9f9c
TC
1#!perl -w
2use strict;
d24404be 3use ExtUtils::MakeMaker;
797a9f9c
TC
4use Getopt::Long;
5use Config;
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;
797a9f9c
TC
17
18my $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
19
20my %opts =
21 (
22 NAME => 'Imager::File::JPEG',
23 VERSION_FROM => 'JPEG.pm',
24 OBJECT => 'JPEG.o imjpeg.o imexif.o',
30160513 25 clean => { FILES => 'testout' },
797a9f9c
TC
26 );
27
28my @inc;
29if ($BUILDING_IMAGER) {
30 push @inc, "-I..";
31 unshift @INC, "../lib";
32}
33else {
34 unshift @INC, "inc";
35 print "JPEG: 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
4b2e59d3 41 my @Imager_req = ( Imager => "0.86" );
797a9f9c
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",
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",
797a9f9c
TC
59 },
60 };
61 $opts{PREREQ_PM} =
62 {
63 @Imager_req,
a5919365 64 XSLoader => 0,
797a9f9c
TC
65 };
66 }
67}
68
69require Imager::Probe;
70
71my %probe =
72 (
73 name => "JPEG",
74 inccheck => sub { -e File::Spec->catfile($_[0], "jpeglib.h") },
75 libbase => "jpeg",
cb4f51d6
TC
76 testcode => _jpeg_test_code(),
77 testcodeheaders => [ "stdio.h", "stddef.h", "jpeglib.h" ],
0c3c1180
TC
78 incpath => \@incpaths,
79 libpath => \@libpaths,
0987aae1 80 verbose => $verbose,
797a9f9c
TC
81 );
82
83my $probe_res = Imager::Probe->probe(\%probe);
84if ($probe_res) {
d97c8dbd
TC
85 $IMAGER_LIBS{JPEG} = 1;
86
797a9f9c
TC
87 push @inc, $probe_res->{INC};
88 $opts{LIBS} = $probe_res->{LIBS};
03e49392 89 $opts{DEFINE} = $probe_res->{DEFINE};
797a9f9c
TC
90 $opts{INC} = "@inc";
91
92 if ($MM_ver > 6.06) {
5b480b14 93 $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
797a9f9c
TC
94 $opts{ABSTRACT} = 'JPEG Image file support';
95 }
96
97 WriteMakefile(%opts);
98}
99else {
d97c8dbd
TC
100 $IMAGER_LIBS{JPEG} = 0;
101
797a9f9c 102 if ($BUILDING_IMAGER) {
d24404be 103 ExtUtils::MakeMaker::WriteEmptyMakefile(%opts);
797a9f9c
TC
104 }
105 else {
106 # fail in good way
107 die "OS unsupported: JPEG libraries or headers not found\n";
108 }
109}
110
111sub _jpeg_test_code {
112 return <<'CODE';
cb4f51d6
TC
113struct jpeg_decompress_struct cinfo;
114struct jpeg_error_mgr jerr;
115
116cinfo.err = jpeg_std_error(&jerr);
117jpeg_create_decompress(&cinfo);
797a9f9c 118
797a9f9c
TC
119return 0;
120CODE
121}