1

My distro does not offer any gsl <2.6 any more.

Given:

  • Alien::GSL 1.01
  • /tmp/gsl-2.5.tar.gz

How do I force it to compile that gsl instead of downloading from GNU FTP version 2.6, which I already have on the system anyway but is not delectable to Math::GSL 0.40?

I unsuccessfully tried:

  • copying the tarball into the unpacked Alien::GSL base directory
  • messing with alien_repository

This is for a throw-away project. I'm okay with manual installation instructions and patching toolchain code.

daxim
  • 39,270
  • 4
  • 65
  • 132
  • 1
    Looks like it uses `pkg-config --modversion gsl` to check if the library is already installed. I don't know what that is, or how it knows what libraries are installed. – ikegami Sep 29 '19 at 13:07
  • If you already have `libgsl` version 2.6 on you system, you might also have the command `gsl-config`. What is the output of running `gsl-config --version`? From [the source](https://metacpan.org/source/LETO/Math-GSL-0.40/Build.PL#L296) it seems it will try `gsl-config` first. – Håkon Hægland Sep 29 '19 at 13:19
  • When you run `pkg-config --modversion gsl`, it says `Package gsl was not found in the pkg-config search path. Perhaps you should add the directory containing 'gsl.pc' to the PKG_CONFIG_PATH environment variable No package 'gsl' found` I think that `gsl.pc` is created when you build `gsl`. Try building 2.5, and check if it creates a `gsl.pc`. If so, follow the above instructions, and you should be ok – ikegami Sep 29 '19 at 13:19
  • Did you try just changing `my $ver2func = Ver2Func->new( $gsl_conf->{gsl_version} );` to `my $ver2func = Ver2Func->new( '2.5' );` in Math::GSL's `Build.PL`? Hopefully, 2.6 is backwards compatible with 2.5 – ikegami Sep 29 '19 at 13:24
  • I had deinstalled on purpose gsl-devel-2.6, wich includes pkgconfig files and gsl-config, so it does not interfere. I want to build gsl-2.5 **through Alien::GSL** from a local tarball. /// @ikegami, forcing the version that way eventually errors out in `xs/SparseMatrix_wrap.2.5.c`; not compatible. – daxim Sep 29 '19 at 13:43
  • The whole point of Alien::* is to install *if not already installed*, which goes back to my first two comments. – ikegami Sep 29 '19 at 14:02
  • Why not install from source: `tar zxvf /tmp/gsl-2.5.tar.gz && cd gsl-2.5 && ./configure --prefix=/opt/gsl/gsl-2.5 && make && sudo make install`. Then make `/opt/gsl/gsl-2.5/bin` available in `$PATH` such that it finds `/opt/gsl/gsl-2.5/bin/gsl-config` ? – Håkon Hægland Sep 29 '19 at 14:07
  • Looks like it unconditionally takes the newest version `$cabinet->sort_files; { local $CWD = $self->alien_temp_dir; my $file = $cabinet->files->[0]; `. I didn't see anyway (e.g. using env vars) of overriding the repo specified in Alien::GSL's `Build.PL`, so the only way to get Alien::GSL to build 2.5 would be to edit its `Build.PL`. It looks like you can set `protocol` of `local` to use a local file – ikegami Sep 29 '19 at 14:14
  • But of course, the whole point of Alien::* is to install a module *if it's not already installed*, so makes more sense to just install 2.5 rather than mucking with `Build.PL`. – ikegami Sep 29 '19 at 14:17
  • Since Alien::GSL uses Alien::Base::ModuleBuild, https://metacpan.org/pod/Alien::Base::ModuleBuild#ENVIRONMENT may be helpful. – Grinnz Sep 29 '19 at 14:30

1 Answers1

2

ikegami found the decisive hint:

It looks like you can set protocol of local to use a local file


Tested step-by-step instructions, plus some additional work-arounds; to me it looks like the build systems of the two modules are buggy/insufficiently tested:

cpanm --look Alien::GSL

patch Build.PL

diff --git a/Build.PL b/Build.PL
index 32f3057..6537138 100644
--- a/Build.PL
+++ b/Build.PL
@@ -20,10 +20,9 @@ my $builder = Alien::Base::ModuleBuild->new(
   alien_name => 'gsl',
   alien_repository => [
     {
-      protocol => 'ftp',
-      host     => 'ftp.gnu.org',
-      location => '/gnu/gsl',
-      pattern  => qr/^gsl-([\d\.]+)\.tar\.gz$/,
+      protocol => 'local',
+      location => '/tmp',
+      pattern  => 'gsl-2.5.tar.gz',
     },
   ],
   meta_merge => {
-- 
2.23.0
perl Build.PL
./Build

Pay attention to the generated configure/libtool commands here, they match the Perl configuration. A manual installation without those various options is not guaranteed to be compatible or usable. (This is not superstition: a similar problem historically shows up when installing mod_perl2 and libapreq2 from source on a system httpd; perl needs to be compiled first, then httpd to match, then the other packages, otherwise it won't work.) This shows the value of installing through Alien, since it delegates to M::B, the correct options will be figured out. It's above my level of knowledge to accurately create them from scratch.

./Build test

gsl-config in blib now erroneously contains build paths, not install paths, fix:

perl -MConfig -i -lpe'
    s|/.*(/auto/share/dist/Alien-GSL)|$Config{installsitelib}$1|
' blib/lib/auto/share/dist/Alien-GSL/bin/gsl-config
./Build install
exit # cpanm

cpanm --look Math::GSL
# let it pick up gsl-config on PATH
export PATH=$PATH:$(perl -mAlien::GSL -e'print Alien::GSL->bin_dir')
perl Build.PL
./Build
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(gsl-config --libs | perl -lne'/-L(\S+) / && print $1')
./Build test
./Build install
exit # cpanm

Finally rëexport the variables whenever you want to use Math::GSL.

daxim
  • 39,270
  • 4
  • 65
  • 132