# Get the tarball
cd
test -f installed/libffi-3.4.8.tar.gz &&
mv installed/libffi-3.4.8.tar.gz .
test ! -f libffi-3.4.8.tar.gz &&
wget https://github.com/libffi/libffi/releases/download/v3.4.8/\
libffi-3.4.8.tar.gz
# Verify tarball w/ sha256sum:
# (from mine, so this only proves yours is the same)
echo "bc9842a18898bfacb0ed1252c4febcc7e78fa139fd27fdc7a3e30d9d935611\
9b libffi-3.4.8.tar.gz" | sha256sum -c
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -name "libffi-*" -exec rm -r {} \;
tar xzvf ~/libffi-3.4.8.tar.gz
cd libffi-3.4.8
test $UID = 0 && chown -R root:root .
# I use /usr/include/ffi here because of things like Python < 3.12.0 which
# use setup.py It is not so good at finding includes and libraries.
# If /usr/include/ffi is where ffi.h and ffitarget.h are, and:
# pkg-config --cflags-only-I libffi
# outputs that, then you're good.
# If they are in /usr/include and:
# pkg-config --cflags-only-I libffi
# outputs nothing, then it will fail with a useless error similar to
# File not found /usr/include/*.h
# Python >= 3.12.0 does not use setup.py any more.
#
# https://github.com/python/cpython/issues/79004
# https://github.com/python/cpython/issues/58732
# https://github.com/python/cpython/pull/20451
# https://bugs.python.org/issue14527
# https://bugs.python.org/issue31710
# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
./configure --enable-static=no --prefix=/usr \
--docdir=/usr/doc/libffi-3.4.8 \
--includedir=/usr/include/ffi \
--infodir=/usr/info \
--libdir=/usr/lib64 \
--localstatedir=/var \
--mandir=/usr/man \
--sysconfdir=/etc
# Configure the build for anything else
test $(uname -m) = 'x86_64' &&
./configure --enable-static=no --prefix=/usr \
--docdir=/usr/doc/libffi-3.4.8 \
--includedir=/usr/include/ffi \
--infodir=/usr/info \
--localstatedir=/var \
--mandir=/usr/man \
--sysconfdir=/etc
# Build it
make
# Check the build
make check
# Become root to install it
su
# WARNING: make may be linked with libffi, so if you will be removing
# the Slackware package below, you may want to be safe and save a copy
# of /usr/lib*/libffi.so.* to copy back in there manually
# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg libffi
## If 'make' fails here, because it is linked with libffi.so.6
## (ldd /usr/bin/make|grep libffi) and you just
## removed it, you can do something like this in a pinch (maybe):
# cp -a x86_64-pc-linux-gnu/.libs/libffi.so.8.1.4 /usr/lib64/
# ln -s /usr/lib64/libffi.so.8.1.4 /usr/lib64/libffi.so.6
# ldconfig
# If you used --enable-static=no above, remove old version static library
rm -f /usr/lib*/libffi.a
# Remove old version docs
find /usr/doc -maxdepth 1 -type d -name "libffi-*" -exec rm -r {} \;
test -d /usr/doc/libffi
# Be aware that libffi.info will be installed in to /usr/info,
# but you may already have a libffi.info.gz from the GCC Slackware package
# (so use the full path: 'info /usr/info/libffi.info')
# If you used --includedir=/usr/include before (the default), remove
# the old ones
( cd /usr/include ; rm -f ffi.h ffitarget.h )
# Install it
make install
ldconfig
# Create symlinks for anything that assumes the includes are in /usr/include
( cd /usr/include
rm -f ffi.h ffitarget.h
ln -s ffi/ffi.h
ln -s ffi/ffitarget.h )
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become your non-root user again
exit
# Keep the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/libffi-*.tar.*
mv libffi-3.4.8.tar.gz installed/
# If you ever want to uninstall libffi, this should do it:
find /usr/doc -maxdepth 1 -type d -name "libffi-*" -exec rm -r {} \;
cd
su
test -d src/libffi-* && ( cd src/libffi-* ; make uninstall )
find /usr/doc -maxdepth 1 -type d -name "libffi-*" -exec rm -r {} \;
( cd /usr/include
rm -f ffi.h ffitarget.h )
find /usr/lib -maxdepth 1 -type d -name "libffi-*" -exec rm -r {} \;
test -d /usr/lib64 &&
find /usr/lib64 -maxdepth 1 -type d -name "libffi-*" -exec rm -r {} \;
( cd /usr/man/man3 ; rm -f ffi.3 ffi_*.3 )
rm -f /usr/info/libffi.info /usr/lib*/libffi.* /usr/lib*/pkgconfig/libffi.pc
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "libffi-*" -exec rm -r {} \;
rm -f ~/installed/libffi-*.tar.*