Re: [Rd] Makevars, cc files in multiple directories

From: Dirk Eddelbuettel <>
Date: Sat, 31 Oct 2009 14:58:52 -0500

On 29 October 2009 at 11:47, Saptarshi Guha wrote:
| Hello,
| In the src folder of my R package I have
| f/g/
| my 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: PKG_LIBS = $(SUBLIBS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) 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.

______________________________________________ mailing list
Received on Sat 31 Oct 2009 - 20:00:10 GMT

This archive was generated by hypermail 2.2.0 : Sat 31 Oct 2009 - 20:00:18 GMT