3 use ExtUtils::MakeMaker;
12 my @incpaths; # places to look for headers
13 my @libpaths; # places to look for libraries
16 GetOptions("incpath=s", \@incpaths,
17 "libpath=s" => \@libpaths,
18 "v|verbose" => \$verbose);
20 my @objs = qw/Screenshot.o/;
26 my @inc = Imager::ExtUtils->includes;
31 inccheck => sub { -e File::Spec->catfile($_[0], "X11/Xlib.h") },
33 libpath => [ @libpaths, "/usr/X11R6/lib", "/usr/X11/lib" ],
34 incpath => [ @incpaths, "/usr/X11R6/include", "/usr/X11/include" ],
36 $x11_probe{alternatives} =
43 my $x11_result = Imager::Probe->probe(\%x11_probe);
45 push @objs, 'scx11.o';
46 push @cflags, '-DSS_X11', $x11_result->{DEFINE};
47 push @lflags, $x11_result->{LIBS};
48 push @inc, $x11_result->{INC};
54 inccheck => sub { -e File::Spec->catfile($_[0], "windows.h") },
56 testcode => _win32_test_code(),
57 testcodeheaders => [ "stdio.h", "string.h", "windows.h" ],
58 incpath => \@incpaths,
59 libpath => \@libpaths,
62 my $win32_result = Imager::Probe->probe(\%win32_probe);
64 push @objs, 'scwin32.o', 'svwin32.o';
65 push @cflags, '-DSS_WIN32', $win32_result->{DEFINE};
66 if ($^O eq 'cygwin') {
67 push @lflags, '-L/usr/lib/w32api', '-lgdi32';
69 print "Found Win32\n";
72 if ($^O eq "darwin" and my ($rel) = `uname -r` =~ /^([0-9]+)/) {
73 # this test is overly simple
75 push @objs, "scdarwin.o";
76 push @cflags, "-DSS_DARWIN";
77 push @lddlflags, qw/-framework OpenGL -framework Cocoa/;
78 print "Found OS X (<11)\n";
81 push @objs, "scdarwin2.o";
82 push @cflags, "-DSS_DARWIN";
83 push @lddlflags, qw/-framework Cocoa/;
84 print "Found OS X (>=11)\n";
90 OS unsupported: Headers or libraries not found for a supported GUI
92 Sorry, I can't find headers or libraries for a supported GUI
93 You need to install development headers and libraries for your GUI
94 For Win32: Platform SDK or a substitute
95 For X11: X11 headers and libraries, eg. the libX11-dev package on Debian
96 For OS X: Install Xcode
103 NAME => 'Imager::Screenshot',
104 VERSION_FROM => 'Screenshot.pm',
108 'Imager::Probe' => 0,
112 TYPEMAPS => [ Imager::ExtUtils->typemap ],
115 $opts{LIBS} = "@lflags" if @lflags;
116 $opts{INC} .= " @cflags" if @cflags;
119 $opts{LDDLFLAGS} = $Config{lddlflags} . " @lddlflags";
122 # avoid "... isn't numeric in numeric gt ..." warnings for dev versions
123 my $eu_mm_version = eval $ExtUtils::MakeMaker::VERSION;
124 if ($eu_mm_version > 6.06) {
125 $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
126 $opts{ABSTRACT} = 'Screen/Window capture to Imager images';
129 # LICENSE was introduced in 6.30_01, but Debian etch includes
130 # (as of 2007/01/12) an ExtUtils::MakeMaker versioned 6.30_01 without
132 # EXTRA_META was also introduced in 6.30_01
133 if ($eu_mm_version > 6.3001) {
134 $opts{LICENSE} = 'perl';
136 if ($eu_mm_version >= 6.46) {
139 configure_requires =>
142 'Imager::Probe' => 0,
147 "Test::More" => "0.47",
152 homepage => "http://imager.perl.org/",
153 repository => "git://git.imager.perl.org/imager-screenshot.git",
154 bugtracker => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager-Screenshot",
159 WriteMakefile(%opts);
161 sub _win32_test_code {
163 HDC dc = GetDC(NULL);
164 HDC bmpDc = CreateCompatibleDC(dc);