Karim.Belabas on Fri, 15 Jun 2001 14:22:31 +0200 (MET DST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Can't build Math::PARI


On Thu, 7 Jun 2001, Katherine Sauceda wrote:
> Ultimately, I wan to build things like Net:SSH:perl for my perl programmers
> to use. So I need Math::PARI.
> 
> I compiled and installed pari-2.1.1 - no errors. I put Math::PARI in the
> build directory for pari-2.1.1 and make fails (using gcc, no Sun compilers
> installed):
[...]
> make: *** No rule to make target `libPARI/Makefile', needed by
> `libPARI/libPARI.a'.  Stop.
> 
> I get the same error on older versions of the module. Can't seem to find any
> indication of this problem in the news groups. I've looked through the
> patches in Math::PARI and I do not see anything that would address this
> problem.
> 
> Can someone give me some advice, please?

Hi, 

[ I have no previous experience with Math:PARI, there _may_ be a simple
solution to your problems, but I couldn't find one ]

I checked with perl-5.005_03 on Solaris, and indeed it was quite tough to
get Math::PARI to compile:

1) Math::PARI module expects a directory name like pari-2.1.1 (to get a
version number and apply the relevant patch) but in your situation, it gets
something like '..' [and if would get something like 'pari' from the CVS
server, which would fail just the same].

2) On solaris, it fails if SUNWspro is not installed

3) Header files get tangled up (/usr/include/sys/dl.h attempts to declare
ladd which pari.h already defined with a different meaning)

The three patches below address all that, and then things do compile.

Unfortunately, Math::PARI attempts to support old and instable version [e.g
in the range 1.39 --> 2.0.20], and replicates a lot of 'Configure' logic all
by itself, quite incorrectly at times:

a) less than optimal compiler optimization flags, and an obsolete compiler also
on my machine.

b) The shared library Pari.so eventually produced is incorrect:

  ld.so.1: /home/belabas/bin/solaris/perl: elf error:
  blib/arch/auto/Math/Pari/Pari.so: bad ELF type: ET_NONE at
  /usr/local/lib/perl5/5.00503/sun4-solaris/DynaLoader.pm line 169.

I didn't attempt to correct that since I don't intend to replicate the effort
put into the Configure machinery.

Hope this helps somewhat,

    Karim.
  
*** ./Makefile.PL.orig	Fri Jun 15 13:21:56 2001
--- ./Makefile.PL	Fri Jun 15 13:43:56 2001
***************
*** 18,23 ****
--- 18,24 ----
  
  sub format_pari {
    my $dir = shift;
+   $dir = get_pari_version($dir) if ($dir !~ /[0-9]/);
    $dir =~ s/(\d+)\.(\d+).(\d+)/sprintf('%03d%03d%03d',$1,$2,$3)/e;
    $dir;
  }
***************
*** 41,46 ****
--- 42,59 ----
      @gooddirs = sort {format_pari($a) cmp format_pari($b)} @gooddirs;
      $paridir = $gooddirs[-1] if @gooddirs;
    }
+ }
+ 
+ sub get_pari_version {
+   my $v = "", $dir = shift;
+   open(IN, "$dir/config/version");
+   while (<IN>)
+   {
+     if (/=\'*([0-9]*)\'*/) { $v .= "$1."; }
+   }
+   close(IN);
+   $v =~ s/\.*$//;
+   return "pari-$v";
  }
  
  $paridir = get_pari() if !$paridir;  
*** libPARI/Makefile.PL.orig	Fri Jun 15 13:44:23 2001
--- libPARI/Makefile.PL	Fri Jun 15 13:47:03 2001
***************
*** 289,298 ****
--- 289,300 ----
  
  
  if ($Config{osname} eq 'solaris') {
+   if (@sc_dirs) {
      @sc_dirs = </opt/SUNWspro/SC*>;
      die "Cannot find SUNWspro dirs, needed for -lsunmath" unless @sc_dirs;
      $libs .= " -L$sc_dirs[-1]/lib -lsunmath";
      $sol_under = '_nounder';	# Need to filter
+   }
  } elsif ($Config{osname} eq 'sunos') {
    # $machine = 'sparcv8_super' if $Config{myuname} =~ /\bsun4m\b/o;
    $mycflags .= ' -DULONG_NOT_DEFINED';
*** ./Pari.xs.orig	Fri Jun 15 14:04:45 2001
--- ./Pari.xs	Fri Jun 15 14:05:07 2001
***************
*** 1,7 ****
- #include <pari.h>
- #include <language/anal.h>
- #include <gp/gp.h>			/* init_opts */
- 
  #define PERL_POLLUTE			/* We use older varnames */
  
  #ifdef __cplusplus
--- 1,3 ----
***************
*** 15,20 ****
--- 11,20 ----
  #ifdef __cplusplus
  }
  #endif 
+ 
+ #include <pari.h>
+ #include <language/anal.h>
+ #include <gp/gp.h>			/* init_opts */
  
  /* This should not be defined at this moment, but in 5.001n is. */
  #ifdef coeff

-- 
Karim Belabas                    email: Karim.Belabas@math.u-psud.fr
Dep. de Mathematiques, Bat. 425
Universite Paris-Sud             Tel: (00 33) 1 69 15 57 48
F-91405 Orsay (France)           Fax: (00 33) 1 69 15 60 19
--
PARI/GP Home Page: http://www.parigp-home.de/