[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 ?
Ivan Krylov
kry|ov@r00t @end|ng |rom gm@||@com
Mon Aug 17 16:50:31 CEST 2020
On Sat, 15 Aug 2020 19:50:41 +0530
Akshit Achara <acharaakshit using gmail.com> wrote:
> 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.
Just as Makevars is generated during ./configure run from Makefile.in,
you could generate a config.h from a config.h.in and substitute all the
necessary #defines in it. This is how GNU autoconf is typically used in
stand-alone programs [*].
A simpler option would be to add an equivalent of
-DMZN_PATH='"@MZN_PATH"' to PKG_CPPFLAGS in Makevars.in and make sure
that AC_SUBST is called for that variable in configure.ac [**]. Then
the C or C++ code would be able to use MZN_PATH as if it was #defined
in a header file.
--
Best regards,
Ivan
[*]
https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Configuration-Headers.html
[**]
https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Makefile-Substitutions.html
More information about the R-package-devel
mailing list