Re: [Rd] include <R.h>

From: Simon Urbanek <simon.urbanek_at_r-project.org>
Date: Sun, 19 Feb 2012 21:46:23 -0500

Paul,

On Feb 19, 2012, at 9:32 PM, Paul Gilbert wrote:

> On 12-02-19 04:56 PM, Simon Urbanek wrote:

>> Paul,
>> 
>> On Feb 19, 2012, at 2:45 PM, Paul Gilbert wrote:
>> 
>>> I am trying to add
>>> 
>>> #include<R.h>
>>> 
>>> to a .c file in one of my package, so I can call error() without a complaint about implicit defined function. The src/ has a Makefile, to build some exec/ files that are needed. Without the include, my Makefile target
>>> 
>>> OBJS = $(SRC:.c=.o)
>>> 
>>> $(PKGNAME).so: $(OBJS) rpcx.h
>>> 	$(R_HOME)/bin/R CMD SHLIB  $(OBJS)
>>> 
>>> seems to work fine, and I do not need a target for the .o's, the default works. But when I add the include, the location of R.h does not get passed along. How am I suppose to specify $(R_HOME)lib/R/include so that it gets passed along by R CMD SHLIB ?
>>> 
>> 
>> I assume you know that the above general approach won't work very well, so I won't go there... (you don't need Makefile to just add targets).

>
> Simon
>
> I'm not sure if I understand this. I know I could add targets in Makevars or Makerules, but do you means something else? I also need to build some executables and move then into exec/, which I think also implies I need to change the default target in src/. Isn't a Makefile the only way to do that? (I know you said you won't go here, but now I' curious.)
>

No, you can add arbitrary targets to Makevars - the only real difference between Makefile and Makevars is that in the former you have to write all rules by hand whereas the latter includes R rules so you don't need to create them by hand - it is still a fully functional Makefile. One benefit of Makevars is that you are not giving up the capability of your package to be built for all archs (but it also means you have to be good about cleaning up after builds - R only cleans what it knows about).

In you case your Makevars could look like

all: myexec $(SHLIB)

myexec:

	# build your desired exec files
	# put them in in inst... or wherever you need them
	# clean up all build files for myexec

where $(SHLIB) is the default target that R will build (same as R CMD SHLIB) and myexec: is your additional target that you need

Cheers,
Simon

>> But your immediate problem is that you want to use R CMD SHLIB $(SRC) and not $(OBJS), otherwise you'll be missing all C*FLAGS (which includes -I that is needed for the headers) since the compilation will be done by your Makefile and not R.

>
> Thanks, that fixed it!
> Paul
>
>> Cheers,
>> Simon
>> 

>
>


R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 20 Feb 2012 - 02:47:58 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 20 Feb 2012 - 14:30:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive