[Rd] C macros and Makevars/package building

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Sep 9 08:38:16 CEST 2005


Kasper Daniel Hansen <khansen at stat.berkeley.edu> writes:

> Hi
> 
> We are currently embedding a rather large C++ library in R (BioC),  
> and we want some comments on the portability of how we have approach  
> this.
> 
> First of, we are not really able to do much about the portability of  
> the basic library, which of course is the main question :) We have an  
> approach which seems to work, I just want a bit of feedback on it....
> 
> The way we integrate it into R is simply by having a subdirectory  / 
> src/sdk together with a Makevars file. This file basically looks like
> 
> PKG_CPPFLAGS+=\
>    -imacros R_affx_constants.h\
>    -Isdk/files\
>     (... + a lot of other -I statements telling CPP to include  
> subdirectories of src/sdk)
> 
> Then we have a
> 
> SOURCES.SDK = \
>    sdk/files/FileIO.cpp \
>    (... + a lot of other .cpp files)
> SOURCES.OURS = \
>    R_affx_cdf.cpp
> 
> and then finally a
> 
> OBJS=$(SOURCES.SDK:.cpp=.o) $(SOURCES.OURS:cpp:.o)
> 
> We seem to need the last statement since it seems that .cpp is not  
> automatically a C++ suffix (but is it done the "right" way for  
> portability?). 

Er, I don't think it has to do with .cpp being a known suffix or not. 
If it wasn't, you would use SUFFIXES and a .cpp.o rule. The last line
comes from specifying sources, rather than objects.
Traditional make style would be

OBJS.SDK = \
   sdk/files/FileIO.o \
   (... + a lot of other .cpp files)
OBJS.OURS = \
    R_affx_cdf.o

OBJS = $(OBJS.SDK) $(OBJS.OURS)

from which the suffix rules would deduce the source files.

> We need the -imacro statement in order to include some  
> macros from Rconfig.h (big endian checks) which are then translated  
> from the WORDS_BIGENDIAN used in R to the IS_BIG_ENDIAN used in the  
> library.
> 
> Comments on the portability?
> 
> Kasper
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-devel mailing list