From ripley at stats.ox.ac.uk  Thu Jul  3 15:56:08 2003
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu Jul  3 15:56:12 2003
Subject: [Rd] Use of PKG_FFLAGS on Windows
In-Reply-To: <1F2CE8D4B0195E488213E8B8CCF714860161B66F@saffron.cfs.le.ac.uk>
Message-ID: <Pine.LNX.4.44.0307031447440.1887-100000@gannet.stats>

On Thu, 3 Jul 2003, Hotz, T. wrote:

> Dear all,
> 
> After reading the manuals (especially R-exts) I haven't found 
> an answer to the following question yet.
> 
> I was compiling someone else's Fortran routines to make them 
> available with R. Hear, I should not that I don't know anything 
> about Fortran, and I only tried to built a shared library.
> 
> Linux being my platform of choice when developing for R, I first 
> got everything done there, using R CMD COMPILE, and R CMD SHLIB. 
> Since g77 complained about the Fortran Codes indentation style, 
> I assumed (after reading g77's manpage) that the Fortran code is 
> given in free-form dialect. Therefore, I added a line 
> PKG_FFLAGS+= -ffree-form to Makevars. Compilation and building 
> went fine and I successfully accessed the routines using dyn.load 
> and .Fortran.
> 
> My colleague, who wanted this done, runs R under windows. So I 
> learnt how to build a package under windows (readme.packages is a 
> great guide!), and it went all smoothly, except: option -free-form 
> no longer was passed to g77 (from Rtools), which caused compilation 
> to fail. Renaming Makevars to Makevars.win did not help.
> 
> Investigating this in more detail, I found that MakeDLL contains 
> the line
> <snip>
> FFLAGS=-O2 $(DEBUGFLAG)
> <snip>
> so PKG_FFLAGS weren't used at all. Changing this line to
> <snip>
> FFLAGS=$(PKG_FFLAGS) -O2 $(DEBUGFLAG)
> <snip>
> resolved the problem, however. I subsequently was again able to access 
> the routines of the built library.
> 
> My question now is: is this behaviour intended, and, if so, why? I am 
> curious only because I might want to make this package freely 
> available, and wouldn't like to ask people to change MakeDLL which I 
> assume was written that way for good reasons. If the change in 
> MakeDLL is not necessary, how do I then pass a compiler option to g77?
> 
> Any comments and suggestions are very welcome. I hope my minor 
> knowledge has not raised problems to far off-topic. Thanks  in advance 
> for your time and help.

Why no just transform the Fortran to legal Fortran?  You can't assume that
your users are going to be using gcc (and from your comments I gather you 
are intending to distribute this).

PKG_FFLAGS has never been implemented on Windows, because we have never
seen a need for it.  I have just added it to the development version.
Nevertheless, it will be hard to find compiler-independent settings and I 
actually don't know of any possibilities.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] Use of PKG_FFLAGS on Windows
Prof Brian Ripley