Skip to content

Commit a2d734a

Browse files
Remove non-include paths from INC in pre-build checks (#17)
* Remove non-include paths from INC in pre-build checks While trying to get `PDL::Graphics::PLplot` to install, I found it kept telling me that it needed a plplot library compiled with the `--with-double` option: ``` $ perl Makefile.PL Use of uninitialized value $size in numeric eq (==) at Makefile.PL line 46. Sizeof(PLFLT) must be 8. PLplot must be compiled --with-double (IE ./configure --with-double). Please either: - Install PLplot using your package manager then reinstall Alien::PLplot or - Reinstall Alien::PLplot from CPAN with environment variable ALIEN_INSTALL_TYPE=share. ``` After having tried the advice about reinstalling `Alien::PLplot` and failing, and having checked that `libplplot` had been installed using double precision, I happened to stumble upon the issue that the option `-pthread` was appearing in the `$plplot_include_path` variable. I noticed this by replacing the call to `check_lib` (from `Devel::CheckLib`) with `check_lib_or_exit`. When using this function, the error output was this instead: ``` $ perl Makefile.PL INC argument badly-formed: -pthread ``` Upon reading the docs for `Devel::CheckLib`, it turns out that the `INC` option to both `check_lib` and `check_lib_or_exit` needs to be a space-delimited list of options, all of which start with `-I`. Since `-pthread` doesn't start with `-I` the argument was badly formed, hence the `analyze_binary` callback was never called. Thus no check code was compiled which then resulted in `$size` being set to `undef`. Because `$size` was `undef`, the uninitialized value warning mentioned in the first error message mentione above and the check for a double precision library failed. In other words, because `-pthread` was turning up in the `$plplot_include_path` string, the test for a library compiled with the `--with-double` option was failing and hence `PDL::Graphics::PLplot` failed to install. By filtering only for include paths from the list of options originally found in `$plplot_include_path` (i.e. selecting only options starting with `-I` and hence excluding in this particular instance the `-pthread` option), one avoids the issue of a badly formed INC argument and thus the checks in `Makefile.PL` compile and run. Because all checks run, the `Makefile` is created as per normal and the test suite passes. More background info: I found this issue on Debian version 11.11 with a perlbrewed perl, version 5.32.1.
1 parent 6ac6723 commit a2d734a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Makefile.PL

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use ExtUtils::MakeMaker;
44
use Config;
55
use File::Spec;
66
use Data::Dumper;
7+
use Text::ParseWords qw(shellwords);
78

89
use PDL::Core::Dev;
910
use Devel::CheckLib;
@@ -113,11 +114,13 @@ sub compileAndRun {
113114
my ($code) = @_;
114115
my $result;
115116

117+
my $inc = join " ", grep /^-I/, shellwords($plplot_include_path);
118+
116119
check_lib(
117-
ccflags => "$plplot_include_path",
118-
ldflags => "$libs",
119-
INC => "$plplot_include_path",
120-
LIBS => "$libs",
120+
ccflags => $plplot_include_path,
121+
ldflags => $libs,
122+
INC => $inc,
123+
LIBS => $libs,
121124
header => [ 'stdio.h', $header ],
122125
function => $code,
123126
analyze_binary => sub {

0 commit comments

Comments
 (0)