Skip to content
Prev 40312 / 63424 Next

Calling Rscript from Makevars

Hi,
I've found this type of thing to be extremely confusing, myself, but I
managed to get something to work. I'm not sure how well. I also don't know
if R is running autoconf or just configure--at least I don't remember off
the top of my head. However, here are some examples of commands I put in my
configure.ac file: 
CC=`"${R_HOME}/bin/R" CMD config CC`
CXX=`"${R_HOME}/bin/R" CMD config CXX`
CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
PKG_LIBS=`${R_HOME}/bin/Rscript -e "Rcpp:::LdFlags()"`
then you can use some preset commands such as:
AC_PROG_CC
or generic commands such as:
AC_SUBST(whateverVariableYouLike)
and make sure to put in the key command at the bottom before AC_OUTPUT:
AC_CONFIG_FILES([src/Makefile])
If R runs autoconf before ./configure when packaging or installing, you will
be fine with just the configure.ac. Otherwise you might have to run autoconf
before packaging. 
Anyway, what this will do is create a configure script when autoconf is run.
When ./configure is run by R when installing, it will execute replacement
commands on src/Makefile.in to generate the new Makefile.
Anything within two @ symbols will be replaced.
examples inside my Makefile.in:
CC = @CC@
CXX = @CXX@
I still haven't figured out how to do the Makevars thing, but I've
completely given up on R documentation. The key part from the R
documentation that I found useful was that it calls configure on install, so
you can use autoconf documentation to figure out how to set things up.
I'm sure I probably left out a ton of info, but those are my two cents.
Please feel free to ask me for more details if you are interested.
Good luck,
Sean
On 5/20/11 12:04 PM, "Martyn Byng" <Martyn.Byng at nag.co.uk> wrote: