04b7641e85
- Add x11proto to redbear-full.toml package list - libxau recipe updated with x11proto dependency and custom build script - Fixes libxau build failure: 'Package xproto was not found'
85 lines
3.7 KiB
Bash
85 lines
3.7 KiB
Bash
#!/usr/bin/env bash
|
|
# libtool-version-sync.sh — sync configure's macro_version/revision to host libtool.
|
|
#
|
|
# Autotools recipes that ship a pre-generated `configure` script (libiconv 1.17,
|
|
# gettext 0.21, and many others) embed the libtool release identifier at
|
|
# configure-generation time. When the host's libtool is later updated (for
|
|
# example, from 2.6.0 to 2.6.0.23-b08cb on Debian), the bundled configure
|
|
# declares an older macro_version than the running libtool binary, and
|
|
# libtool aborts with:
|
|
#
|
|
# Version mismatch error. This is libtool <host>, but the
|
|
# definition of this LT_INIT comes from libtool <bundled>.
|
|
# You should recreate aclocal.m4 with macros from <host>
|
|
# and run autoconf again.
|
|
#
|
|
# Regenerating aclocal.m4 + configure inside every cross-compiled recipe is
|
|
# brittle and depends on autoconf/automake being available in the cookbook
|
|
# environment. The robust workaround used here is to rewrite the macro_version
|
|
# and macro_revision assignments inside the existing configure scripts so they
|
|
# match the host libtool's runtime version. configure then embeds the right
|
|
# version into the generated libtool helper, and the version check passes.
|
|
#
|
|
# Usage from a recipe's [build] script:
|
|
#
|
|
# . "${COOKBOOK_SOURCE}/../../../../local/scripts/lib/libtool-version-sync.sh"
|
|
# redbear_sync_libtool_version "${COOKBOOK_SOURCE}/configure" \
|
|
# "${COOKBOOK_SOURCE}/libcharset/configure"
|
|
#
|
|
# The paths are script-relative because recipes can be in any category.
|
|
|
|
_redbear_libtool_version() {
|
|
# The cookbook prepends the Redox cross sysroot's bin/ to PATH, so
|
|
# `command -v libtool` can return the Redox-target libtool
|
|
# (e.g. 2.5.4-redox-9510) instead of the host toolchain's libtool.
|
|
# Search known host prefixes first to make sure we report the
|
|
# actually-running libtool that the configure scripts will see at
|
|
# compile time, not the cross-compile wrapper.
|
|
local host_libtool
|
|
for host_libtool in /usr/bin/libtool /bin/libtool /usr/local/bin/libtool; do
|
|
if [ -x "${host_libtool}" ]; then
|
|
"${host_libtool}" --version 2>/dev/null | head -n1 | awk '{print $NF}'
|
|
return 0
|
|
fi
|
|
done
|
|
if [ -f /usr/share/libtool/build-aux/ltmain.sh ]; then
|
|
grep '^VERSION=' /usr/share/libtool/build-aux/ltmain.sh | head -n1 \
|
|
| sed -E "s/^VERSION=['\"]?([^'\"]+)['\"]?$/\1/"
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
_redbear_libtool_revision() {
|
|
local version="$1"
|
|
# The "revision" is the <MAJOR>.<MINOR>.<PATCH> triple with the build-suffix
|
|
# (e.g. 2.6.0.23-b08cb -> 2.6.0.23). Drop the trailing -<suffix> segment.
|
|
printf '%s\n' "${version%%-*}"
|
|
}
|
|
|
|
redbear_sync_libtool_version() {
|
|
local host_version host_revision path
|
|
host_version="$(_redbear_libtool_version)" || {
|
|
echo "redbear_sync_libtool_version: unable to detect host libtool version" >&2
|
|
return 1
|
|
}
|
|
host_revision="$(_redbear_libtool_revision "${host_version}")"
|
|
|
|
for path in "$@"; do
|
|
[ -f "${path}" ] || continue
|
|
_redbear_rewrite_configure_libtool_id "${path}" "${host_version}" "${host_revision}"
|
|
done
|
|
}
|
|
|
|
_redbear_rewrite_configure_libtool_id() {
|
|
local path="$1" host_version="$2" host_revision="$3"
|
|
sed -i \
|
|
-e "s/macro_version='2\.4\.7'/macro_version='${host_version}'/g" \
|
|
-e "s/macro_version='2\.5\.4-redox-9510'/macro_version='${host_version}'/g" \
|
|
-e "s/macro_version='2\.6\.0'/macro_version='${host_version}'/g" \
|
|
-e "s/macro_revision='2\.4\.7'/macro_revision='${host_revision}'/g" \
|
|
-e "s/macro_revision='2\.5\.4-redox-9510'/macro_revision='${host_revision}'/g" \
|
|
-e "s/macro_revision='2\.6\.0'/macro_revision='${host_revision}'/g" \
|
|
"${path}"
|
|
}
|