# Get the source
cd
test -f installed/lz4-1.9.3.tar.gz && mv -f installed/lz4-1.9.3.tar.gz .
test ! -f lz4-1.9.3.tar.gz &&
wget https://github.com/lz4/lz4/archive/refs/tags/v1.9.3.tar.gz \
-O lz4-1.9.3.tar.gz
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -name "lz4-*" -exec rm -r {} \;
tar xzvf ~/lz4-1.9.3.tar.gz
cd lz4-1.9.3
test $UID = 0 && chown -R root:root .
# Build it, specifying paths so liblz4.pc is accurate, 64-bit
test $(uname -m) = 'x86_64' &&
PREFIX=/usr LIBDIR=/usr/lib64 MANDIR=/usr/man/man1 make
# Build it, specifying paths so liblz4.pc is accurate, anything else
test $(uname -m) != 'x86_64' &&
PREFIX=/usr MANDIR=/usr/man/man1 make
# Become root to install it
su
# Install it for 64-bit
test $(uname -m) = 'x86_64' &&
PREFIX=/usr LIBDIR=/usr/lib64 MANDIR=/usr/man/man1 make install
# Install it for anything else
test $(uname -m) != 'x86_64' &&
PREFIX=/usr MANDIR=/usr/man/man1 make install
# Become your non-root user again
exit
# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/lz4-*.tar.gz
mv -f lz4-1.9.3.tar.gz installed/
# If you ever want to uninstall LZ4, this should do it
# 'make uninstall' as root in the source directory should do it
# The rest is in case old version files are leftover
cd
su
test -d src/lz4-* &&
( cd src/lz4-*
test $(uname -m) = 'x86_64' &&
PREFIX=/usr LIBDIR=/usr/lib64 MANDIR=/usr/man/man1 make uninstall
test $(uname -m) != 'x86_64' &&
PREFIX=/usr MANDIR=/usr/man/man1 make uninstall )
( cd /usr/bin
rm -f lz4 lz4c lz4cat unlz4 )
( cd /usr/include
rm -f lz4.h lz4frame.h lz4frame_static.h lz4hc.h )
( cd /usr/lib
rm -f liblz4.* pkgconfig/liblz4.pc )
( cd /usr/lib64
rm -f liblz4.* pkgconfig/liblz4.pc )
( cd /usr/man/man1
rm -f lz4.1 lz4c.1 lz4cat.1 unlz4.1 )
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "lz4-*" -exec rm -r {} \;
rm -f ~/installed/lz4-*.tar.*