# Get the tarball
cd
test -f installed/openjpeg-2.5.0.tar.gz &&
mv installed/openjpeg-2.5.0.tar.gz .
test ! -f openjpeg-2.5.0.tar.gz &&
wget https://github.com/uclouvain/openjpeg/archive/refs/tags/\
v2.5.0.tar.gz -O openjpeg-2.5.0.tar.gz
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "OpenJPEG_*" -exec rm -r {} \;
find -maxdepth 1 -type d -name "openjpeg-*" -exec rm -r {} \;
tar xzvf ~/openjpeg-2.5.0.tar.gz
cd openjpeg-2.5.0
test $UID = 0 && chown -R root:root .
# Build everything in a sub-directory
mkdir build
cd build
# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
cmake -DCMAKE_INSTALL_PREFIX=/usr -DOPENJPEG_INSTALL_LIB_DIR=/usr/lib64 ..
# Configure the build for anything else
test $(uname -m) != 'x86_64' && cmake ..
# Build it
make
# Become root to install it
su
# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg openjpeg
# Remove old library files if you're sure they are not in use
rm -f /usr/lib*/libopenjpeg.* /usr/local/lib*/libopenjpeg.*
# Install it
make install
ldconfig
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become yourself again
exit
# Save the tarball for later
cd
mkdir -p -m 0700 installed
rm -f installed/openjpeg_*.tar.* installed/openjpeg-*.tar.*
mv openjpeg-2.5.0.tar.gz installed/
# If you ever want to uninstall OpenJPEG, this should do it:
su
cd ~/src/openjpeg-*/build
cat install_manifest.txt | xargs rm
for pfx in /usr /usr/local;
do
cd $pfx
( cd bin
rm -f image_to_j2k j2k_dump j2k_to_image obj_compress obj_decompress \
obj_dump )
find ./doc -type d -maxdepth 1 -name "openjpeg-*" -exec rm -r {} \;
find ./include -type d -maxdepth 1 -name "openjpeg-*" \
-exec rm -r {} \;
for libdir in ${pfx}/lib ${pfx}/lib64;
do
find $libdir -maxdepth 1 -type d -name "openjpeg-*" -exec rm -r {} \;
( cd ${libdir}/pkgconfig
rm -f libopenjp2.pc libopenjpeg1.pc )
done
( cd man/man1 ; image_to_j2k.1 j2k_dump.1 j2k_to_image.1 )
rm -f include/openjpeg.h man/man3/libopenjpeg.3
done
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "OpenJPEG_*" -exec rm -r {} \;
find ~/src -maxdepth 1 -type d -name "openjpeg-*" -exec rm -r {} \;
rm -f ~/installed/openjpeg_*.tar.* installed/openjpeg-*.tar.*