i_img_info() (C API) no longer tries to handle a NULL image object pointer.
[imager.git] / W32 / Makefile.PL
CommitLineData
718b8c97
TC
1#!perl -w
2use strict;
d24404be 3use ExtUtils::MakeMaker;
718b8c97
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;
718b8c97 17
718b8c97
TC
18my %opts =
19 (
20 NAME => 'Imager::Font::W32',
21 VERSION_FROM => 'W32.pm',
22 OBJECT => 'W32.o win32.o',
3edd17c9 23 clean => { FILES => 'testout' },
718b8c97
TC
24 );
25
572d5255
TC
26if (eval { ExtUtils::MakeMaker->VERSION('6.46'); 1 }) {
27 $opts{LICENSE} = "perl_5";
28 $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
29 $opts{ABSTRACT} = 'Win32 font driver 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://git.imager.perl.org/imager.git",
44 web => "http://git.imager.perl.org/imager.git",
45 },
46 bugtracker =>
47 {
48 web => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager",
49 mailto => 'bug-Imager@rt.cpan.org',
50 },
51 },
52 };
53}
54
718b8c97
TC
55my @inc;
56if ($BUILDING_IMAGER) {
57 push @inc, "-I..";
58 unshift @INC, "../lib";
59}
60else {
61 unshift @INC, "inc";
62 print "Win32: building independently\n";
63 require Imager::ExtUtils;
64 push @inc, Imager::ExtUtils->includes;
65 $opts{TYPEMAPS} = [ Imager::ExtUtils->typemap ];
66
67 # Imager required configure through use
5eac8456 68 my @Imager_req = ( Imager => "0.95" );
572d5255
TC
69 if (eval { ExtUtils::MakeMaker->VERSION('6.46'); 1 }) {
70 $opts{META_MERGE}{prereqs} =
718b8c97 71 {
572d5255
TC
72 configure =>
73 {
74 requires =>
75 {
76 @Imager_req,
77 },
78 },
79 build =>
718b8c97 80 {
572d5255
TC
81 requires =>
82 {
83 @Imager_req,
84 "Test::More" => "0.47",
85 }
718b8c97 86 },
572d5255 87 runtime =>
718b8c97 88 {
572d5255
TC
89 requires =>
90 {
91 @Imager_req,
92 }
718b8c97 93 },
572d5255 94 test =>
718b8c97 95 {
572d5255
TC
96 requires =>
97 {
98 "Test::More" => "0.47",
99 }
718b8c97
TC
100 },
101 };
102 $opts{PREREQ_PM} =
103 {
104 @Imager_req,
a5919365 105 XSLoader => 0,
718b8c97
TC
106 };
107 }
108}
109
110require Imager::Probe;
111
112my %probe =
113 (
114 name => "Win32",
115 inccheck => sub { -e File::Spec->catfile($_[0], "windows.h") },
116 libbase => "gdi32",
117 testcode => _win32_test_code(),
118 testcodeheaders => [ "stdio.h", "string.h", "windows.h" ],
0c3c1180
TC
119 incpath => \@incpaths,
120 libpath => \@libpaths,
0987aae1 121 verbose => $verbose,
718b8c97
TC
122 );
123
124my $probe_res = Imager::Probe->probe(\%probe);
125if ($probe_res) {
d97c8dbd
TC
126 $IMAGER_LIBS{Win32} = 1;
127
718b8c97
TC
128 push @inc, $probe_res->{INC};
129 $opts{LIBS} = $probe_res->{LIBS};
03e49392 130 $opts{DEFINE} = $probe_res->{DEFINE};
718b8c97
TC
131 $opts{INC} = "@inc";
132
718b8c97
TC
133 WriteMakefile(%opts);
134}
135else {
d97c8dbd
TC
136 $IMAGER_LIBS{Win32} = 0;
137
718b8c97 138 if ($BUILDING_IMAGER) {
d24404be 139 ExtUtils::MakeMaker::WriteEmptyMakefile(%opts);
718b8c97
TC
140 }
141 else {
142 # fail in good way
143 die "OS unsupported: Win32 libraries or headers not found\n";
144 }
145}
146
147sub _win32_test_code {
148 return <<'CODE';
149HDC dc = GetDC(NULL);
150HDC bmpDc = CreateCompatibleDC(dc);
151DeleteDC(bmpDc);
152ReleaseDC(NULL, dc);
153return 0;
154CODE
155}