[R-pkg-devel] set PKG_CONFIG_PATH before installing a package

Dirk Eddelbuettel edd @end|ng |rom deb|@n@org
Mon Apr 8 21:14:24 CEST 2019

On 8 April 2019 at 10:59, Travers Ching wrote:
| I think the correct way to do it is through the configure script.  See
| for example the Cairo package that uses pkg-config.  Configure scripts
| are slightly hard to work through in my experience, but are worth it
| if you need  customization of the installation environment.

Or from the RcppRedis package you and I stand behind :)


## ... but check for pkg-config

## use pkg-config for hiredis
if test x"${PKGCONFIG}" == x"yes"; then
    ## check via pkg-config for hiredis
    if pkg-config --exists hiredis; then
        ## obtain cflags and obtain libs
        hiredis_cxxflags=`pkg-config --cflags hiredis`
        hiredis_libs=`pkg-config --libs hiredis`
        ## no need to build libhiredis.a
        AC_MSG_WARN([pkg-config exists but hiredis is not available.])

## And make sure these flags are used for the tests below.
CPPFLAGS="${hiredis_cxxflags} ${CPPFLAGS}"
CXXFLAGS="${hiredis_cxxflags} ${CXXFLAGS}"


There is more at
but is a key part.

Another useful trick is to just write a shell script 'configure' as one does
not have to use 'autoconf' to produce 'configure' see eg
for that approach, or one of Jeroen's packages.

Last but not least you can call 'pkg-config' directly from src/Makevars too.


http://dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org

More information about the R-package-devel mailing list