# libdeflate 1.19 (2023-09-16)
# ===============
# Get the source tarball
cd
test -f installed/libdeflate-1.19.tar.gz &&
mv -f installed/libdeflate-1.19.tar.gz .
test ! -f libdeflate-1.19.tar.gz &&
wget https://github.com/ebiggers/libdeflate/releases/download/\
v1.19/libdeflate-1.19.tar.gz
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "libdeflate-*" -exec rm -r {} \;
tar xzvf ~/libdeflate-1.19.tar.gz
cd libdeflate-1.19
test $UID = 0 && chown -R root:root .
# Create a build directory (or just use -B build)
mkdir build
cd build
# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_INSTALL_LIBDIR=/usr/local/lib64 \
-DLIBDEFLATE_BUILD_STATIC_LIB=OFF ..
# Configure the build for anything else
test $(uname -m) != 'x86_64' &&
cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_INSTALL_LIBDIR=/usr/local/lib64 \
-DLIBDEFLATE_BUILD_STATIC_LIB=OFF ..
# Build it
make
# Become root to install it
su
# Install it
make install
ldconfig
# Become your non-root user again
exit
# Save the tarball for later
cd
mkdir -p -m 0700 installed
rm -f installed/libdeflate-*.tar.*
mv -f libdeflate-1.19.tar.gz installed/
# If you ever want to uninstall libdeflate, this should do it:
cd
su
test -d src/libdeflate-* && ( cd src/libdeflate-* ; make uninstall )
( cd /usr/local/bin
rm -f libdeflate-gunzip libdeflate-gzip )
( cd /usr/local/lib
rm -f libdeflate.so.0 libdeflate.so pkgconfig/libdeflate.pc
test -d cmake/libdeflate && rm -r cmake/libdeflate )
test -d /usr/local/lib64 &&
( cd /usr/local/lib64
rm -f libdeflate.so.0 libdeflate.so pkgconfig/libdeflate.pc
test -d cmake/libdeflate && rm -r cmake/libdeflate )
rm -f /usr/local/include/libdeflate.h
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "libdeflate-*" -exec rm -r {} \;
rm -f ~/installed/libdeflate-*.tar.*