andreas1234567 has asked for the wisdom of the Perl Monks concerning the following question:

I recently got co-maintainership of a module which depends on PHP version 5. More specifically, it requires The former is easy using File::Find as shown here. However, I do not know how to reliably do the latter.

ExtUtils::MakeMaker goes to great lengths to check that libraries are installed, and emits this message upon failure:

Note (probably harmless): No library found for -lphp5
I'd like to catch that warning. Can I make an assessment based on the return value from ExtUtils::MakeMaker?

My goal is to simply abort (i.e. die) the 'perl Makefile.PL' if not all of the above requirements are met. Is there a reliable, platform-independent way of doing that in perl?

Replies are listed 'Best First'.
Re: Detect library in Makefile.PL
by syphilis (Archbishop) on Nov 13, 2008 at 10:11 UTC
    It's intended that Devel::CheckLib can help with this. I haven't taken a close look - ymmv.

    Cheers,
    Rob
      Devel::CheckLib looks promising, but it silently converts gcc's compiling errors to "Can't link/include":
      use strict; use warnings; use Devel::CheckLib; our $debug ||= 0; my @headers = qw ( php_main.h ); my @incpath = qw( /usr/local/include /usr/local/include/php /usr/local/include/php/main /usr/local/include/php/TSRM /usr/local/include/php/Zend /usr/local/include/php/ext /usr/local/include/php/ext/date/lib ); check_lib_or_exit( header => \@headers, incpath => \@incpath, debug => $debug, ); __END__
      $ perl -sl devel.checklib.pl Can't link/include 'php_main.h' $ perl -sl devel.checklib.pl -debug 1 # /usr/bin/gcc assertlibSu6peu8p.c -I/usr/local/include -I/usr/local/i +nclude/php -I/usr/local/include/php/main -I/usr/local/include/php/TSR +M -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/l +ocal/include/php/ext/date/lib -o assertlib27VD0sdi In file included from /usr/local/include/php/Zend/zend_globals.h:28, from /usr/local/include/php/main/php_main.h:25, from assertlibSu6peu8p.c:1: /usr/local/include/php/Zend/zend_globals_macros.h: In function `BEGIN_ +EXTERN_C':/usr/local/include/php/Zend/zend_globals_macros.h:37: error +: storage class specified for parameter `ZEND_API' /usr/local/include/php/Zend/zend_globals_macros.h:37: error: syntax er +ror before "struct"
      Is it a bug, or am I missing something?
      --
      No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]
Re: Detect library in Makefile.PL
by Anonymous Monk on Nov 13, 2008 at 11:41 UTC