0.84_01 development release
[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 $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
19
20my %opts =
21 (
22 NAME => 'Imager::Font::W32',
23 VERSION_FROM => 'W32.pm',
24 OBJECT => 'W32.o win32.o',
3edd17c9 25 clean => { FILES => 'testout' },
718b8c97
TC
26 );
27
28my @inc;
29if ($BUILDING_IMAGER) {
30 push @inc, "-I..";
31 unshift @INC, "../lib";
32}
33else {
34 unshift @INC, "inc";
35 print "Win32: 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
fa61d195 41 my @Imager_req = ( Imager => "0.79" );
718b8c97
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",
718b8c97
TC
59 },
60 };
61 $opts{PREREQ_PM} =
62 {
63 @Imager_req,
64 };
65 }
66}
67
68require Imager::Probe;
69
70my %probe =
71 (
72 name => "Win32",
73 inccheck => sub { -e File::Spec->catfile($_[0], "windows.h") },
74 libbase => "gdi32",
75 testcode => _win32_test_code(),
76 testcodeheaders => [ "stdio.h", "string.h", "windows.h" ],
0c3c1180
TC
77 incpath => \@incpaths,
78 libpath => \@libpaths,
718b8c97
TC
79 );
80
81my $probe_res = Imager::Probe->probe(\%probe);
82if ($probe_res) {
d97c8dbd
TC
83 $IMAGER_LIBS{Win32} = 1;
84
718b8c97
TC
85 push @inc, $probe_res->{INC};
86 $opts{LIBS} = $probe_res->{LIBS};
03e49392 87 $opts{DEFINE} = $probe_res->{DEFINE};
718b8c97
TC
88 $opts{INC} = "@inc";
89
90 if ($MM_ver > 6.06) {
5b480b14 91 $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
718b8c97
TC
92 $opts{ABSTRACT} = 'Win32 font file support for Imager';
93 }
94
95 WriteMakefile(%opts);
96}
97else {
d97c8dbd
TC
98 $IMAGER_LIBS{Win32} = 0;
99
718b8c97 100 if ($BUILDING_IMAGER) {
d24404be 101 ExtUtils::MakeMaker::WriteEmptyMakefile(%opts);
718b8c97
TC
102 }
103 else {
104 # fail in good way
105 die "OS unsupported: Win32 libraries or headers not found\n";
106 }
107}
108
109sub _win32_test_code {
110 return <<'CODE';
111HDC dc = GetDC(NULL);
112HDC bmpDc = CreateCompatibleDC(dc);
113DeleteDC(bmpDc);
114ReleaseDC(NULL, dc);
115return 0;
116CODE
117}