# libimagequant 2.12.2
# ====================
# If you want a command-line utility for this library, see pngquant
# Get it
cd
test -f installed/libimagequant-2.12.2.tar.gz &&
mv -f installed/libimagequant-2.12.2.tar.gz .
test ! -f libimagequant-2.12.2.tar.gz &&
wget -O libimagequant-2.12.2.tar.gz \
https://github.com/ImageOptim/libimagequant/archive/2.12.2.tar.gz
# Extract it
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "libimagequant-*" -exec rm -r {} \;
tar xzvf ~/libimagequant-2.12.2.tar.gz
cd libimagequant-2.12.2
test $UID = 0 && chown -R root:root .
# Read ./README.md
# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
./configure --libdir=/usr/local/lib64 \
--pkgconfigdir=/usr/local/lib64/pkgconfig
# Configure the build for anything else
test $(uname -m) != 'x86_64' && ./configure
# 'make imagequant.pc' does not use libdir passed to configure, so
# update the .in file if 64-bit. If you're not sure what it should be,
# it is whatever LIBDIR in config.mk is set to.
# Verify changes with 'diff -u imagequant.pc.in imagequant.pc'
test $(uname -m) = 'x86_64' &&
cat imagequant.pc.in | \
sed -e 's|\${prefix}/lib$|\${prefix}/lib64|' \
-e 's|PREFIX|/usr/local|' \
-e 's|VERSION|2.12.2|' > imagequant.pc
# Not 64-bit, generate imagequant.pc the usual way
test $(uname -m) != 'x86_64' && make imagequant.pc
# Build it (only) as a shared library
make libimagequant.so
# Make sure your non-root user can remove the source later
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/libimagequant-*.tar.*
mv -f libimagequant-2.12.2.tar.gz installed/
# If you ever want to uninstall libimagequant, this should do it:
cd
su
test -d src/libimagequant-* && ( cd src/libimagequant-* ; make uninstall )
rm -f /usr/local/include/libimagequant.h \
/usr/local/lib64/libimagequant.* \
/usr/local/lib64/pkgconfig/imagequant.pc
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "libimagequant-*" -exec rm -r {} \;
rm -f ~/installed/libimagequant-*.tar.*