Make the installation easier, with a script that builds rocksdb

scripts/build-rocksdb.sh builds rocksdb once, with the shared and the
static library, into a prefix of its own. It builds the version of the
rocksdb package of the distribution where there is one, so that the
static library matches what collocatordb is compiled against, and a
pinned one where there is none (Rocky Linux, RHEL). Older rocksdb
versions are made to compile with newer compilers, e.g. Fedora's 10.2.1
with gcc 16.

-DSTATIC_ROCKSDB=ON links rocksdb and collocatordb statically, which
makes counting collocations about 22% faster, without naming the two
libraries by their paths.

The installation section of the README is rewritten as four steps that
cover Fedora, Rocky Linux 9 and 10, RHEL and MacOS.

Change-Id: Idbb588ad517c626fc387973b676126480edb6c2e
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f391940..8abe345 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,7 @@
 cmake_minimum_required(VERSION 3.9)
 project(dereko2vec VERSION 0.9.1 DESCRIPTION "Fork from wang2vec with extensions for re-training and count based models")
 option(STATIC_DEREKO2VEC "Build dereko2vec as a static binary" OFF)
+option(STATIC_ROCKSDB "Link rocksdb and collocatordb statically, everything else shared" OFF)
 if (STATIC_DEREKO2VEC AND APPLE)
     message(FATAL_ERROR "STATIC_DEREKO2VEC does not work on MacOS, which ships "
             "no static system libraries. Build without it.")
@@ -31,12 +32,14 @@
 include_directories(/usr/local/include /usr/local/kl/include /opt/homebrew/include)
 link_directories(/usr/local/kl/lib /usr/local/lib /usr/local/lib64 /opt/homebrew/lib)
 
-# A static dereko2vec needs everything as a static library. An ordinary build
-# takes the shared ones, and it has to take them explicitly: a leftover static
-# library below /usr/local would otherwise win over the shared library of the
-# distribution, because cmake weighs the search path higher than the suffix.
-# Set -DCOLLOCATORDB=<path> or -DROCKSDB=<path> to pick specific ones.
-if (STATIC_DEREKO2VEC)
+# A static dereko2vec needs everything as a static library. With STATIC_ROCKSDB
+# only rocksdb and collocatordb are static and the compression libraries stay
+# shared, which is the fast indexing build the README describes. An ordinary
+# build takes the shared ones, and it has to take them explicitly: a leftover
+# static library below /usr/local would otherwise win over the shared library
+# of the distribution, because cmake weighs the search path higher than the
+# suffix. Set -DCOLLOCATORDB=<path> or -DROCKSDB=<path> to pick specific ones.
+if (STATIC_DEREKO2VEC OR STATIC_ROCKSDB)
     find_library(COLLOCATORDB libcollocatordb_static.a)
     find_library(ROCKSDB librocksdb.a)
 else ()
@@ -50,16 +53,17 @@
 if (NOT COLLOCATORDB)
     message(FATAL_ERROR "No collocatordb found. Please install it from "
             "https://korap.ids-mannheim.de/gerrit/plugins/gitiles/ids-kl/collocatordb"
-            " - a static dereko2vec needs libcollocatordb_static.a, otherwise "
+            " - a static build needs libcollocatordb_static.a, otherwise "
             "libcollocatordb.so is enough.")
 endif ()
 if (NOT ROCKSDB)
     message(FATAL_ERROR "No rocksdb found. Install the rocksdb development "
             "package of your distribution, e.g. librocksdb-dev or "
-            "rocksdb-devel. Where there is none, or where it is older than the "
-            "one collocatordb was built against, build rocksdb and say where "
-            "it is: -DCMAKE_PREFIX_PATH=<prefix it was installed to>. It has "
-            "to be the same rocksdb that collocatordb was built against.")
+            "rocksdb-devel. Where there is none, or where a static one is "
+            "needed, scripts/build-rocksdb.sh builds one into a prefix of its "
+            "own; then say where it is: -DCMAKE_PREFIX_PATH=<prefix>. It has "
+            "to be the same rocksdb that collocatordb was built against, "
+            "which the script takes care of on its own.")
 endif ()
 message(STATUS "Using collocatordb ${COLLOCATORDB}")
 message(STATUS "Using RocksDB ${ROCKSDB}")