Re: [Rd] Calling Rscript from Makevars
Thanks for the help! On 5/23/11 8:58 PM, Simon Urbanek simon.urba...@r-project.org wrote: Sean, On May 23, 2011, at 2:03 PM, Sean Robert McGuffee wrote: On 5/23/11 1:30 PM, Simon Urbanek simon.urba...@r-project.org wrote: On May 23, 2011, at 12:56 PM, Sean Robert McGuffee wrote: I'm not sure what you mean by, any tests you run in configure will ignore it since autoconf only uses LIBS and not PKG_LIBS. I though autoconf used any variable names you tell it to, so that it would use PKG_LIBS if you tell it to. No, many variables have a special meanings in autoconf, such as CC, CPP, CFLAGS, LIBS, LDFLAGS etc. When you run tests like AC_PROG*, AC_HEADER*, AC_CHECK_*, AC_COMPILE*, AC_LINK* then those use (and set) only the variables supported by configure and they have no idea about things like PKG_LIBS. So as far as autoconf is concerned PKG_LIBS has no effect. I'm not familiar with all of the AC_* commands, but I'm pretty sure that AC_SUBST(PKG_LIBS) will properly set the variable PKG_LIBS or any variable you like. You can run tests to set it how you like before you run AC_SUBST too. For example, if test [ -n $lmmin_include_path ] ; then LMMIN_INCLUDE_CXXFLAGS=-I${lmmin_include_path} else if test [ -n ${LMMIN_INCLUDE} ] ; then LMMIN_INCLUDE_CXXFLAGS=-I${LMMIN_INCLUDE} else LMMIN_INCLUDE_CXXFLAGS=-I/default fi fi AC_SUBST(LMMIN_INCLUDE_CXXFLAGS) Yes, but the above don't actually test anything - it just performs a shell substitution, you still have no idea if that actually works. The point of autoconf is to provide tests of functionality - that's what all the tests I mentioned are about. If you just wanted to replace a variable, you can use sed and skip all autoconf ;) - or in fact you can simply use Makevars since that gives you all shell functionality and you don't sacrifice the ability to support multiple architectures (see my previous comment why configure should be only used if absolutely necessary as it impedes the package build process). Good point--And now that I understand that Makevars is going to be included in a Makefile that R will generate, that makes perfect sense. Because R has its own building process, using autoconf with packages means you have to a) set autoconf's flags to match the R configuration before you do anything, b) use autoconf tests which implies using autoconf's flags, c) map resulting autoconf flags to special R package flags. If you skip any of a,b,c the result will not be reliable. In theory, you can handle R's flags and autoconf flags in parallel, i.e., updating both in the success branch of each test, but that's a bit too tedious to implement (you can't use the autoconf default actions) and unnecessary. Also, I'm still not clear as to what a Makevars file is. To clarify, I do understand a Makefile. When GNU's make program is run, it looks for a Makefile and interprets it in ways that are documented very well by GNU. I have yet to find any lead as to what a Makevars file is, what to put in it, what it does, or how it helps in installation with R packages. I can understand how to define variables in it, but the only way I know how to use variables that are defined is by using them in a Makefile. Where and how are variables defined in Makevars used? Makevars is simply a file included in R's Makefile when it is building the package. I think this if *EXTREMEMLY* useful information and should be appended to the beginning of Writing R Extensions: 1.2.1 Using Makevars. Thank you so much for sharing this crucial piece of information. Now it all makes sense. From R-admin: http://r.research.att.com/man/R-exts.html#Using-Makevars There are some macros which are set whilst configuring the building of R itself and are stored in R_HOME/etcR_ARCH/Makeconf. That makefile is included as a Makefile afterMakevars[.win], and the macros it defines can be used in macro assignments and make command lines in the latter. (this attempts makes clear that Makevars is a makefile included before Makeconf) Notice how the word Makevars is not in that quote... It tends to be difficult to clarify something about Makevars without using the word Makevars. and Note that Makevars should not normally contain targets, as it is included before the default makefile and make will call the first target, intended to be all in the default makefile. If you really need to circumvent that, use a suitable (phony) target all before any actual targets in Makevars.[win]: (this attempts to make clear that you can define targets in Makevars even if it's not customary) This makes sense now knowing that Makevars gets included in a Makefile that R generates. Cheers, Simon So, technically, it is a makefile. The difference between Makevars and Makefile is that Makevars doesn't need to specify any rules or variables that R already knows about, because they are already
Re: [Rd] Calling Rscript from Makevars
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.urba...@r-project.org] Sent: 20 May 2011 20:17 To: Martyn Byng Cc: r-devel@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 day22 svn rev51801 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@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}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Calling Rscript from Makevars
Hi Simon, I'm not sure what you mean by, any tests you run in configure will ignore it since autoconf only uses LIBS and not PKG_LIBS. I though autoconf used any variable names you tell it to, so that it would use PKG_LIBS if you tell it to. Also, I'm still not clear as to what a Makevars file is. To clarify, I do understand a Makefile. When GNU's make program is run, it looks for a Makefile and interprets it in ways that are documented very well by GNU. I have yet to find any lead as to what a Makevars file is, what to put in it, what it does, or how it helps in installation with R packages. I can understand how to define variables in it, but the only way I know how to use variables that are defined is by using them in a Makefile. Where and how are variables defined in Makevars used? Sean __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Calling Rscript from Makevars
On 5/23/11 1:30 PM, Simon Urbanek simon.urba...@r-project.org wrote: On May 23, 2011, at 12:56 PM, Sean Robert McGuffee wrote: I'm not sure what you mean by, any tests you run in configure will ignore it since autoconf only uses LIBS and not PKG_LIBS. I though autoconf used any variable names you tell it to, so that it would use PKG_LIBS if you tell it to. No, many variables have a special meanings in autoconf, such as CC, CPP, CFLAGS, LIBS, LDFLAGS etc. When you run tests like AC_PROG*, AC_HEADER*, AC_CHECK_*, AC_COMPILE*, AC_LINK* then those use (and set) only the variables supported by configure and they have no idea about things like PKG_LIBS. So as far as autoconf is concerned PKG_LIBS has no effect. I'm not familiar with all of the AC_* commands, but I'm pretty sure that AC_SUBST(PKG_LIBS) will properly set the variable PKG_LIBS or any variable you like. You can run tests to set it how you like before you run AC_SUBST too. For example, if test [ -n $lmmin_include_path ] ; then LMMIN_INCLUDE_CXXFLAGS=-I${lmmin_include_path} else if test [ -n ${LMMIN_INCLUDE} ] ; then LMMIN_INCLUDE_CXXFLAGS=-I${LMMIN_INCLUDE} else LMMIN_INCLUDE_CXXFLAGS=-I/default fi fi AC_SUBST(LMMIN_INCLUDE_CXXFLAGS) Because R has its own building process, using autoconf with packages means you have to a) set autoconf's flags to match the R configuration before you do anything, b) use autoconf tests which implies using autoconf's flags, c) map resulting autoconf flags to special R package flags. If you skip any of a,b,c the result will not be reliable. In theory, you can handle R's flags and autoconf flags in parallel, i.e., updating both in the success branch of each test, but that's a bit too tedious to implement (you can't use the autoconf default actions) and unnecessary. Also, I'm still not clear as to what a Makevars file is. To clarify, I do understand a Makefile. When GNU's make program is run, it looks for a Makefile and interprets it in ways that are documented very well by GNU. I have yet to find any lead as to what a Makevars file is, what to put in it, what it does, or how it helps in installation with R packages. I can understand how to define variables in it, but the only way I know how to use variables that are defined is by using them in a Makefile. Where and how are variables defined in Makevars used? Makevars is simply a file included in R's Makefile when it is building the package. I think this if *EXTREMEMLY* useful information and should be appended to the beginning of Writing R Extensions: 1.2.1 Using Makevars. Thank you so much for sharing this crucial piece of information. Now it all makes sense. So, technically, it is a makefile. The difference between Makevars and Makefile is that Makevars doesn't need to specify any rules or variables that R already knows about, because they are already included by R. So it is much more convenient since it saves you a lot of trouble trying to setup the correct rules for compilation, linking etc. At the same time, it is a makefile so you can add targets, modify dependencies etc., you're not constrained to just setting variables although that is its primary use. In practice Makevars can be used in several ways: a) just set PKG_CFLAGS, PKG_LIBS this is the most common use and it leaves the standard targets in place so R will use those to compile $(SHLIB) automatically b) include additional targets: if you have additional features to build, you can specify them in a target, for example this is form rJava: all: $(SHLIB) @WANT_JRI_TRUE@ jri jri: ... It builds the standard $(SHLIB) which is loaded by the package, but it also builds a separate target jri if enabled in configure c) include dependencies: you can add dependent builds that are needed for your $(SHLIB), for example from RSQLite: all: $(SHLIB) $(SHLIB): do_includes do_includes: This makes sure that do_includes is built before R attempts to build the .so/.dll So, as you can see you Makevars gives you the flexibility of Makefile but without the hassle. Cheers, Simon __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Calling Rscript from Makevars
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 day22 svn rev51801 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] 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.b...@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 day22 svn rev51801 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
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 day22 svn rev51801 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Calling Rscript from Makevars
This is unrelated to the original question, so clarifications inline for posterity. On May 20, 2011, at 3:15 PM, Sean Robert McGuffee wrote: 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. Martyn was asking about dynamic variables in Makevars which is less intrusive than having a configure script. In general, I recommend using the configure script only as the ultima ratio if there is no easy way to achieve the same effect with Makevars, because configure prevents the package from building all architectures. 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: 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 ;). 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. 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. 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.b...@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
Re: [Rd] Calling Rscript from Makevars
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@ 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. 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.b...@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 day22 svn rev51801
Re: [Rd] Calling Rscript from Makevars
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). I'm not clear on what to put in Makevars. For example, in my Makefile.in, I have various header/include variables and various library variables for compiling and linking different libraries that could be in random locations on different platforms. In the Makefile.in, I put these variables in the correct locations for compilation and linking. I assume I can just change AC_CONFIG_FILES([src/Makefile]) to AC_CONFIG_FILES([src/Makevars]) in autoconf.ac to get Makevars made from a Makevars.in file. However, what I can't figure out is what my goal is to put in a Makevars file. I've never seen any explanation of what Makevars files do to accomplish all of the complexity of a Makefile. Does R use PKG_LIBS in all compilation and linking steps or something? If so, then I guess I would just have to set it equal to all of the other variables inside configure. I haven't explicitly found that written somewhere, but I'm starting to wonder if that's what it does. Anyway, if you could connect that dot for me, I'd appreciate it. Thanks, Sean Cheers, Simon __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Calling Rscript from Makevars
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.b...@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