[Rd] Calling Rscript from Makevars

Simon Urbanek simon.urbanek at r-project.org
Sat May 21 03:40:09 CEST 2011


Sean,

On May 20, 2011, at 9:00 PM, Sean Robert McGuffee wrote:

> 
>> Note that setting PKG_LIBS in configure won't work since configure doesn't
>> know how to handle it. It may be ok if you don't care that the flags won't be
>> checked, but then you better know what you're doing ;).
>> 
> Why wouldn't PKG_LIBS work in configure?
> 
> configure.ac:
> 
> PKG_LIBS=`${R_HOME}/bin/Rscript -e "Rcpp:::LdFlags()"`
> AC_SUBST(PKG_LIBS)
> 
> src/Makefile.in:
> PKG_LIBS = @PKG_LIBS@
> 

It will "work" as in the substitution will take place but any tests you run in configure will ignore it since autoconf only uses LIBS and not PKG_LIBS. That's why the standard procedure is to set LIBS and then use PKG_LIBS=@LIBS@ in Makevars.in (there are many ways to do this, though).


>> You have to run autoconf yourself - R has no way of knowing how to bootstrap
>> your setup. Some authors prefer to use the maintainer mode in configure for
>> that, but you still have to create some configure script.
> 
> Good to know--I hoped that explained what was happening sometimes when
> autoconf needed to be run.
> NOTE: The manual says,
> "1.2 Configure and cleanup
> Note that most of this section is specfic to Unix-alikes: see the comments
> later on about the Windows port of R.
> 
> If your package needs some system-dependent configuration before
> installation you can include an executable (Bourne shell) script configure
> in your package which (if present) is executed by R CMD INSTALL before any
> other action is performed.  This can be a script created by the Autoconf
> mechanism, but may also be a script written by yourself.  Use this to detect
> if any nonstandard libraries are present such that corresponding code in the
> package can be disabled at install time rather than giving error messages
> when the package is compiled or used.  To summarize, the full power of
> Autoconf is available for your extension package (including variable
> substitution, searching for libraries, etc.). "
> 
> It might be worth someone revizing this to take out the Autoconf term if it
> really isn't even being used.
> 

It simply says that the configure can be created by autoconf or manually - entirely up to you. It also says explicitly that for this you must include a script named configure so it's quite unmistakable that R won't be creating it.

Cheers,
Simon


> 
>> 
>> 
>>> 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@
>> 
>> You can omit all that if you use Makevars. Also using Makefile is discouraged
>> because it forces you to replicate the whole building process which is very
>> error prone (and may be different for each version of R).
>> 
>> 
>>> I still haven't figured out how to do the Makevars thing,
>> 
>> 
>> It's very simple - just remove all targets from your Makefile and you have
>> Makevars since R will do the compilation and linking for you and correctly. If
>> you feel like it, you can override its behavior by adding one rule (e.g.,
>> all:) that lists your desired dependency and you can pass on to the R default
>> by depending on $(SHLIB).
>> 
>> Cheers,
>> Simon
>> 
>> 
>> 
>>> 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:
>>> 
>>>> Hi,
>>>> 
>>>> I am trying to package some code to use with R and wanted to call
>>>> Rscript from within the Makevars file (I am trying to automate the
>>>> setting of the location of a third party library depending on what is
>>>> available / the system the package is being installed on).
>>>> 
>>>> If I just have a simple Makevars containing
>>>> 
>>>> 
>>>> PKG_LIBS= -lnag_nag -L/fserver/nagprod/FL22/fll6a22df/lib
>>>> 
>>>> 
>>>> the package is built without any errors, if I attempt to add a call to
>>>> Rscript, for example (which I think is the way that "Writing R
>>>> Extensions" recommends):
>>>> 
>>>> 
>>>> R_SCRIPT_NAME=Rscript
>>>> ifneq ($(R_HOME),)
>>>> R_SCRIPT=$(R_HOME)/bin$(R_ARCH_BIN)/$(R_SCRIPT_NAME)
>>>> else
>>>> R_SCRIPT=$(R_SCRIPT_NAME)
>>>> endif
>>>> R_ARCH=$(shell $(R_SCRIPT) -e 'cat(R.version$$arch)')
>>>> 
>>>> PKG_LIBS= -lnag_nag -L/fserver/nagprod/FL22/fll6a22df/lib
>>>> 
>>>> 
>>>> I get the following error:
>>>> 
>>>> * checking for file 'NAGFWrappers/DESCRIPTION' ... OK
>>>> * preparing 'NAGFWrappers':
>>>> * checking DESCRIPTION meta-information ... OK
>>>> * cleaning src
>>>> make: Nothing to be done for `clean'.
>>>> * removing junk files
>>>> * checking for LF line-endings in source and make files
>>>> * checking for empty or unneeded directories
>>>> * building binary distribution
>>>> * installing *source* package 'NAGFWrappers' ...
>>>> ** libs
>>>> /usr/share/R/make/shlib.mk:3: /usr/lib64/R/etcx86_64/Makeconf: No such
>>>> file or directory
>>>> make: *** No rule to make target `/usr/lib64/R/etcx86_64/Makeconf'.
>>>> Stop.
>>>> ERROR: compilation failed for package 'NAGFWrappers'
>>>> * removing '/tmp/Rinst1513764321/NAGFWrappers'
>>>> ERROR
>>>> * installation failed
>>>> 
>>>> 
>>>> Any help / pointers would be appreciated.
>>>> 
>>>> Cheers
>>>> 
>>>> Martyn
>>>> 
>>>> Output from R.version:
>>>> 
>>>> platform       x86_64-redhat-linux-gnu
>>>> arch           x86_64
>>>> os             linux-gnu
>>>> system         x86_64, linux-gnu
>>>> status         
>>>> major          2
>>>> minor          11.0
>>>> year           2010
>>>> month          04
>>>> day            22
>>>> svn rev        51801
>>>> language       R
>>>> version.string R version 2.11.0 (2010-04-22)
>>>> 
>>>> 
>>>> ________________________________________________________________________
>>>> The Numerical Algorithms Group Ltd is a company registered in England
>>>> and Wales with company number 1249803. The registered office is:
>>>> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
>>>> 
>>>> This e-mail has been scanned for all viruses by Star. Th...{{dropped:4}}
>>>> 
>>>> ______________________________________________
>>>> R-devel at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>> 
>>> ______________________________________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>> 
>>> 
>> 
> 
> 
> 



More information about the R-devel mailing list