[R-pkg-devel] How to retrieve a flag set in configure.ac (filled in Makevars.in) during package installation in an R or C++ script ?

Akshit Achara @ch@r@@k@h|t @end|ng |rom gm@||@com
Sat Aug 15 16:20:41 CEST 2020


Hi everyone,

Background:

The package rminizinc <https://github.com/acharaakshit/RMiniZinc> provides
an interface to MiniZinc
<https://www.minizinc.org/tutorial/minizinc-tute.pdf> in R. The package
provides various functionalities to parse, solve and manipulate MiniZinc
models. This is done by using the MiniZinc C++ API (libminizinc
<https://github.com/MiniZinc/libminizinc>).

The installation requires linking of the library an including the header
files for which PKG_LIBS flag(-L/path/to/libminizinc -lmzn) , and
PKG_CPPFLAGS (-I/path/to/libminizinc/include) are filled in Makevars.in
which is set by configure based on the path of the library provided by the
user using --configure-args or if the user doesn't provide any arguments, a
default path is passed from configure (using configure.ac).

Question:

In one of my Rcpp functions mzn_parse() which is used to parse MiniZinc
models, I sometimes need to use the files in the subdirectories of the
libminizinc library. To access these files, I need to use the path of
libminizinc (which can change per installation). I want to extract this
path from either Makevars or configure to use it in my package. Is there
any way I could retrieve this path in my scripts?

Please let me know if this question is not relevant to the mailing list.

The Makevars.in looks like this:

CXX_STD = CXX11
PKG_CPPFLAGS = -I. @MZN_INCLUDE@
PKG_LIBS = @MZN_LIBS@
OBJECTS.tests = cpp_tests/test-runner.o cpp_tests/test-mzn_parse.o
cpp_tests/test-
set_params.o cpp_tests/test-mzn_eval.o cpp_tests/test-sol_parse.o
cpp_tests/test-
getMissingPars.o
OBJECTS.sources = RcppExports.o set_params.o mzn_parse.o mzn_eval.o sol_parse.o
getMissingPars.o
OBJECTS.helpers = filetoString.o helper_parse.o expDetails.o pathStringcheck.o
OBJECTS = $(OBJECTS.sources) $(OBJECTS.tests) $(OBJECTS.helpers)
$(SOURCES:.cpp=.o)
strippedLib: $(SHLIB)
    if test -e "/usr/bin/strip"; then /usr/bin/strip --strip-debug
$(SHLIB); fi.phony: strippedLib
all: clean
clean:
    rm -f $(OBJECTS.sources) $(OBJECTS.tests) $(OBJECTS.helpers)  *.so

Thanks!

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list