0.78 release
[imager.git] / W32 / Makefile.PL
CommitLineData
718b8c97
TC
1#!perl -w
2use strict;
3use ExtUtils::MakeMaker qw(WriteMakefile WriteEmptyMakefile);
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;
16
17$DB::single = 1;
18
19my $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
20
21my %opts =
22 (
23 NAME => 'Imager::Font::W32',
24 VERSION_FROM => 'W32.pm',
25 OBJECT => 'W32.o win32.o',
3edd17c9 26 clean => { FILES => 'testout' },
718b8c97
TC
27 );
28
29my @inc;
30if ($BUILDING_IMAGER) {
31 push @inc, "-I..";
32 unshift @INC, "../lib";
33}
34else {
35 unshift @INC, "inc";
36 print "Win32: building independently\n";
37 require Imager::ExtUtils;
38 push @inc, Imager::ExtUtils->includes;
39 $opts{TYPEMAPS} = [ Imager::ExtUtils->typemap ];
40
41 # Imager required configure through use
893474f1 42 my @Imager_req = ( Imager => "0.78" );
718b8c97
TC
43 if ($MM_ver >= 6.46) {
44 $opts{META_MERGE} =
45 {
46 configure_requires =>
47 {
48 @Imager_req,
49 },
50 build_requires =>
51 {
52 @Imager_req,
53 "Test::More" => "0.47",
54 },
55 resources =>
56 {
57 homepage => "http://imager.perl.org/",
58 repository =>
59 {
3a882231
TC
60 url => "http://imager.perl.org/svn/trunk/Imager/W32",
61 web => "http://imager.perl.org/svnweb/public/browse/trunk/Imager/W32",
718b8c97
TC
62 type => "svn",
63 },
64 },
65 };
66 $opts{PREREQ_PM} =
67 {
68 @Imager_req,
69 };
70 }
71}
72
73require Imager::Probe;
74
75my %probe =
76 (
77 name => "Win32",
78 inccheck => sub { -e File::Spec->catfile($_[0], "windows.h") },
79 libbase => "gdi32",
80 testcode => _win32_test_code(),
81 testcodeheaders => [ "stdio.h", "string.h", "windows.h" ],
0c3c1180
TC
82 incpath => \@incpaths,
83 libpath => \@libpaths,
718b8c97
TC
84 );
85
86my $probe_res = Imager::Probe->probe(\%probe);
87if ($probe_res) {
88 push @inc, $probe_res->{INC};
89 $opts{LIBS} = $probe_res->{LIBS};
90
91 $opts{INC} = "@inc";
92
93 if ($MM_ver > 6.06) {
94 $opts{AUTHOR} = 'Tony Cook <tony@imager.perl.org>';
95 $opts{ABSTRACT} = 'Win32 font file support for Imager';
96 }
97
98 WriteMakefile(%opts);
99}
100else {
101 if ($BUILDING_IMAGER) {
102 WriteEmptyMakefile(%opts);
103 }
104 else {
105 # fail in good way
106 die "OS unsupported: Win32 libraries or headers not found\n";
107 }
108}
109
110sub _win32_test_code {
111 return <<'CODE';
112HDC dc = GetDC(NULL);
113HDC bmpDc = CreateCompatibleDC(dc);
114DeleteDC(bmpDc);
115ReleaseDC(NULL, dc);
116return 0;
117CODE
118}