3 use ExtUtils::MakeMaker;
8 my @objs = qw/Screenshot.o/;
11 my $X11_lib = $^O eq 'cygwin' ? 'X11.dll' : 'X11';
12 if (find_header("X11/Xlib.h") and find_lib($X11_lib)) {
13 push @objs, 'scx11.o';
14 push @cflags, '-DSS_X11';
15 push @lflags, '-l'.$X11_lib;
18 if (find_header('windows.h') and find_lib('gdi32')) {
19 push @objs, 'scwin32.o';
20 push @cflags, '-DSS_WIN32';
21 if ($^O eq 'cygwin') {
22 push @lflags, '-L/usr/lib/w32api', '-lgdi32';
24 print "Found Win32\n";
28 die "Sorry, I can't find headers or libraries for a supported GUI\n"
33 NAME => 'Imager::Screenshot',
34 VERSION_FROM => 'Screenshot.pm',
39 INC => Imager::ExtUtils->includes,
40 TYPEMAPS => [ Imager::ExtUtils->typemap ],
43 $opts{LIBS} = "@lflags" if @lflags;
44 $opts{INC} .= " @cflags" if @cflags;
46 if ($ExtUtils::MakeMaker::VERSION > 6.06) {
47 $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
48 $opts{ABSTRACT} = 'Screen/Window capture to Imager images';
54 sub header_search_path {
55 @incs and return @incs;
57 push @incs, '/usr/include'
58 unless $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/;
59 push @incs, split /\Q$Config{path_sep}/, $ENV{INCLUDE}
60 if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{INCLUDE};
61 push @incs, split ' ', $Config{locincpth}
62 if $Config{locincpth};
63 push @incs, split /\Q$Config{path_sep}/, $Config{incpath}
65 push @incs, '/usr/include/w32api', '/usr/X11R6/include'
68 @incs = grep -d, @incs;
74 sub library_search_path {
75 @libs and return @libs;
77 push @libs, '/usr/lib'
78 unless $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/;
79 push @libs, split /\Q$Config{path_sep}/, $ENV{LIB}
80 if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{LIB};
81 push @libs, split ' ', $Config{loclibpth}
82 if $Config{loclibpth};
83 push @libs, split /\Q$Config{path_sep}/, $Config{libpth}
85 push @libs, '/usr/lib/w32api', '/usr/X11R6/lib'
88 @libs = grep -d, @libs;
95 my ($name, @where) = @_;
97 grep -f File::Spec->catfile($_, $name), @where;
101 _find_file($_[0], header_search_path());
107 if ($^O eq 'MSWin32' && $Config{_a} eq '.lib') {
108 @found = _find_file($name . $Config{_a}, library_search_path());
111 @found = _find_file("lib" . $name . $Config{_a}, library_search_path());
114 push @lflags, "-L$_" for @found;