From ripley at stats.ox.ac.uk  Thu Dec 20 23:23:49 2007
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu, 20 Dec 2007 22:23:49 +0000 (GMT)
Subject: [Rd] SHLIB steps on a Makefile
In-Reply-To: <dba1e14b0712201349t552a9409mb96b1007b3b6a483@mail.gmail.com>
References: <dba1e14b0712201349t552a9409mb96b1007b3b6a483@mail.gmail.com>
Message-ID: <Pine.LNX.4.64.0712202206210.11123@gannet.stats.ox.ac.uk>

On Thu, 20 Dec 2007, Iago Mosqueira wrote:

> Hi,
>
> I need to create a Makefile.win for a given package so as to fiddle
> slightly with the compilation process. My Makefile works fine in Linux

That's rather dangerous: we have had lots of trouble with packages for 
which the Makefile works on the maintainer's Linux, but not on other 
people's systems (even Linux ones).

Do you really, really need a Makefile.win?: I would be surprised if you 
did.  Only 9 CRAN packages have a Makefile.win, and two of those are 
dummies and one other we have asked the maintainers to replace by 
Makevars.win as it is not portable.

> but I am having trouble creating Makefile.win for MinGW. I first
> looked at the commands that Rcmd SHLIB appeared to be running and
> copied those onto the Makefile. But one step seems to be missing, the
> creation of the _res.rc file needed by windres
>
> 	g++-sjlj -I$(RHOME)/include -I../inst/include/ -O2 -Wall -c pkg.cpp -o pkg.o
> 	windres --preprocessor="gcc-sjlj -E -xc -DRC_INVOKED"
> -I$(RHOME)/include -I../inst/include -i pkg_res.rc -o pkg_res.o
> 	g++-sjlj -shared -s -o pkg.dll pkg.def pkg.o FL pkg_res.o -L$(RHOME)/bin -lR
>
> This might be fairly obvious, but it is my first attempt at compiling
> with MinGW and my search has been fruitless.
>
> What is it that I need to add to replicate what Rcmd SHLIB does?

Adding the resources is not essential: they add identification to the 
DLL which can be very useful but are icing on the cake.  So I would not 
try to emulate that step.

But the Makefile in use is src/gnuwin32/MakeDll and that contains

$(DLLNAME)_res.rc:
         @PERL5LIB=$(RHOME)/share/perl $(PERL) $(RHOME)/src/gnuwin32/makeDllRes.pl $(DLLNAME) > $@

$(DLLNAME)_res.o: $(DLLNAME)_res.rc $(RHOME)/include/Rversion.h

-- 
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



[Rd] SHLIB steps on a Makefile
Prof Brian Ripley