From Martyn.Byng at nag.co.uk  Mon May 23 13:55:43 2011
From: Martyn.Byng at nag.co.uk (Martyn Byng)
Date: Mon, 23 May 2011 12:55:43 +0100
Subject: [Rd] Calling Rscript from Makevars
References: <49E76DF37649DC48A4CE882BC8CE51C901AD8398@nagmail2.nag.co.uk>
	<86F6F0A1-391C-4481-B0BA-5681CC4CA148@r-project.org>
Message-ID: <49E76DF37649DC48A4CE882BC8CE51C901AD84B4@nagmail2.nag.co.uk>

Hi,

Thanks for the help. 

Putting the call to Rscript directly in the definition of PKG_LIBS
rather than in a different makefile variable and using that variable
when defining PKG_LIBS did indeed fix my problem.

Martyn
-----Original Message-----
From: Simon Urbanek [mailto:simon.urbanek at r-project.org] 
Sent: 20 May 2011 20:17
To: Martyn Byng
Cc: r-devel at r-project.org
Subject: Re: [Rd] Calling Rscript from Makevars


On May 20, 2011, at 12:04 PM, Martyn Byng 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)')
> 

That's all pretty much unnecessary since all settings carry over from
the R invocation and also it is what causes your error (since your
"arch" is wrong). On unix it's as simple as

PKG_LIBS=`${R_HOME}/bin/Rscript -e 'whatever.you.meant.to.run()'`

and on Windows it's

PKG_LIBS=`${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe -e
'whatever.you.meant.to.run()'`

Note that you should NOT mess with the environment variables that R uses
as you're likely to set them incorrectly.

Cheers,
Simon



> 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
> 
> 


________________________________________________________________________
This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}



[Rd] Calling Rscript from Makevars
Martyn Byng