3 use ExtUtils::MakeMaker;
9 my @objs = qw/Screenshot.o/;
14 my $X11_lib = $^O eq 'cygwin' ? 'X11.dll' : 'X11';
15 if (find_header("X11/Xlib.h") and find_lib($X11_lib)) {
16 push @objs, 'scx11.o';
17 push @cflags, '-DSS_X11';
18 push @lflags, '-l'.$X11_lib;
21 if (find_header('windows.h') and find_lib('gdi32')) {
22 push @objs, 'scwin32.o';
23 push @cflags, '-DSS_WIN32';
24 if ($^O eq 'cygwin') {
25 push @lflags, '-L/usr/lib/w32api', '-lgdi32';
27 print "Found Win32\n";
31 die "NA: Sorry, I can't find headers or libraries for a supported GUI\n"
36 NAME => 'Imager::Screenshot',
37 VERSION_FROM => 'Screenshot.pm',
42 INC => Imager::ExtUtils->includes,
43 TYPEMAPS => [ Imager::ExtUtils->typemap ],
46 $opts{LIBS} = "@lflags" if @lflags;
47 $opts{INC} .= " @cflags" if @cflags;
49 # avoid "... isn't numberic in numeric gt ..." warnings for dev versions
50 my $eu_mm_version = eval $ExtUtils::MakeMaker::VERSION;
51 if ($eu_mm_version > 6.06) {
52 $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
53 $opts{ABSTRACT} = 'Screen/Window capture to Imager images';
56 # LICENSE was introduced in 6.30_01, but Debian etch includes
57 # (as of 2007/01/12) an ExtUtils::MakeMaker versioned 6.30_01 without
59 if ($eu_mm_version > 6.3001) {
60 $opts{LICENSE} = 'perl';
66 sub header_search_path {
67 @incs and return @incs;
69 push @incs, '/usr/include', '/usr/X11R6/include'
70 unless $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/;
71 push @incs, split /\Q$Config{path_sep}/, $ENV{INCLUDE}
72 if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{INCLUDE};
73 push @incs, split ' ', $Config{locincpth}
74 if $Config{locincpth};
75 push @incs, split /\Q$Config{path_sep}/, $Config{incpath}
77 push @incs, '/usr/include/w32api', '/usr/X11R6/include'
80 @incs = grep -d, @incs;
86 sub library_search_path {
87 @libs and return @libs;
89 push @libs, '/usr/lib', '/usr/X11R6/lib'
90 unless $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/;
91 push @libs, split /\Q$Config{path_sep}/, $ENV{LIB}
92 if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{LIB};
93 push @libs, split ' ', $Config{loclibpth}
94 if $Config{loclibpth};
95 push @libs, split /\Q$Config{path_sep}/, $Config{libpth}
97 push @libs, '/usr/lib/w32api', '/usr/X11R6/lib'
100 @libs = grep -d, @libs;
107 my ($name, @where) = @_;
109 grep -f File::Spec->catfile($_, $name), @where;
113 my @found = _find_file($_[0], header_search_path());
116 push @cflags, "-I$_" for grep !$seen_incdir{$_}, @found;
117 @seen_incdir{@found} = (1) x @found;
126 if ($^O eq 'MSWin32' && $Config{_a} eq '.lib') {
127 @found = _find_file($name . $Config{_a}, library_search_path());
130 @found = _find_file("lib" . $name . $Config{_a}, library_search_path());
133 push @lflags, "-L$_" for grep !$seen_libdir{$_}, @found;
134 @seen_libdir{@found} = (1) x @found;