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 -*-
PKG_CPPFLAGS = -I./UFconfig
## 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
OBJECTS = $(SOURCES_C:.c=.o)
SUBDIRS = CHOLMOD COLAMD AMD
SUBLIBS = $(SUBDIRS:=.a)
all: $(SHLIB)
## making src/*.o and in sublibs can be done simultaneously
# for development:
#$(SHLIB): $(OBJECTS)
# 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; \
done
clean: subclean
@-rm -rf .libs _libs
@-rm -f *.o $(SHLIB)
subclean:
@-rm -f *.a
@for d in $(SUBDIRS); do \
(cd $${d} && MkInclude="$(MkInclude)" $(MAKE) clean) ||
exit 1; \
done
include scripts/DEPS.mkf
-----------------------------------------------------------------------------
--
Three out of two people have difficulties with fractions.