3 use ExtUtils::MakeMaker;
12 my @incpaths; # places to look for headers
13 my @libpaths; # places to look for libraries
15 GetOptions("incpath=s", \@incpaths,
16 "libpath=s" => \@libpaths);
18 my @objs = qw/Screenshot.o/;
24 my $X11_lib = $^O eq 'cygwin' ? 'X11.dll' : 'X11';
25 if (find_header("X11/Xlib.h", "X11 header")
26 and find_lib($X11_lib, "X11 library")) {
27 push @objs, 'scx11.o';
28 push @cflags, '-DSS_X11';
29 push @lflags, '-l'.$X11_lib;
32 if (find_header('windows.h', "Win32 header")
33 && find_lib('gdi32', "Win32 library")
34 || check_lib(header => "windows.h",
37 push @objs, 'scwin32.o', 'svwin32.o';
38 push @cflags, '-DSS_WIN32';
39 if ($^O eq 'cygwin') {
40 push @lflags, '-L/usr/lib/w32api', '-lgdi32';
42 print "Found Win32\n";
45 if ($^O eq "darwin") {
46 # this test is overly simple
47 push @objs, "scdarwin.o";
48 push @cflags, "-DSS_DARWIN";
49 push @lddlflags, qw/-framework OpenGL -framework Cocoa/;
55 OS unsupported: Headers or libraries not found for a supported GUI
57 Sorry, I can't find headers or libraries for a supported GUI
58 You need to install development headers and libraries for your GUI
59 For Win32: Platform SDK or a substitute
60 For X11: X11 headers and libraries, eg. the libX11-dev package on Debian
61 For OS X: Install Xcode
68 NAME => 'Imager::Screenshot',
69 VERSION_FROM => 'Screenshot.pm',
74 INC => Imager::ExtUtils->includes,
75 TYPEMAPS => [ Imager::ExtUtils->typemap ],
78 $opts{LIBS} = "@lflags" if @lflags;
79 $opts{INC} .= " @cflags" if @cflags;
82 $opts{LDDLFLAGS} = $Config{lddlflags} . " @lddlflags";
85 # avoid "... isn't numeric in numeric gt ..." warnings for dev versions
86 my $eu_mm_version = eval $ExtUtils::MakeMaker::VERSION;
87 if ($eu_mm_version > 6.06) {
88 $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
89 $opts{ABSTRACT} = 'Screen/Window capture to Imager images';
92 # LICENSE was introduced in 6.30_01, but Debian etch includes
93 # (as of 2007/01/12) an ExtUtils::MakeMaker versioned 6.30_01 without
95 # EXTRA_META was also introduced in 6.30_01
96 if ($eu_mm_version > 6.3001) {
97 $opts{LICENSE} = 'perl';
99 if ($eu_mm_version >= 6.46) {
102 configure_requires =>
109 "Test::More" => "0.47",
114 homepage => "http://imager.perl.org/",
115 repository => "git://git.imager.perl.org/imager-screenshot.git",
116 bugtracker => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager-Screenshot",
121 WriteMakefile(%opts);
124 sub header_search_path {
125 @incs and return @incs;
127 push @incs, map {; split /\Q$Config{path_sep}/ } @incpaths;
128 push @incs, split /\Q$Config{path_sep}/, $ENV{IM_INCPATH}
129 if defined $ENV{IM_INCPATH};
130 push @incs, '/usr/include', '/usr/X11R6/include'
131 unless $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/;
132 push @incs, split /\Q$Config{path_sep}/, $ENV{INCLUDE}
133 if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{INCLUDE};
134 push @incs, split ' ', $Config{locincpth}
135 if $Config{locincpth};
136 push @incs, split /\Q$Config{path_sep}/, $Config{incpath}
138 push @incs, '/usr/include/w32api', '/usr/X11R6/include'
141 @incs = grep -d, @incs;
147 sub library_search_path {
148 @libs and return @libs;
150 push @libs, map {; split /\Q$Config{path_sep}/ } @libpaths;
151 push @incs, split /\Q$Config{path_sep}/, $ENV{IM_LIBPATH}
152 if defined $ENV{IM_LIBPATH};
153 push @libs, '/usr/lib', '/usr/X11R6/lib'
154 unless $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/;
155 push @libs, split /\Q$Config{path_sep}/, $ENV{LIB}
156 if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{LIB};
157 push @libs, split ' ', $Config{loclibpth}
158 if $Config{loclibpth};
159 push @libs, split /\Q$Config{path_sep}/, $Config{libpth}
161 push @libs, '/usr/lib/w32api', '/usr/X11R6/lib'
164 @libs = grep -d, @libs;
170 my ($name, @where) = @_;
172 grep -f File::Spec->catfile($_, $name), @where;
186 my ($name, $description) = @_;
187 my @found = _find_file($_[0], header_search_path());
190 push @cflags, _quote_spaces("-I$_") for grep !$seen_incdir{$_}, @found;
191 @seen_incdir{@found} = (1) x @found;
194 print STDERR "Could not find $name ($description)\n";
201 my ($name, $description) = shift;
204 if ($^O eq 'MSWin32' && $Config{_a} eq '.lib') {
205 $libname = $name . $Config{_a};
206 @found = _find_file($libname, library_search_path());
209 $libname = "lib" . $name . $Config{_a};
210 @found = _find_file($libname, library_search_path());
211 if (!@found && $Config{so}) {
212 $libname = "lib" . $name . "." . $Config{so};
213 @found = _find_file($libname, library_search_path());
217 push @lflags, _quote_spaces("-L$_") for grep !$seen_libdir{$_}, @found;
218 @seen_libdir{@found} = (1) x @found;
221 print STDERR "Could not find $libname ($description)\n";