[Rd] Makevars, cc files in multiple directories

Dirk Eddelbuettel edd at debian.org
Sat Oct 31 20:58:52 CET 2009

On 29 October 2009 at 11:47, Saptarshi Guha wrote:
| Hello,
| In the src folder of my R package I have
| a.cc
| b.cc
| f/g/x.cc
| my Makevars.in has
| all: $(SHLIB)
| upon installing only, a.o and b.o is build and the final dll is  
| comprised of a.o and b.o
| How can I instruct $(SHLIB) to pick up its source files from all  
| subdirectories (or maybe a subset, though here it will be all)
| in src ?

The Matrix package by D Bates and M Maechler has one of the more complex
setups, you could study their example. I include the (short) src/Makevars
below, it uses the (appropriate) Make directive SUBDIRS. And similar to
Paul's suggestionm it seems like static libraries are used to tie the
subdirectories together.

Hth, Dirk

# -*- Makefile -*-

## we use the BLAS and the LAPACK library:

MkInclude = $(R_HOME)/etc${R_ARCH}/Makeconf

include scripts/SOURCES_C.mkf


all: $(SHLIB)
## making src/*.o and in sublibs can be done simultaneously
# for development:
# for real:
$(SHLIB): $(OBJECTS) sublibs

## We have to clean here, to clean up between architectures:
## INSTALL only cleans src/*.o src/*$(SHLIB_EXT) for each arch
sublibs: subclean
	@for d in $(SUBDIRS); do \
	  (cd $${d} && CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" MkInclude="$(MkInclude)" $(MAKE) library) || exit 1; \

clean: subclean
	@-rm -rf .libs _libs
	@-rm -f *.o $(SHLIB)

	@-rm -f *.a
	@for d in $(SUBDIRS); do \
	  (cd $${d} && MkInclude="$(MkInclude)" $(MAKE) clean) || exit 1; \

include scripts/DEPS.mkf

Three out of two people have difficulties with fractions.

More information about the R-devel mailing list