From 7ef191f4bebecdc375e9e0dfd625b585a019aef2 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Wed, 25 Oct 2017 06:03:29 -0700 Subject: [PATCH] [build] honour `OPAMROOT` Reviewed By: jberdine Differential Revision: D6136780 fbshipit-source-id: 4b26a36 --- Makefile.autoconf.in | 2 ++ configure.ac | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile.autoconf.in b/Makefile.autoconf.in index 8d4c48f4e..8d03cd510 100644 --- a/Makefile.autoconf.in +++ b/Makefile.autoconf.in @@ -60,6 +60,7 @@ OCAMLFIND = @OCAMLFIND@ OCAMLLEX = @OCAMLLEX@ OCAMLOPT = @OCAMLOPT@ OPAM = @OPAM@ +OPAMROOT = @OPAMROOT@ OPAMSWITCH = @OPAMSWITCH@ PATH = @PATH@ prefix = @prefix@ @@ -80,3 +81,4 @@ endif # Export parts of the config relevant to running other programs export PATH := $(PATH) export CAML_LD_LIBRARY_PATH := $(CAML_LD_LIBRARY_PATH) +export OPAMROOT := $(OPAMROOT) diff --git a/configure.ac b/configure.ac index 0274cefdf..c81da13f7 100644 --- a/configure.ac +++ b/configure.ac @@ -201,14 +201,22 @@ AC_ASSERT_OCAML_PKG([yojson]) AC_ARG_VAR([CAML_LD_LIBRARY_PATH], [Additional directories to search for dynamically-loaded libraries.]) - +AC_ARG_VAR([OPAMROOT], [Root of the local opam installation.]) +AC_ARG_VAR([OPAMSWITCH], [Opam switch used for building infer.]) AC_CHECK_TOOL([OPAM], [opam], [no]) AS_IF([test "$OPAM" != "no"], [ + AC_MSG_CHECKING([current opam root]) + OPAMROOT=$("$OPAM" config var root) + AC_MSG_RESULT([$OPAMROOT]) AC_MSG_CHECKING([current opam switch]) OPAMSWITCH=$("$OPAM" switch show) AC_MSG_RESULT([$OPAMSWITCH]) -], [OPAMSWITCH=no]) +], [ + OPAMROOT=no + OPAMSWITCH=no +]) +AC_SUBST([OPAMROOT]) AC_SUBST([OPAMSWITCH]) if test "x$enable_java_analyzers" = "xyes"; then