mirror of
https://github.com/openwrt/openwrt.git
synced 2026-10-13 00:17:02 +04:00
Three cases kept a cached answer that no longer held: A new configure script. A package with an autoreconf fixup regenerates configure with the staged autoconf, automake and libtool, and a new version of one of them can change what a cache variable means. The site script now keeps a checksum of configure beside the cache and drops the cache when the checksum changes. A new patch to configure is covered too. A changed precious variable. configure aborts when LIBS, CPP or another precious variable differs from the value in the cache, and because nothing removes the cache, it aborts on every later run as well: configure: error: 'LIBS' was not set in the previous run configure: error: changes in the environment can compromise the build The site script now makes the same comparison before configure does and drops the cache on a difference. Paths under other names. The libtool answers lt_cv_path_*, acl_cv_path_* and lt_cv_sys_global_symbol_*, and gmp_cv_prog_m4, hold the path of a system tool or of the staged sed and m4, and survived a wipe of staging_dir. The site script now drops them with the ac_cv_path_ answers. m4 and gmp still configure the same way with a warm cache as they do without one, and still read it: the m4 configure stage takes 1.5 s warm against 23 s cold. Signed-off-by: John Crispin <john@phrozen.org>
75 lines
3.1 KiB
Bash
75 lines
3.1 KiB
Bash
#!/bin/sh
|
|
#
|
|
# Points the autoconf result cache at the file that the build system keeps for
|
|
# this package. Set CONFIGURE_CACHE_DIR to switch this on; see rules.mk.
|
|
#
|
|
# configure sources the site scripts before it loads the cache, so setting
|
|
# cache_file here has the same effect as --cache-file, without a configure
|
|
# argument that a hand written configure script would choke on.
|
|
|
|
# Autoconf before 2.70 reads CONFIG_SITE as a single path name, so the site
|
|
# script of the architecture cannot be a second word in it. Load it from here.
|
|
if [ -n "$CONFIG_SITE_BASE" ] && [ -r "$CONFIG_SITE_BASE" ]; then
|
|
. "$CONFIG_SITE_BASE"
|
|
fi
|
|
|
|
if [ -n "$CONFIGURE_CACHE_FILE" ]; then
|
|
configure_cache_dir=${CONFIGURE_CACHE_FILE%/*}
|
|
|
|
mkdir -p "$configure_cache_dir" 2>/dev/null
|
|
|
|
# A change of the configure arguments gives a new file name. Drop the
|
|
# file of the previous arguments so that the directory holds one cache
|
|
# per package.
|
|
for configure_cache_stale in "$configure_cache_dir"/*.cache "$configure_cache_dir"/*.cache.sum; do
|
|
[ -f "$configure_cache_stale" ] || continue
|
|
[ "${configure_cache_stale%.sum}" = "$CONFIGURE_CACHE_FILE" ] || rm -f "$configure_cache_stale"
|
|
done
|
|
|
|
# An autoreconf run with a new autoconf, automake or libtool, or a new
|
|
# patch, gives a new configure script whose checks can mean something
|
|
# else under the same cache variable name.
|
|
configure_cache_sum=$(cksum < "${as_myself:-$0}")
|
|
if [ "$configure_cache_sum" != "$(cat "$CONFIGURE_CACHE_FILE.sum" 2>/dev/null)" ]; then
|
|
rm -f "$CONFIGURE_CACHE_FILE"
|
|
printf '%s\n' "$configure_cache_sum" > "$CONFIGURE_CACHE_FILE.sum"
|
|
fi
|
|
|
|
# configure aborts when a precious variable such as LIBS or CPP differs
|
|
# from the value in the cache, and it aborts again on every later run.
|
|
# Make the same comparison here and start from a cold cache instead.
|
|
if [ -f "$CONFIGURE_CACHE_FILE" ] && ! (
|
|
set -f
|
|
. "$CONFIGURE_CACHE_FILE"
|
|
for ac_var in $ac_precious_vars; do
|
|
eval "old_set=\$ac_cv_env_${ac_var}_set new_set=\$ac_env_${ac_var}_set"
|
|
[ "$old_set" = "$new_set" ] || exit 1
|
|
eval "set -- \$ac_cv_env_${ac_var}_value"
|
|
old_val=$*
|
|
eval "set -- \$ac_env_${ac_var}_value"
|
|
[ "$old_val" = "$*" ] || exit 1
|
|
done
|
|
); then
|
|
rm -f "$CONFIGURE_CACHE_FILE"
|
|
fi
|
|
|
|
# A cached program path outlives a wipe of staging_dir, so it can name a
|
|
# tool that is gone, or miss one that the build installed since. Drop
|
|
# those answers and let configure search PATH again. A search runs no
|
|
# compiler, and the compiler is where the time goes. The libtool and gmp
|
|
# answers hold the path of the staged sed and m4.
|
|
if [ -f "$CONFIGURE_CACHE_FILE" ]; then
|
|
grep -v -e '^[a-z]*_cv_path_' -e '^ac_cv_prog_' -e '^gmp_cv_prog_' \
|
|
-e '^lt_cv_sys_global_symbol_' -e '^lt_cv_truncate_bin=' \
|
|
-e '^ac_cv_AM_TEST_RUNNER_SHELL=' \
|
|
"$CONFIGURE_CACHE_FILE" > "$CONFIGURE_CACHE_FILE.tmp"
|
|
mv -f "$CONFIGURE_CACHE_FILE.tmp" "$CONFIGURE_CACHE_FILE"
|
|
fi
|
|
|
|
cache_file=$CONFIGURE_CACHE_FILE
|
|
|
|
# A configure script that runs further configure scripts must not hand
|
|
# this cache to them. Their checks run with different flags.
|
|
unset CONFIGURE_CACHE_FILE configure_cache_dir configure_cache_stale configure_cache_sum
|
|
fi
|