I have been RTFM/doc/www, but I'm still lost. How does one tell R CMD INSTALL and R CMD check (both) that libraries are installed in non-usual places and so -I/APPS/include (or whatever) is necessary in CPPFLAGS and -L/APPS/lib (similarly) is necessary in LDFLAGS? I know I can hardwire them in pkg/src/Makevars, but this requires hand editing of that file by each installer (yuck!) rgentlem suggested some tricks with configure, but after a lot of grovelling in autoconf manuals and books, I still don't get it. Surely this is a pre-solved problem (I hopefully assert). Is there a standard solution, and if so where is the example I follow? -- Charles Geyer Professor, School of Statistics University of Minnesota charlie at stat.umn.edu
On 20 February 2005 at 11:12, Charles Geyer wrote: | I have been RTFM/doc/www, but I'm still lost. | | How does one tell R CMD INSTALL and R CMD check (both) that libraries | are installed in non-usual places and so -I/APPS/include (or whatever) | is necessary in CPPFLAGS and -L/APPS/lib (similarly) is necessary | in LDFLAGS? | | I know I can hardwire them in pkg/src/Makevars, but this requires hand | editing of that file by each installer (yuck!) | | rgentlem suggested some tricks with configure, but after a lot of grovelling | in autoconf manuals and books, I still don't get it. | | Surely this is a pre-solved problem (I hopefully assert). Is there a standard | solution, and if so where is the example I follow? FWIW, I have followed other packages when I crafted this for RQuantLib. i) src/Makevars.in is a stanza that gets filled by Autoconf: edd at chibud:~/src/debian/QuantLib/RQuantLib-0.1.11> cat src/Makevars.in PKG_CXXFLAGS=@pkg_cxxflags@ PKG_LIBS=@pkg_libs@ ii) The actual work is done by configure at package built time. That is the single best method. You can snoop tricks from dozens of CRAN packages that do the same: I crafted a reasonably short file: edd at chibud:~/src/debian/QuantLib/RQuantLib-0.1.11> wc -l configure.in 149 configure.in that tests for both QuantLib and Boost headers and libraries. Personally, I find going by working example the easiest, with the documentation (for autoconf) at my side. That said, I also benefited from tips by Kurt who wears a black belt in autoconf magic. edd at chibud:~/src/debian/QuantLib/RQuantLib-0.1.11> head -8 configure.in # RQuantLib configure.in by Dirk Eddelbuettel <edd at debian.org> # Borrowed pieces from RPgSQL, GNU Gretl, GNU R and QuantLib # # Greatly simplified thanks to quantlib-config # Another contribution by Kurt Hornik gratefully acknowledged # # $Id: configure.in,v 1.1 2004/12/22 04:07:57 edd Exp $ The fact that this credits RPgSQL is probably a reflection of the point in time when I first wrote this several years ago -- CRAN was considerably smaller at the time. Hope this helps. Dirk -- Better to have an approximate answer to the right question than a precise answer to the wrong question. -- John Tukey as quoted by John Chambers
[This is getting rather technical, so moved to R-devel.] On Sun, 20 Feb 2005, Charles Geyer wrote:> I have been RTFM/doc/www, but I'm still lost. > > How does one tell R CMD INSTALL and R CMD check (both) that libraries > are installed in non-usual places and so -I/APPS/include (or whatever) > is necessary in CPPFLAGS and -L/APPS/lib (similarly) is necessary > in LDFLAGS? > > I know I can hardwire them in pkg/src/Makevars, but this requires hand > editing of that file by each installer (yuck!) > > rgentlem suggested some tricks with configure, but after a lot of grovelling > in autoconf manuals and books, I still don't get it. > > Surely this is a pre-solved problem (I hopefully assert). Is there a standard > solution, and if so where is the example I follow?Configure helps if there is a well-known and exhaustive set of possible locations. Otherwise src/Makevars saying PKG_CPPFLAGS = -I$(FOO_INCLUDE) PKG_LIBS = -L$(FOO_LDPATH) and instructions to the user to set the environment variables FOO_INCLUDE amd FOO_LDPATH is a good compromise (except perhaps for the auto-builders and auto-testers at CRAN). I looked at the examples on CRAN, and failed to find one that allowed users to specify the paths flexibly. RQuantian mentioned by Dirk does allow the Boost paths to be set, but not the quantlib-config path (at least it is not mentioned in RQuantian/configure --help), and it appears not be make use of the Boost paths that can be set. (Dirk: surely they need to be appended to pkg_cxxflags and pkg_libs?) Here is a working example planned for RODBC: src/Makevars.in: PKG_CPPFLAGS=@CPPFLAGS@ PKG_LIBS=@LIBS@ configure.ac: AC_INIT(DESCRIPTION) AC_ARG_WITH([odbc-include], AC_HELP_STRING([--with-odbc-include=INCLUDE_PATH], [the location of ODBC header files]), [odbc_include_path=$withval]) if test [ -n "$odbc_include_path" ] ; then AC_SUBST([CPPFLAGS],["-I${odbc_include_path} ${CPPFLAGS}"]) else if test [ -n "${ODBC_INCLUDE}" ] ; then AC_SUBST([CPPFLAGS],["-I${ODBC_INCLUDE} ${CPPFLAGS}"]) fi fi AC_ARG_WITH([odbc-lib], AC_HELP_STRING([--with-odbc-lib=LIB_PATH], [the location of ODBC libraries]), [odbc_lib_path=$withval]) if test [ -n "$odbc_lib_path" ] ; then AC_SUBST([LIBS],[" -L${odbc_lib_path} ${LIBS}"]) else if test [ -n "${ODBC_LIB}" ] ; then AC_SUBST([LIBS],["-I${ODBC_LIB} ${LIBS}"]) fi fi AC_SEARCH_LIBS(SQLTables, odbc odbc32 iodbc,, AC_MSG_ERROR("no ODBC driver manager found")) AC_SUBST(CPPFLAGS) AC_SUBST(LIBS) AC_OUTPUT(src/Makevars) Then just running 'autoconf' in the top directory makes configure, and configure --help lists the options. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595