[R-pkg-devel] Subarchitectures

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Thu Feb 11 21:27:19 CET 2021


On 11/02/2021 2:30 p.m., Balasubramanian Narasimhan wrote:
> If GNU make is acceptable as a system requirement, you can get any R
> configuration/runtime variable in Makevars, e.g.
> 
> R_ARCH=$(shell $(R_HOME)/bin/Rscript -e 'cat(.Platform$r_arch)')


I wanted to avoid it, since WRE discourages it so strongly.  What I 
ended up doing is putting the following into src/Makevars.in:

all: $(SHLIB) @HIDE_IF_NO_OPENGL@ ../inst/useNULL$(R_ARCH)/$(SHLIB)

../inst/useNULL$(R_ARCH)/$(SHLIB): $(SHLIB)
	cp -R *.cpp *.c *.h OpenGL useNULL
	cd useNULL;$(R_HOME)/bin/R CMD SHLIB -o $(SHLIB);rm *.cpp *.c *.h 
OpenGL/*; cd ..
	mkdir -p ../inst/useNULL$(R_ARCH)
	mv useNULL/$(SHLIB) ../inst/useNULL$(R_ARCH)/


The $(SHLIB) target should already have the subarchitecture in it. 
@HIDE_IF_NO_OPENGL@ is set by configure to "#" if OpenGL is not 
available for the build, so the second make target would be commented 
out.  If it's not commented out, then I copy all the source files into 
src/useNULL, and in that directory, I make $(SHLIB) again.  (There's 
another Makevars.in in that directory that has different compiler and 
linker options than the main one.)  Then I move the result to 
inst/useNULL$(R_ARCH)/, which will be inst/useNULL in most cases, but 
will have a subarchitecture directory added on if necessary.

This is complicated, partly because  R CMD check  has a bug 
(https://bugs.r-project.org/bugzilla/show_bug.cgi?id=18054) which means 
you will get check warnings if you try to register entry points in a DLL 
with any name except the same as the name of the package.  So to get a 
modified version of the main DLL, it has to have the same name but be 
stored somewhere else.

The version above passes checks, but it's pretty unusual, so I'm not 
certain it doesn't violate the intention of some rule or other.

Duncan Murdoch



More information about the R-package-devel mailing list