2 use ExtUtils::MakeMaker;
\r
3 use Imager::ExtUtils;
\r
7 my @objs = qw/Screenshot.o/;
\r
10 if (find_header("X11/X.h") and find_lib("X11")) {
\r
11 push @objs, 'scx11.o';
\r
12 push @cflags, '-DSS_X11';
\r
13 push @lflags, '-lX11';
\r
14 print "Found X11\n";
\r
16 if (find_header('windows.h') and find_lib('gdi32')) {
\r
17 push @objs, 'scwin32.o';
\r
18 push @cflags, '-DSS_WIN32';
\r
19 push @lflags, '-lgdi32' if $^O eq 'cygwin';
\r
20 print "Found Win32\n";
\r
23 unless (@objs > 1) {
\r
24 die "Sorry, I can't find headers or libraries for a supported GUI\n"
\r
29 NAME => 'Imager::Screenshot',
\r
30 VERSION_FROM => 'Screenshot.pm',
\r
35 INC => Imager::ExtUtils->includes,
\r
36 TYPEMAPS => [ Imager::ExtUtils->typemap ],
\r
39 $opts{LIBS} = "@lflags" if @lflags;
\r
40 $opts{INC} .= " @cflags" if @cflags;
\r
42 if ($ExtUtils::MakeMaker::VERSION > 6.06) {
\r
43 $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
\r
44 $opts{ABSTRACT} = 'Screen/Window capture to Imager images';
\r
47 WriteMakefile(%opts);
\r
50 sub header_search_path {
\r
51 @incs and return @incs;
\r
53 push @incs, '/usr/include'
\r
54 unless $^O eq 'MSWin32';
\r
55 push @incs, split /\Q$Config{path_sep}/, $ENV{INCLUDE}
\r
56 if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{INCLUDE};
\r
57 push @incs, split ' ', $Config{locincpth}
\r
58 if $Config{locincpth};
\r
59 push @incs, split /\Q$Config{path_sep}/, $Config{incpath}
\r
60 if $Config{incpath};
\r
62 @incs = grep -d, @incs;
\r
68 sub library_search_path {
\r
69 @libs and return @libs;
\r
71 push @libs, '/usr/lib'
\r
72 unless $^O eq 'MSWin32';
\r
73 push @libs, split /\Q$Config{path_sep}/, $ENV{LIB}
\r
74 if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{LIB};
\r
75 push @libs, split ' ', $Config{loclibpth}
\r
76 if $Config{loclibpth};
\r
77 push @libs, split /\Q$Config{path_sep}/, $Config{libpth}
\r
80 @libs = grep -d, @libs;
\r
87 my ($name, @where) = @_;
\r
89 grep -f File::Spec->catfile($_, $name), @where;
\r
93 _find_file($_[0], header_search_path());
\r
98 if ($^O eq 'MSWin32') {
\r
99 return _find_file($name . $Config{_a}, library_search_path());
\r
102 return _find_file("lib" . $name . $Config{_a}, library_search_path());
\r