#!/bin/sh -e

./configure \
    --prefix=/usr \
    --disable-exec-static-tramp \
    --with-pic

make
make install

# Maintain compatibility and avoid the need
# for rebuilds of all packages linking to
# libffi.
#
# ABI incompatibility (6 -> 7) only affects AArch64.
# See: https://github.com/libffi/libffi/commit/c02c341
#      https://github.com/libffi/libffi/issues/528
#
# ABI incompatibility (7 -> 8) only affects
# --enable-exec-static-tramp (which is default).
# See: https://sourceware.org/pipermail/libffi-discuss/2021/002644.html
#      https://github.com/libffi/libffi/pull/647
ln -sf libffi.so.7 "$1/usr/lib/libffi.so.6"
ln -sf libffi.so.8 "$1/usr/lib/libffi.so.7"