[Rd] Makevars, cc files in multiple directories

Paul Roebuck plroebuck at mdanderson.org
Thu Oct 29 17:46:07 CET 2009


On Thu, 29 Oct 2009, Saptarshi Guha wrote:

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

I have used something like the following to achieve a
similar goal. Create a library (foo.a) based on its
subdirectory makefile (foo_r.mk) and then have the package
link with it (foo.a).

HTH




---------------- Makevars ------------------
###
### MAKEVARS
###

FOODIR    = ./f/g
FOOSRC    = $(FOODIR)
FOOINCDIR = $(FOODIR)/include
FOOLIBDIR = $(FOODIR)
FOOLIB    = -lfoo

PKG_CPPFLAGS = -DNDEBUG -I$(FOOINCDIR)
PKG_LIBS = -L$(FOOLIBDIR) $(FOOLIB) $(LIBM)

##
## Targets
##
all: foo $(SHLIB)

foo:
	(cd $(FOOSRC) && $(MAKE) -f foo_r.mk)

.PHONY: foo all

---------------- foo.mk ---------------------
###
###
### Makefile for FOO library (R environment)
###
###

include $(R_HOME)/etc${R_ARCH}/Makeconf

               AR = ar clq
           RANLIB = ranlib

LIBRARY= foo
MAJOR  = 1
MINOR  = 0
SRCS   = x.c \
         y.c \
         z.c
OBJS   = ${SRCS:.c=.o}

##
## Targets
##
all: lib$(LIBRARY).a

lib$(LIBRARY).a: $(OBJS)
        $(RM) $@
        $(AR) $@ $(OBJS)
        $(RANLIB) $@

clean:
        $(RM) *.o core *.a

.PHONY: clean all

----------------------------------------------------------
SIGSIG -- signature too long (core dumped)



More information about the R-devel mailing list