[Rd] gfortran Makefile for windows

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Sep 28 14:43:46 CEST 2005


On Wed, 28 Sep 2005, Prof Brian Ripley wrote:

> I am unaware that gfortran or gcc4 exist as a MinGW binary for Windows.
> You mention Cygwin, but that is not a supported platform for R.
>
> There is a g95 binary for Windows.

At www.g95.org, but I found no installation instructions relevant to 
Windows.  Some comments at the end of this message.

[...]

> Support for F95 files is planned for R 2.3.0, but depends on being able to
> differentiate F77 and F95 sources where needed (most platforms).
> Meanwhile we will try to add an example to the R-admin manual for 2.2.0.

Here is an example src/Makefile.win for a package called testf95 that uses 
F95/F90 only.

% cat testf95/src/Makefile.win

DLLNAME=testf95 # will not be needed in 2.2.0

include $(RHOME)/src/gnuwin32/MkRules

F90SOURCES=$(wildcard -f *.f90)
F95SOURCES=$(wildcard -f *.f95)
OBJS=$(F90SOURCES:.f90=.o) $(F95SOURCES:.f95=.o)

G95=c:/packages/g95/bin/g95
MINGW=c:/packages/gcc-3.4.4/

.SUFFIXES: .f90 .f95
.f90.o:
 	$(G95) -c $< -o $@
.f95.o:
 	$(G95) -c $< -o $@

## at least on my setup, G95 is not searching MinGW libs.
DLL=$(G95) -L$(MINGW)/lib

all: $(DLLNAME).dll

## Rules copied from MakeDll

RCNAME=${DLLNAME}_res
RCOBJ=$(RCNAME).o
RESFLAGS=--include-dir $(RHOME)/include
$(DLLNAME)_res.rc:
 	@PERL5LIB=$(RHOME)/share/perl perl 
$(RHOME)/src/gnuwin32/makeDllRes.pl $(DLLNAME) > $@
$(DLLNAME)_res.o: $(DLLNAME)_res.rc $(RHOME)/include/Rversion.h
$(DLLNAME).a: $(OBJS)
$(DLLNAME).dll : $(DLLNAME).a $(RCOBJ)


It works for me, but do be aware that it will depend on the
fine details of how your MinGW/G95 tools are installed.  I had to copy
dllcrt2.o from MINGW/lib to
C:/packages/g95/lib/gcc-lib/i686-pc-mingw32/4.0.1 since the paths are
processed after that file.  It is probably better to fiddle with the specs 
file.


-- 
Brian D. Ripley,                  ripley at 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



More information about the R-devel mailing list