Install everything with one script, and use it in the CI

scripts/install.sh runs the whole installation: the packages of the
distribution, rocksdb where there is none or none with the static
library, collocatordb, and dereko2vec with the fast static link, tested
and installed below /usr/local. Options: --shared, --skip-deps,
--skip-tests, --static-binary, --prefix, --rocksdb-prefix,
--rocksdb-version, -j.

The GitHub workflow (Ubuntu, MacOS) and the GitLab CI (Debian, with the
completely static binary as the artifact) now call it instead of
repeating the steps.

build-rocksdb.sh passes the homebrew prefix to cmake on MacOS, so that
the compression libraries are found.

Change-Id: Idbe7d7e598001d91aef8aaba045ac1ace61bf92a
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5ea23b7..f77d7e4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -32,33 +32,18 @@
     - start_section install_linux_packages "Installing missing Linux packages"
     - mkdir -pv $APT_CACHE_DIR ccache
     - apt-get update && apt-get -o dir::cache::archives="$APT_CACHE_DIR" -y install ccache cmake librocksdb-dev libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev libomp-dev
-    # ccache only makes the build faster, it must never be able to make it fail,
-    # so everything that uses it is guarded and CCACHE_OPTS stays empty without it
-    - if CCACHE=$(command -v ccache); then ln -sf "$CCACHE" /usr/local/sbin/gcc && ln -sf "$CCACHE" /usr/local/sbin/g++ && CCACHE_OPTS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"; else echo "ccache is not available - building without it"; CCACHE_OPTS=""; fi
+    # ccache only makes the build faster, it must never be able to make it
+    # fail, so it is wired in through compiler symlinks only when it is there
+    - if CCACHE=$(command -v ccache); then ln -sf "$CCACHE" /usr/local/sbin/gcc && ln -sf "$CCACHE" /usr/local/sbin/g++; else echo "ccache is not available - building without it"; fi
     - end_section install_linux_packages
 
-    - start_section install_collocatordb "Building and installing collocatordb"
-    - git clone "https://korap.ids-mannheim.de/gerrit/ids-kl/collocatordb"
-    - cd collocatordb
-    - mkdir -p build
-    - cd build
-    - cmake $CCACHE_OPTS ..
-    - make
-    - command -v ccache > /dev/null && ccache --show-stats || true
-    - make install # && ctest --extra-verbose
-    - ldconfig
-    - end_section install_collocatordb
-    - cd ../..
-
   script:
+    # Debian ships the static rocksdb in librocksdb-dev, so install.sh builds
+    # no rocksdb here. --static-binary keeps the artifact a completely static
+    # binary. ccache works through the compiler symlinks set up above.
     - start_section build_dereko2vec "Building and testing dereko2vec"
-    - pwd
-    - mkdir build
-    - cd build
-    - cmake -DSTATIC_DEREKO2VEC=ON $CCACHE_OPTS ..
-    - make || (cmake $CCACHE_OPTS .. && make)
+    - scripts/install.sh --skip-deps --static-binary
     - command -v ccache > /dev/null && ccache --show-stats || true
-    - ctest --extra-verbose
     - end_section build_dereko2vec
 
   artifacts: