From 03ccd9d5f3c8794cc8c426a951111402e3569d9e Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 15 Dec 2015 14:28:13 -0800 Subject: [PATCH] better instructions for first-time users Summary: public The instructions to install opam from the web on linux were not enough: you need to install opam somewhere on the PATH. Moreover, the wget command could erase "opam" if launched from the infer repo, which already has an "opam" file. ./build-infer.sh's "opam init" command would fail if ocaml was not already installed, instead of installing a default compiler. Finally, check that ocamlfind is installed using the same logic as other ocamlfind packages, to get an error message explaining how to get it using opam if it's not installed, instead of just a failure. Reviewed By: jeremydubreil Differential Revision: D2760678 fb-gh-sync-id: 678178e --- INSTALL.md | 10 ++++++++-- build-infer.sh | 12 ++++++++---- configure.ac | 1 - m4/ac_assert_ocaml_pkg.m4 | 21 +++++++++++++++++++-- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index e01d013dd..e3c00955f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -106,6 +106,8 @@ compile Infer on a few Linux distributions. sudo apt-get update sudo apt-get upgrade sudo apt-get install -y \ + autoconf \ + automake \ build-essential \ git \ libgmp-dev \ @@ -125,6 +127,8 @@ sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get upgrade sudo apt-get install -y \ + autoconf \ + automake \ build-essential \ g++-4.8 \ gcc-4.8 \ @@ -148,8 +152,10 @@ Unfortunately, the version of opam that ships with some Linux distributions is broken, so you'll have to get it from the web: ```sh -wget -O opam https://github.com/ocaml/opam/releases/download/1.2.2/opam-1.2.2-x86_64-Linux -chmod +x opam +wget https://github.com/ocaml/opam/releases/download/1.2.2/opam-1.2.2-x86_64-Linux +chmod +x opam-1.2.2-x86_64-Linux +sudo cp opam-1.2.2-x86_64-Linux /usr/local/bin/opam +opam init --comp=4.02.3 ``` Alternatively, follow the instructions [from the opam diff --git a/build-infer.sh b/build-infer.sh index 28dc6353c..557f51e76 100755 --- a/build-infer.sh +++ b/build-infer.sh @@ -96,15 +96,19 @@ check_installed () { echo "initializing opam... " check_installed opam -# opam is noisy -opam init --no-setup --yes > /dev/null +# if the first command doesn't succeed it means that ocaml is not even +# installed on the system, so we have to pick a compiler version ourselves +# +# opam is noisy, so we silence the first invocation which typically would be a +# no-op +opam init --no-setup --yes > /dev/null || \ + opam init --no-setup --yes --comp=4.02.3 + eval $(opam config env) echo "preparing build... " if [ ! -f .release ]; then ./autogen.sh > /dev/null -elif [ ! -d .git ] && [ ! -f .release ]; then - git submodule update --init --recursive fi TARGETS="" diff --git a/configure.ac b/configure.ac index f2c104659..524df9a67 100644 --- a/configure.ac +++ b/configure.ac @@ -149,7 +149,6 @@ AC_ASSERT_PROG([ocamlc], [$OCAMLC]) AC_ASSERT_PROG([ocamlopt], [$OCAMLOPT]) AC_ASSERT_PROG([ocamlbuild], [$OCAMLBUILD]) AC_PROG_FINDLIB -AC_ASSERT_PROG([ocamlfind], [$OCAMLFIND]) AC_PROG_OCAMLLEX AC_ASSERT_PROG([ocamllex], [$OCAMLLEX]) AC_PROG_OCAMLYACC diff --git a/m4/ac_assert_ocaml_pkg.m4 b/m4/ac_assert_ocaml_pkg.m4 index d4c8fa9c9..4450e7ee3 100644 --- a/m4/ac_assert_ocaml_pkg.m4 +++ b/m4/ac_assert_ocaml_pkg.m4 @@ -9,16 +9,33 @@ dnl AC_ASSERT_OCAML_PKG([pkg_name], [pkg_version]) dnl dnl fails if $pkg_name is not installed; also fails if it is not dnl installed at version $pkg_version if specified +dnl +dnl assumes that AC_PROG_FINDLIB has been called AC_DEFUN([AC_ASSERT_OCAML_PKG], [dnl AC_CHECK_OCAML_PKG_PATH([$1], [$2], [$3]) unset has_pkg unset pkg + unset version - has_pkg=$AS_TR_SH[OCAML_PKG_$1] + AS_IF([test "$OCAMLFIND" = "no"], [dnl + # trick to detect if ocamlfind is correctly installed and give the + # right opam instructions to install it if not since they're the + # same as when any other opam package is missing. + has_pkg=no + pkg=ocamlfind + version= + ], [dnl + has_pkg=$AS_TR_SH[OCAML_PKG_$1] + pkg=$1 + version= + AS_IF([test "x$3" = "x"], [dnl + version=" version $3" + ]) + ]) AS_IF([test "$has_pkg" = "no"], [dnl - AC_MSG_ERROR([missing dependency: $1$version. + AC_MSG_ERROR([missing dependency: $pkg$version. If you are using opam, please run