From plroebuck at mdanderson.org  Thu Oct 29 17:46:07 2009
From: plroebuck at mdanderson.org (Paul Roebuck)
Date: Thu, 29 Oct 2009 11:46:07 -0500 (CDT)
Subject: [Rd] Makevars, cc files in multiple directories
In-Reply-To: <04B3F9E2-03F7-455F-A656-E934FA94383E@gmail.com>
References: <04B3F9E2-03F7-455F-A656-E934FA94383E@gmail.com>
Message-ID: <Pine.OSF.4.58.0910291118260.64323@wotan.mdacc.tmc.edu>

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)



[Rd] Makevars, cc files in multiple directories
Paul Roebuck