R package development - How to handle C library linking errors on package install

Viewed 26

Situation:

The R package I am developing exports a C function through R's .C.

The code in src/ where the function is defined compiles fine if libtiff is installed in the OS.

I'd like this functionality to be optional; just as there are "suggested" R packages, because it is not essential.

The problem

I found no way to tell R that a C function compilation is "suggested". Neither could I find a way to make compilation of code in src/ optional, or conditional to the presence of libtiff in the OS in some way.

My current Makevars says:

CC=ccache clang -Qunused-arguments
CXX=ccache clang++ -Qunused-arguments
CCACHE_CPP2=yes    
PKG_LIBS = -ltiff

I have been searching for a solution all day, without success.

I've only just figured out how to use Makevars to look for libtiff:

TIFFSTATUS := $(shell $(LD) -ltiff; echo 0 || echo 1)
ifeq ($(TIFFSTATUS), 1)
... stuff?

The question

How can I properly tell R that a function using .C is optional (ie conditional to the availability of the libtiff dependencies).

Thanks.

0 Answers
Related