]> git.imager.perl.org - imager-screenshot.git/blobdiff - Makefile.PL
changes for mingw
[imager-screenshot.git] / Makefile.PL
index a19828e3cf57e48f9df5b027870a504ae7a87726..f598d1d2e821320be5002e4cf69b9a28018c5944 100644 (file)
@@ -1,3 +1,4 @@
+#!perl -w\r
 use strict;\r
 use ExtUtils::MakeMaker;\r
 use Imager::ExtUtils;\r
 use strict;\r
 use ExtUtils::MakeMaker;\r
 use Imager::ExtUtils;\r
@@ -7,21 +8,23 @@ use File::Spec;
 my @objs = qw/Screenshot.o/;\r
 my @cflags;\r
 my @lflags;\r
 my @objs = qw/Screenshot.o/;\r
 my @cflags;\r
 my @lflags;\r
-#if (find_header("X11.h") and find_lib("X11")) {\r
-#  push @objs, 'scx11.o';\r
-#  push @cflags, '-DSS_X11';\r
-#  push @lflags, '-lX11';\r
-#  print "Found X11\n";\r
-#}\r
+my $X11_lib = $^O eq 'cygwin' ? 'X11.dll' : 'X11';\r
+if (find_header("X11/Xlib.h") and find_lib($X11_lib)) {\r
+  push @objs, 'scx11.o';\r
+  push @cflags, '-DSS_X11';\r
+  push @lflags, '-l'.$X11_lib;\r
+  print "Found X11\n";\r
+}\r
 if (find_header('windows.h') and find_lib('gdi32')) {\r
   push @objs, 'scwin32.o';\r
   push @cflags, '-DSS_WIN32';\r
 if (find_header('windows.h') and find_lib('gdi32')) {\r
   push @objs, 'scwin32.o';\r
   push @cflags, '-DSS_WIN32';\r
-  push @lflags, '-lgdi32' if $^O eq 'cygwin';\r
+  if ($^O eq 'cygwin') {\r
+    push @lflags, '-L/usr/lib/w32api', '-lgdi32';\r
+  }\r
   print "Found Win32\n";\r
 }\r
 \r
   print "Found Win32\n";\r
 }\r
 \r
-unless (@objs) {\r
-  WriteEmptyMakefile();\r
+unless (@objs > 1) {\r
   die "Sorry, I can't find headers or libraries for a supported GUI\n"\r
 }\r
 \r
   die "Sorry, I can't find headers or libraries for a supported GUI\n"\r
 }\r
 \r
@@ -51,12 +54,16 @@ my @incs;
 sub header_search_path {\r
   @incs and return @incs;\r
 \r
 sub header_search_path {\r
   @incs and return @incs;\r
 \r
+  push @incs, '/usr/include'\r
+    unless $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/;\r
   push @incs, split /\Q$Config{path_sep}/, $ENV{INCLUDE}\r
     if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{INCLUDE};\r
   push @incs, split ' ', $Config{locincpth}\r
     if $Config{locincpth};\r
   push @incs, split /\Q$Config{path_sep}/, $Config{incpath}\r
     if $Config{incpath};\r
   push @incs, split /\Q$Config{path_sep}/, $ENV{INCLUDE}\r
     if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{INCLUDE};\r
   push @incs, split ' ', $Config{locincpth}\r
     if $Config{locincpth};\r
   push @incs, split /\Q$Config{path_sep}/, $Config{incpath}\r
     if $Config{incpath};\r
+  push @incs, '/usr/include/w32api', '/usr/X11R6/include'\r
+    if $^O eq 'cygwin';\r
 \r
   @incs = grep -d, @incs;\r
 \r
 \r
   @incs = grep -d, @incs;\r
 \r
@@ -67,12 +74,16 @@ my @libs;
 sub library_search_path {\r
   @libs and return @libs;\r
 \r
 sub library_search_path {\r
   @libs and return @libs;\r
 \r
+  push @libs, '/usr/lib'\r
+    unless $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/;\r
   push @libs, split /\Q$Config{path_sep}/, $ENV{LIB}\r
     if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{LIB};\r
   push @libs, split ' ', $Config{loclibpth}\r
     if $Config{loclibpth};\r
   push @libs, split /\Q$Config{path_sep}/, $Config{libpth}\r
     if $Config{libpth};\r
   push @libs, split /\Q$Config{path_sep}/, $ENV{LIB}\r
     if $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/ and $ENV{LIB};\r
   push @libs, split ' ', $Config{loclibpth}\r
     if $Config{loclibpth};\r
   push @libs, split /\Q$Config{path_sep}/, $Config{libpth}\r
     if $Config{libpth};\r
+  push @libs, '/usr/lib/w32api', '/usr/X11R6/lib'\r
+    if $^O eq 'cygwin';\r
 \r
   @libs = grep -d, @libs;\r
 \r
 \r
   @libs = grep -d, @libs;\r
 \r
@@ -92,10 +103,15 @@ sub find_header {
 \r
 sub find_lib {\r
   my $name = shift;\r
 \r
 sub find_lib {\r
   my $name = shift;\r
-  if ($^O eq 'MSWin32') {\r
-    return _find_file($name . $Config{_a}, library_search_path());\r
+  my @found;\r
+  if ($^O eq 'MSWin32' && $Config{_a} eq '.lib') {\r
+    @found = _find_file($name . $Config{_a}, library_search_path());\r
   }\r
   else {\r
   }\r
   else {\r
-    return _find_file("lib" . $name . $Config{_a}, library_search_path());\r
+    @found = _find_file("lib" . $name . $Config{_a}, library_search_path());\r
+  }\r
+  if (@found) {\r
+    push @lflags, "-L$_" for @found;\r
   }\r
   }\r
+  @found;\r
 }\r
 }\r