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