[R] source package build/installation with subdirectory-lib

Murat Tasan mmuurr at gmail.com
Mon Oct 4 23:24:21 CEST 2010


i've simplified this process to illustrate what i'm not getting (i.e.
doing wrong) regarding Makevars:

take any R source package of yours (best to pick one that hasn't ever
needed a Makevars file), and add a Makevars in src with:

.PHONY: all testtarget

all: $(SHLIB)

$(SHLIB): testtarget

testtarget:
        echo 'foobar';


now try to install the package (with the -d flag for debugging and
verbose output).

'foobar' never appears (at least on my system, but the compilation
process of the shared library code does indeed begin).
Makevars is in the src directory (with some other source files).

am i completely off here in my usage of Makevars?

thanks!

-murat


On Oct 4, 4:52 pm, Murat Tasan <mmu... at gmail.com> wrote:
> hi all - i have a source package i'm writing that i'd like to be able
> to install with a special library that my R src files rely on.
> to be more precise, i have a normal R package directory structure
> (i.e. src/ R/ man/ DESCRIPTION NAMESPACE etc.).
> i also have another directory here called depPkg, and it has it's own
> configure file for the canonical './configure && make && make install'
> installation.
>
> so myPkg looks like so (only showing the relevant pieces):
>
> + myPkg
> |--- DESCRIPTION
> |--- NAMESPACE
> |--- R/   (with R files in here)
> |--- src/   (with my .c files in here)
> |--- depPkg/   (with all of the package contents (e.g. src, docs,
> configure script, etc)
>
> if i switch into and build depPkg by hand it works just fine, and i
> set a configure option to locate the .a library file it creates into
> the depPkg/lib/ directory, like so:
> bash$ ./configure --prefix=./lib --with-pic --disable-shared
> this builds depPkglib.a and puts it in the lib directory under depPkg.
>
> now when i compile *my* shared library in testing, it also works just
> fine:
> bash$ cd src
> bash$ gcc -std=gnu99 -I/usr/share/R/include -I../depPkg/include -fpic -
> g -O2 -c mycode.c -o mycode.o
> bash$ gcc -std=gnu99 -shared -o mycode.so mycode.o -L/usr/lib64/R/lib -
> lR -L../depPgk/lib -ldepPkg
>
> when in R, i can now use dyn.load("mycode.so") and .Call(...) with my
> C functions perfectly.
>
> now i want to build the package so i can install it easily on my
> colleagues' machines.
> so i use the normal R build mechanism (R CMD build), but first create
> a Makevars file that looks like so:
>
> PKG_CPPFLAGS = -I../depPkg/include
> PKG_LIBS = ../depPkg/lib
>
> .PHONY: all mylibs
>
> all: $(SHLIB)
>
> $(SHLIB): mylibs
>
> mylibs:
>         (cd ..; gunzip depPgk.tar.gz; tar -xf depPkg.tar; cd depPkg; ./
> configure --prefix=./lib --with-pic --disable-shared; make; make
> install)
>
> finally, when i try R CMD INSTALL, i know it sees the Makevars file,
> because the first build step shows the added include path (from the
> PKG_CPPFLAGS variable), but it never seems to execute the commands for
> the mylibs target, thus the compiling step of my code fails.
>
> sorry for the long-winded description, but without it i think this
> would have made no sense (and likely still doesn't).
>
> i have also tried moving depPgk INTO the src directory and updating
> the necessary ../ to ./ in the Makevars, but target mylibs never seems
> to be built first.
>
> anyone ever try something like this and have some pointers on how to
> debug?
>
> thanks much for any help,
>
> -murat
>
> ______________________________________________
> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list