]> git.imager.perl.org - imager-screenshot.git/blobdiff - Makefile.PL
0.009_001 release
[imager-screenshot.git] / Makefile.PL
index b098ebef72c55714f38da88f01f93e0b104de25b..b1f9a8bea24d4578ad1d1678b3fa9bf2ec4ac04b 100644 (file)
@@ -6,6 +6,8 @@ use Imager::ExtUtils;
 use Config;
 use File::Spec;
 use Getopt::Long;
+use lib "inc";
+use Devel::CheckLib;
 
 my @incpaths; # places to look for headers
 my @libpaths; # places to look for libraries
@@ -16,6 +18,7 @@ GetOptions("incpath=s", \@incpaths,
 my @objs = qw/Screenshot.o/;
 my @cflags;
 my @lflags;
+my @lddlflags;
 my %seen_incdir;
 my %seen_libdir;
 my $X11_lib = $^O eq 'cygwin' ? 'X11.dll' : 'X11';
@@ -27,7 +30,10 @@ if (find_header("X11/Xlib.h", "X11 header")
   print "Found X11\n";
 }
 if (find_header('windows.h', "Win32 header")
-    and find_lib('gdi32', "Win32 library")) {
+    && find_lib('gdi32', "Win32 library")
+    || check_lib(header => "windows.h",
+                lib => "gdi32",
+                title => "Win32")) {
   push @objs, 'scwin32.o';
   push @cflags, '-DSS_WIN32';
   if ($^O eq 'cygwin') {
@@ -36,6 +42,14 @@ if (find_header('windows.h', "Win32 header")
   print "Found Win32\n";
 }
 
+if ($^O eq "darwin") {
+  # this test is overly simple
+  push @objs, "scdarwin.o";
+  push @cflags, "-DSS_DARWIN";
+  push @lddlflags, qw/-framework OpenGL -framework Cocoa/;
+  print "Found OS X\n";
+}
+
 unless (@objs > 1) {
   die <<DEAD;
 OS unsupported: Headers or libraries not found for a supported GUI
@@ -44,6 +58,7 @@ Sorry, I can't find headers or libraries for a supported GUI
 You need to install development headers and libraries for your GUI
 For Win32: Platform SDK or a substitute
 For X11: X11 headers and libraries, eg. the libX11-dev package on Debian
+For OS X: Install Xcode
 
 DEAD
 }
@@ -54,7 +69,7 @@ my %opts =
    VERSION_FROM => 'Screenshot.pm',
    OBJECT => "@objs",
    PREREQ_PM => {
-                'Imager'    => 0.54,
+                'Imager'    => 0.69,
                },
    INC => Imager::ExtUtils->includes,
    TYPEMAPS => [ Imager::ExtUtils->typemap ],
@@ -63,7 +78,11 @@ my %opts =
 $opts{LIBS} = "@lflags" if @lflags;
 $opts{INC} .= " @cflags" if @cflags;
 
-# avoid "... isn't numberic in numeric gt ..." warnings for dev versions
+if (@lddlflags) {
+  $opts{LDDLFLAGS} = $Config{lddlflags} . " @lddlflags";
+}
+
+# avoid "... isn't numeric in numeric gt ..." warnings for dev versions
 my $eu_mm_version = eval $ExtUtils::MakeMaker::VERSION;
 if ($eu_mm_version > 6.06) {
   $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
@@ -76,13 +95,20 @@ if ($eu_mm_version > 6.06) {
 # EXTRA_META was also introduced in 6.30_01
 if ($eu_mm_version > 6.3001) {
   $opts{LICENSE} = 'perl';
-  $opts{EXTRA_META} = <<META;
-configure_requires:
-  Imager: 0.54
-build_requires:
-  Imager: 0.54
-  Test::More: 0.47
-META
+}
+if ($eu_mm_version >= 6.46) {
+  $opts{META_MERGE} =
+    {
+     configure_requires => 
+     {
+      Imager => "0.69"
+     },
+     build_requires => 
+     {
+      Imager => "0.69",
+      "Test::More" => "0.47",
+     }
+    };
 }
 
 WriteMakefile(%opts);
@@ -180,3 +206,13 @@ sub find_lib {
 
   @found;
 }
+
+# wrapper around assert lib that doesn't exit and doesn't die
+sub check_lib {
+  my (%opts) = @_;
+
+  my $title = delete $opts{title};
+  $title and print "Looking even harder for $title\n";
+
+  return eval { assert_lib(%opts); 1 };
+}