From edd at debian.org  Tue Jun  6 18:23:52 2006
From: edd at debian.org (Dirk Eddelbuettel)
Date: Tue, 6 Jun 2006 11:23:52 -0500
Subject: [Rd] help compiling package with g77
In-Reply-To: <4485A6BA.2000309@zoo.ufl.edu>
References: <4485A6BA.2000309@zoo.ufl.edu>
Message-ID: <17541.44056.795468.923134@basebud.nulle.part>


On 6 June 2006 at 12:00, Ben Bolker wrote:
| 
|    I have a package with some embedded legacy FORTRAN code
| (for computing complex Bessel functions, written in 2003
| by C. Bond to implement the algorithms of Zhang and Jin 1996).
| It worked well until recently [despite warnings about deprecated
| headers "includes at least one deprecated or antiquated header" --
| when I tried to fix these the code stopped working, so I left
| them alone].  Now an upgrade of my Debian system has apparently
| got R switched over from using g77 to gfortran.  The old code

Ah, yes, you may get to blame me live and in person at Use R ...

More seriously, there was a bit of discussion on the debian-science list
where I asked for help with a similar "works with g77, fails with gfortran"
problem on another CRAN package. 

I am open to switching the package back to g77 -- but I'd love to hear from
real Fortran users whether or not they'd support (or oppose) that.  We can
continue here or on the r-sig-debian list.

| has EQUIVALENCE functions in it that gfortran doesn't like ...
| (I know, the right thing would be to go back and understand all
| the code and rewrite it, but I'm not sure I can bear it.)
| 
|   My first attempt was to hack things by replacing /usr/bin/gfortran
| (a link to /usr/bin/gfortran-4.0) with a link to g77; this helped
| things get farther but got me to an unresolved call to do_lio.
| Based on information in the archives from BDR, I commented out
| unnecessary PRINT commands in the FORTRAN code, but this just
| led to another unresolved symbol (e_wfse ???) -- I suspect that
| this is a symptom of R still using gfortran libraries instead
| of g77 libraries.
| 
|   Now I'm trying to figure out what I can do in the Makevars
| file in the package directory to force use of g77 *and* the
| appropriate libraries ... putting
| 
| F77=/usr/bin/g77
| 
| in [pkgname]/src/Makevars doesn't seem to have any effect.
| Even if I force the use of g77, I'm not sure whether it will
| get the right libraries or not ... perhaps I should recompile
| R with F77=/usr/bin/g77 all the way?

Yes, it is pretty trivial.  Do 

	$ apt-get source r-base
	$ cd r-base-2.3.1
	$ edit debian/control   
		# remove the two 'gfortran (>= ...)' with g77
	$ dpkg-buildpackage -rfakeroot -us -uc -tc
		# may need to install build dependencies

and install the local packages -- thanks to Kurt's configure magic, R should
figure out the rest.  

I would also edit debian/changelog; if you set the version number high enough
you want get an auto-upgrade to a Debian revision I may make.

|   I have poked around in The Fine Manuals quite a bit ... if anyone
| has pointers I would be grateful.  This'll teach me to upgrade.

Upgrades are the Right Thing (TM).  Just talk to your friendly neighbourhood
maintainer if you think the package went astray.

Cheers, Dirk

-- 
Hell, there are no rules here - we're trying to accomplish something. 
                                                  -- Thomas A. Edison



[Rd] help compiling package with g77
Dirk Eddelbuettel