# You can just clone 'master' too, but here we get a tarball of the
# LMDB_0.9.31 tag from the read-only GitHub mirror
#
# The master branch in openldap.org GitLab is here:
# https://git.openldap.org/openldap/openldap/-/tree/master/libraries/liblmdb
#
# The list of tags in GitHub is here:
# https://github.com/LMDB/lmdb/tags
# Get the source
cd
test -f installed/LMDB_0.9.31.tar.gz &&
mv -f installed/LMDB_0.9.31.tar.gz .
test ! -f LMDB_0.9.31.tar.gz &&
wget https://github.com/LMDB/lmdb/archive/refs/tags/LMDB_0.9.31.tar.gz
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "lmdb-LMDB_*" -exec rm -r {} \;
find -maxdepth 1 -type d -name "lmdb-LMDB_*" -exec rm -r {} \;
tar xzvf ~/LMDB_0.9.31.tar.gz
cd lmdb-LMDB_0.9.31
test $UID = 0 && chown -R root:root .
cd libraries/liblmdb
# Build it
make
# Test the build
make test
# Become root to install it
su
# Remove the Slackware package if there is one
test -x /sbin/removepkg && /sbin/removepkg lmdb
# Install it for 64-bit paths
test $(uname -m) = 'x86_64' &&
make install prefix=/usr libdir=/usr/lib64 mandir=/usr/man
# Install it for anything else
test $(uname -m) = 'x86_64' &&
make install prefix=/usr mandir=/usr/man
# Update ld.so.cache
ldconfig
# If you don't want the static library (only shared)
rm -f /usr/lib*/liblmdb.a
# Make sure your non-root user can remove the source later
cd ../..
chown -R $(logname) .
chmod -R u+w .
# Become yourself again
exit
# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/LMDB_*.tar.*
mv -f LMDB_0.9.31.tar.gz installed/
# If you ever want to uninstall LMDB, this should do it:
cd
su
( cd /usr/bin
rm -f mdb_copy mdb_dump mdb_load mdb_stat )
( cd /usr/man/man1
rm -f mdb_copy.1 mdb_dump.1 mdb_load.1 mdb_stat.1 )
rm -f /usr/include/lmdb.h /usr/lib*/liblmdb.*
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "lmdb-LMDB_*" -exec rm -r {} \;
rm -f ~/installed/LMDB_*.tar.*