From: Tony Cook Date: Mon, 7 Apr 2008 12:20:29 +0000 (+0000) Subject: - improved the error messages displayed when headers and libraries X-Git-Tag: v0.008~10 X-Git-Url: http://git.imager.perl.org/imager-screenshot.git/commitdiff_plain/574c4fe0dc2704c4fb0f09d3d5ae1bdfa133f85f?hp=e6d8f15b0cb24f3d93fcec4e19ecc7888e06530b - improved the error messages displayed when headers and libraries can't be found http://rt.cpan.org/Ticket/Display.html?id=32856 - added --incpath and --libpath options to Makefile.PL and also look in $ENV{IM_INCPATH} and $ENV{IM_LIBPATH} like Imager. --- diff --git a/Changes b/Changes index a15197d..f8fcf13 100755 --- a/Changes +++ b/Changes @@ -1,9 +1,17 @@ 0.006 unreleased - - screenshot() on a non-toplevel Tk widget would crash when - calling the frame method. Since this call appears to be - unnecessary I've removed it, and plan to run tests on a few - platforms to check I haven't broken anything. - RT #32843 - thanks to Slaven Rezic. + +- screenshot() on a non-toplevel Tk widget would crash when + calling the frame method. Since this call appears to be + unnecessary I've removed it, and plan to run tests on a few + platforms to check I haven't broken anything. + RT #32843 - thanks to Slaven Rezic. + +- improved the error messages displayed when headers and libraries + can't be found + http://rt.cpan.org/Ticket/Display.html?id=32856 + +- added --incpath and --libpath options to Makefile.PL and also look + in $ENV{IM_INCPATH} and $ENV{IM_LIBPATH} like Imager. 0.005 12 Mar 2007 - 0.005 release diff --git a/Makefile.PL b/Makefile.PL index f6d95ee..e314bd3 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -5,6 +5,13 @@ use Imager 0.54; use Imager::ExtUtils; use Config; use File::Spec; +use Getopt::Long; + +my @incpaths; # places to look for headers +my @libpaths; # places to look for libraries + +GetOptions("incpath=s", \@incpaths, + "libpath=s" => \@libpaths); my @objs = qw/Screenshot.o/; my @cflags; @@ -12,13 +19,15 @@ my @lflags; my %seen_incdir; my %seen_libdir; my $X11_lib = $^O eq 'cygwin' ? 'X11.dll' : 'X11'; -if (find_header("X11/Xlib.h") and find_lib($X11_lib)) { +if (find_header("X11/Xlib.h", "X11 header") + and find_lib($X11_lib, "X11 library")) { push @objs, 'scx11.o'; push @cflags, '-DSS_X11'; push @lflags, '-l'.$X11_lib; print "Found X11\n"; } -if (find_header('windows.h') and find_lib('gdi32')) { +if (find_header('windows.h', "Win32 header") + and find_lib('gdi32', "Win32 library")) { push @objs, 'scwin32.o'; push @cflags, '-DSS_WIN32'; if ($^O eq 'cygwin') { @@ -28,9 +37,24 @@ if (find_header('windows.h') and find_lib('gdi32')) { } unless (@objs > 1) { - die "NA: Sorry, I can't find headers or libraries for a supported GUI\n" + die < 'Imager::Screenshot', @@ -41,6 +65,7 @@ my %opts = }, INC => Imager::ExtUtils->includes, TYPEMAPS => [ Imager::ExtUtils->typemap ], + EXTRA_META => $extra_meta, ); $opts{LIBS} = "@lflags" if @lflags; @@ -66,6 +91,9 @@ my @incs; sub header_search_path { @incs and return @incs; + push @incs, map {; split /\Q$Config{path_sep}/ } @incpaths; + push @incs, split /\Q$Config{path_sep}/, $ENV{IM_INCPATH} + if defined $ENV{IM_INCPATH}; push @incs, '/usr/include', '/usr/X11R6/include' unless $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/; push @incs, split /\Q$Config{path_sep}/, $ENV{INCLUDE} @@ -86,6 +114,9 @@ my @libs; sub library_search_path { @libs and return @libs; + push @libs, map {; split /\Q$Config{path_sep}/ } @libpaths; + push @incs, split /\Q$Config{path_sep}/, $ENV{IM_LIBPATH} + if defined $ENV{IM_LIBPATH}; push @libs, '/usr/lib', '/usr/X11R6/lib' unless $^O eq 'MSWin32' && $Config{cc} =~ /\bcl\b/; push @libs, split /\Q$Config{path_sep}/, $ENV{LIB} @@ -102,7 +133,6 @@ sub library_search_path { @libs; } - sub _find_file { my ($name, @where) = @_; @@ -110,28 +140,38 @@ sub _find_file { } sub find_header { + my ($name, $description) = @_; my @found = _find_file($_[0], header_search_path()); if (@found) { - push @cflags, "-I$_" for grep !$seen_incdir{$_}, @found; - @seen_incdir{@found} = (1) x @found; + push @cflags, "-I$_" for grep !$seen_incdir{$_}, @found; + @seen_incdir{@found} = (1) x @found; + } + else { + print STDERR "Could not find $name ($description)\n"; } @found; } sub find_lib { - my $name = shift; + my ($name, $description) = shift; my @found; + my $libname; if ($^O eq 'MSWin32' && $Config{_a} eq '.lib') { - @found = _find_file($name . $Config{_a}, library_search_path()); + $libname = $name . $Config{_a}; } else { - @found = _find_file("lib" . $name . $Config{_a}, library_search_path()); + $libname = "lib" . $name . $Config{_a}; } + @found = _find_file($libname, library_search_path()); if (@found) { push @lflags, "-L$_" for grep !$seen_libdir{$_}, @found; @seen_libdir{@found} = (1) x @found; } + else { + print STDERR "Could not find $libname ($description)\n"; + } + @found; }