3 use ExtUtils::MakeMaker;
8 my @objs = qw/Screenshot.o/;
13 my $X11_lib = $^O eq 'cygwin' ? 'X11.dll' : 'X11';
14 if (find_header("X11/Xlib.h") and find_lib($X11_lib)) {
15 push @objs, 'scx11.o';
16 push @cflags, '-DSS_X11';
17 push @lflags, '-l'.$X11_lib;
20 if (find_header('windows.h') and find_lib('gdi32')) {
21 push @objs, 'scwin32.o';
22 push @cflags, '-DSS_WIN32';
23 if ($^O eq 'cygwin') {
24 push @lflags, '-L/usr/lib/w32api', '-lgdi32';
26 print "Found Win32\n";
30 die "Sorry, I can't find headers or libraries for a supported GUI\n"
35 NAME => 'Imager::Screenshot',
36 VERSION_FROM => 'Screenshot.pm',
41 INC => Imager::ExtUtils->includes,
42 TYPEMAPS => [ Imager::ExtUtils->typemap ],
45 $opts{LIBS} = "@lflags" if @lflags;
46 $opts{INC} .= " @cflags" if @cflags;
48 if ($ExtUtils::MakeMaker::VERSION > 6.06) {
49 $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
50 $opts{ABSTRACT} = 'Screen/Window capture to Imager images';
53 if ($ExtUtils::MakeMaker::VERSION > 6.30) {
54 $opts{LICENSE} = 'perl';
60 sub header_search_path {
61 @incs and return @incs;
63 push @incs, '/usr/include', '/usr/X11R6/include'
64 unless $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/;
65 push @incs, split /\Q$Config{path_sep}/, $ENV{INCLUDE}
66 if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{INCLUDE};
67 push @incs, split ' ', $Config{locincpth}
68 if $Config{locincpth};
69 push @incs, split /\Q$Config{path_sep}/, $Config{incpath}
71 push @incs, '/usr/include/w32api', '/usr/X11R6/include'
74 @incs = grep -d, @incs;
80 sub library_search_path {
81 @libs and return @libs;
83 push @libs, '/usr/lib', '/usr/X11R6/lib'
84 unless $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/;
85 push @libs, split /\Q$Config{path_sep}/, $ENV{LIB}
86 if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{LIB};
87 push @libs, split ' ', $Config{loclibpth}
88 if $Config{loclibpth};
89 push @libs, split /\Q$Config{path_sep}/, $Config{libpth}
91 push @libs, '/usr/lib/w32api', '/usr/X11R6/lib'
94 @libs = grep -d, @libs;
101 my ($name, @where) = @_;
103 grep -f File::Spec->catfile($_, $name), @where;
107 my @found = _find_file($_[0], header_search_path());
110 push @cflags, "-I$_" for grep !$seen_incdir{$_}, @found;
111 @seen_incdir{@found} = (1) x @found;
120 if ($^O eq 'MSWin32' && $Config{_a} eq '.lib') {
121 @found = _find_file($name . $Config{_a}, library_search_path());
124 @found = _find_file("lib" . $name . $Config{_a}, library_search_path());
127 push @lflags, "-L$_" for grep !$seen_libdir{$_}, @found;
128 @seen_libdir{@found} = (1) x @found;