build: manually update bootstrap from gnulib, and adapt

Updating to the latest bootstrap from gnulib involves more of a
change than usual, and updating to the latest gnulib would involve
its own set of challenges with the upcoming quoting changes, so
we update bootstrap manually and separately.
* bootstrap: Update from gnulib.
* Makefile.am: Initialize more variables to empty, so that gnulib.mk
can append to them with "+=".
* bootstrap.conf (gnulib_mk_hook): Remove.  No longer honored.
(bootstrap_post_import_hook): Instead, run the same command,
etc/prefix-gnulib-mk lib/$gnulib_mk, via slightly different API.
Temporarily disable "bootstrap_sync=true".
* etc/prefix-gnulib-mk: Don't prepend "lib/" to tokens like -I$(...
or "\".
This commit is contained in:
Jim Meyering
2012-01-16 12:29:19 +01:00
parent 77f114dd6e
commit 85ad742d4e
4 changed files with 130 additions and 193 deletions

View File

@@ -37,6 +37,9 @@ BUILT_SOURCES =
DISTCLEANFILES = DISTCLEANFILES =
MOSTLYCLEANFILES = MOSTLYCLEANFILES =
SUFFIXES = SUFFIXES =
noinst_LIBRARIES =
MOSTLYCLEANDIRS =
include build-aux/local.mk include build-aux/local.mk
include data/local.mk include data/local.mk
include djgpp/local.mk include djgpp/local.mk

308
bootstrap
View File

@@ -1,10 +1,10 @@
#! /bin/sh #! /bin/sh
# Print a version string. # Print a version string.
scriptversion=2011-04-05.18; # UTC scriptversion=2012-01-18.21; # UTC
# Bootstrap this package from checked-out sources. # Bootstrap this package from checked-out sources.
# Copyright (C) 2003-2011 Free Software Foundation, Inc. # Copyright (C) 2003-2012 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -38,10 +38,6 @@ export LC_ALL
local_gl_dir=gl local_gl_dir=gl
# Temporary directory names.
bt='._bootmp'
bt_regex=`echo "$bt"| sed 's/\./[.]/g'`
bt2=${bt}2
me=$0 me=$0
usage() { usage() {
@@ -88,9 +84,12 @@ gnulib_modules=
# Any gnulib files needed that are not in modules. # Any gnulib files needed that are not in modules.
gnulib_files= gnulib_files=
# A function to be called to edit gnulib.mk right after it's created. : ${AUTOPOINT=autopoint}
: ${AUTORECONF=autoreconf}
# A function to be called right after gnulib-tool is run.
# Override it via your own definition in bootstrap.conf. # Override it via your own definition in bootstrap.conf.
gnulib_mk_hook() { :; } bootstrap_post_import_hook() { :; }
# A function to be called after everything else in this script. # A function to be called after everything else in this script.
# Override it via your own definition in bootstrap.conf. # Override it via your own definition in bootstrap.conf.
@@ -105,6 +104,11 @@ po_download_command_format=\
"rsync --delete --exclude '*.s1' -Lrtvz \ "rsync --delete --exclude '*.s1' -Lrtvz \
'translationproject.org::tp/latest/%s/' '%s'" 'translationproject.org::tp/latest/%s/' '%s'"
# Fallback for downloading .po files (if rsync fails).
po_download_command_format2=\
"wget --mirror -nd -q -np -A.po -P '%s' \
http://translationproject.org/latest/%s/"
extract_package_name=' extract_package_name='
/^AC_INIT(/{ /^AC_INIT(/{
/.*,.*,.*, */{ /.*,.*,.*, */{
@@ -290,7 +294,7 @@ sort_patterns() {
P P
x x
s/^\n// s/^\n//
}' }' | sed '/^$/d'
} }
# If $STR is not already on a line by itself in $FILE, insert it, # If $STR is not already on a line by itself in $FILE, insert it,
@@ -312,8 +316,8 @@ insert_vc_ignore() {
pattern="$2" pattern="$2"
case $vc_ignore_file in case $vc_ignore_file in
*.gitignore) *.gitignore)
# A .gitignore entry that does not start with `/' applies # A .gitignore entry that does not start with '/' applies
# recursively to subdirectories, so prepend `/' to every # recursively to subdirectories, so prepend '/' to every
# .gitignore entry. # .gitignore entry.
pattern=`echo "$pattern" | sed s,^,/,`;; pattern=`echo "$pattern" | sed s,^,/,`;;
esac esac
@@ -421,18 +425,32 @@ check_versions() {
# Honor $APP variables ($TAR, $AUTOCONF, etc.) # Honor $APP variables ($TAR, $AUTOCONF, etc.)
appvar=`echo $app | tr '[a-z]-' '[A-Z]_'` appvar=`echo $app | tr '[a-z]-' '[A-Z]_'`
test "$appvar" = TAR && appvar=AMTAR test "$appvar" = TAR && appvar=AMTAR
eval "app=\${$appvar-$app}" case $appvar in
inst_ver=$(get_version $app) GZIP) ;; # Do not use $GZIP: it contains gzip options.
if [ ! "$inst_ver" ]; then *) eval "app=\${$appvar-$app}" ;;
echo "$me: Error: '$app' not found" >&2 esac
ret=1 if [ "$req_ver" = "-" ]; then
elif [ ! "$req_ver" = "-" ]; then # Merely require app to exist; not all prereq apps are well-behaved
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2) # so we have to rely on $? rather than get_version.
if [ ! "$latest_ver" = "$inst_ver" ]; then $app --version >/dev/null 2>&1
echo "$me: Error: '$app' version == $inst_ver is too old" >&2 if [ 126 -le $? ]; then
echo " '$app' version >= $req_ver is required" >&2 echo "$me: Error: '$app' not found" >&2
ret=1 ret=1
fi fi
else
# Require app to produce a new enough version string.
inst_ver=$(get_version $app)
if [ ! "$inst_ver" ]; then
echo "$me: Error: '$app' not found" >&2
ret=1
else
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
if [ ! "$latest_ver" = "$inst_ver" ]; then
echo "$me: Error: '$app' version == $inst_ver is too old" >&2
echo " '$app' version >= $req_ver is required" >&2
ret=1
fi
fi
fi fi
done done
@@ -459,6 +477,32 @@ if test $use_libtool = 1; then
find_tool LIBTOOLIZE glibtoolize libtoolize find_tool LIBTOOLIZE glibtoolize libtoolize
fi fi
# gnulib-tool requires at least automake and autoconf.
# If either is not listed, add it (with minimum version) as a prerequisite.
case $buildreq in
*automake*) ;;
*) buildreq="automake 1.9
$buildreq" ;;
esac
case $buildreq in
*autoconf*) ;;
*) buildreq="autoconf 2.59
$buildreq" ;;
esac
# When we can deduce that gnulib-tool will require patch,
# and when patch is not already listed as a prerequisite, add it, too.
if test ! -d "$local_gl_dir" \
|| find "$local_gl_dir" -name '*.diff' -exec false {} +; then
:
else
case $buildreq in
*patch*) ;;
*) buildreq="patch -
$buildreq" ;;
esac
fi
if ! printf "$buildreq" | check_versions; then if ! printf "$buildreq" | check_versions; then
echo >&2 echo >&2
if test -f README-prereq; then if test -f README-prereq; then
@@ -569,6 +613,9 @@ download_po_files() {
domain=$2 domain=$2
echo "$me: getting translations into $subdir for $domain..." echo "$me: getting translations into $subdir for $domain..."
cmd=`printf "$po_download_command_format" "$domain" "$subdir"` cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
eval "$cmd" && return
# Fallback to HTTP.
cmd=`printf "$po_download_command_format2" "$subdir" "$domain"`
eval "$cmd" eval "$cmd"
} }
@@ -656,10 +703,18 @@ symlink_to_dir()
cp -fp "$src" "$dst" cp -fp "$src" "$dst"
} }
else else
# Leave any existing symlink alone, if it already points to the source,
# so that broken build tools that care about symlink times
# aren't confused into doing unnecessary builds. Conversely, if the
# existing symlink's time stamp is older than the source, make it afresh,
# so that broken tools aren't confused into skipping needed builds. See
# <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00326.html>.
test -h "$dst" && test -h "$dst" &&
src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 && src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 && dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
test "$src_i" = "$dst_i" || { test "$src_i" = "$dst_i" &&
both_ls=`ls -dt "$src" "$dst"` &&
test "X$both_ls" = "X$dst$nl$src" || {
dot_dots= dot_dots=
case $src in case $src in
/*) ;; /*) ;;
@@ -681,56 +736,32 @@ symlink_to_dir()
} }
} }
cp_mark_as_generated() # NOTE: we have to be careful to run both autopoint and libtoolize
{ # before gnulib-tool, since gnulib-tool is likely to provide newer
cp_src=$1 # versions of files "installed" by these two programs.
cp_dst=$2 # Then, *after* gnulib-tool (see below), we have to be careful to
# run autoreconf in such a way that it does not run either of these
# two just-pre-run programs.
if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then # Import from gettext.
symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst" with_gettext=yes
elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
symlink_to_dir $local_gl_dir "$cp_dst" with_gettext=no
else
case $cp_dst in
*.[ch]) c1='/* '; c2=' */';;
*.texi) c1='@c '; c2= ;;
*.m4|*/Make*|Make*) c1='# ' ; c2= ;;
*) c1= ; c2= ;;
esac
# If the destination directory doesn't exist, create it. if test $with_gettext = yes; then
# This is required at least for "lib/uniwidth/cjk.h". # Released autopoint has the tendency to install macros that have been
dst_dir=`dirname "$cp_dst"` # obsoleted in current gnulib, so run this before gnulib-tool.
test -d "$dst_dir" || mkdir -p "$dst_dir" echo "$0: $AUTOPOINT --force"
$AUTOPOINT --force || exit
fi
if test -z "$c1"; then # Autoreconf runs aclocal before libtoolize, which causes spurious
cmp -s "$cp_src" "$cp_dst" || { # warnings if the initial aclocal is confused by the libtoolized
# Copy the file first to get proper permissions if it # (or worse out-of-date) macro directory.
# doesn't already exist. Then overwrite the copy. if test $use_libtool = 1; then
echo "$me: cp -f $cp_src $cp_dst" && echo "running: $LIBTOOLIZE --copy --install"
rm -f "$cp_dst" && $LIBTOOLIZE --copy --install
cp "$cp_src" "$cp_dst-t" && fi
sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst-t" &&
mv -f "$cp_dst-t" "$cp_dst"
}
else
# Copy the file first to get proper permissions if it
# doesn't already exist. Then overwrite the copy.
cp "$cp_src" "$cp_dst-t" &&
(
echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
sed "s!$bt_regex/!!g" "$cp_src"
) > $cp_dst-t &&
if cmp -s "$cp_dst-t" "$cp_dst"; then
rm -f "$cp_dst-t"
else
echo "$me: cp $cp_src $cp_dst # with edits" &&
mv -f "$cp_dst-t" "$cp_dst"
fi
fi
fi
}
version_controlled_file() { version_controlled_file() {
dir=$1 dir=$1
@@ -749,96 +780,17 @@ version_controlled_file() {
test $found = yes test $found = yes
} }
slurp() {
for dir in . `(cd $1 && find * -type d -print)`; do
copied=
sep=
for file in `ls -a $1/$dir`; do
case $file in
.|..) continue;;
# FIXME: should all file names starting with "." be ignored?
.*) continue;;
esac
test -d $1/$dir/$file && continue
for excluded_file in $excluded_files; do
test "$dir/$file" = "$excluded_file" && continue 2
done
if test $file = Makefile.am && test "X$gnulib_mk" != XMakefile.am; then
copied=$copied${sep}$gnulib_mk; sep=$nl
remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
sed "$remove_intl" $1/$dir/$file |
cmp - $dir/$gnulib_mk > /dev/null || {
echo "$me: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
rm -f $dir/$gnulib_mk &&
sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk &&
gnulib_mk_hook $dir/$gnulib_mk
}
elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
version_controlled_file $dir $file; then
echo "$me: $dir/$file overrides $1/$dir/$file"
else
copied=$copied$sep$file; sep=$nl
if test $file = gettext.m4; then
echo "$me: patching m4/gettext.m4 to remove need for intl/* ..."
rm -f $dir/$file
sed '
/^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
AC_DEFUN([AM_INTL_SUBDIR], [])
/^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
$a\
AC_DEFUN([gl_LOCK_EARLY], [])
' $1/$dir/$file >$dir/$file
else
cp_mark_as_generated $1/$dir/$file $dir/$file
fi
fi || exit
done
for dot_ig in x $vc_ignore; do
test $dot_ig = x && continue
ig=$dir/$dot_ig
if test -n "$copied"; then
insert_vc_ignore $ig "$copied"
# If an ignored file name ends with .in.h, then also add
# the name with just ".h". Many gnulib headers are generated,
# e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
# Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
f=`echo "$copied" |
sed '
s/\.in\.h$/.h/
s/\.sin$/.sed/
s/\.y$/.c/
s/\.gperf$/.h/
'
`
insert_vc_ignore $ig "$f"
# For files like sys_stat.in.h and sys_time.in.h, record as
# ignorable the directory we might eventually create: sys/.
f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
insert_vc_ignore $ig "$f"
fi
done
done
}
# Create boot temporary directories to import from gnulib and gettext.
rm -fr $bt $bt2 &&
mkdir $bt $bt2 || exit
# Import from gnulib. # Import from gnulib.
gnulib_tool_options="\ gnulib_tool_options="\
--import\ --import\
--no-changelog\ --no-changelog\
--aux-dir $bt/$build_aux\ --aux-dir $build_aux\
--doc-base $bt/$doc_base\ --doc-base $doc_base\
--lib $gnulib_name\ --lib $gnulib_name\
--m4-base $bt/$m4_base/\ --m4-base $m4_base/\
--source-base $bt/$source_base/\ --source-base $source_base/\
--tests-base $bt/$tests_base\ --tests-base $tests_base\
--local-dir $local_gl_dir\ --local-dir $local_gl_dir\
$gnulib_tool_option_extras\ $gnulib_tool_option_extras\
" "
@@ -850,25 +802,12 @@ if test $use_libtool = 1; then
fi fi
echo "$0: $gnulib_tool $gnulib_tool_options --import ..." echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules && $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
slurp $bt || exit
for file in $gnulib_files; do for file in $gnulib_files; do
symlink_to_dir "$GNULIB_SRCDIR" $file || exit symlink_to_dir "$GNULIB_SRCDIR" $file || exit
done done
bootstrap_post_import_hook
# Import from gettext.
with_gettext=yes
grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
with_gettext=no
if test $with_gettext = yes; then
echo "$0: (cd $bt2; ${AUTOPOINT-autopoint}) ..."
cp configure.ac $bt2 &&
(cd $bt2 && ${AUTOPOINT-autopoint} && rm configure.ac) &&
slurp $bt2 $bt || exit
fi
rm -fr $bt $bt2 || exit
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
# gnulib-populated directories. Such .m4 files would cause aclocal to fail. # gnulib-populated directories. Such .m4 files would cause aclocal to fail.
@@ -882,28 +821,21 @@ find "$m4_base" "$source_base" \
-depth \( -name '*.m4' -o -name '*.[ch]' \) \ -depth \( -name '*.m4' -o -name '*.[ch]' \) \
-type l -xtype l -delete > /dev/null 2>&1 -type l -xtype l -delete > /dev/null 2>&1
# Reconfigure, getting other files. # Some systems (RHEL 5) are using ancient autotools, for which the
# --no-recursive option had not been invented. Detect that lack and
# Skip autoheader if it's not needed. # omit the option when it's not supported. FIXME in 2017: remove this
grep -E '^[ ]*AC_CONFIG_HEADERS?\>' configure.ac >/dev/null || # hack when RHEL 5 autotools are updated, or when they become irrelevant.
AUTOHEADER=true no_recursive=
case $($AUTORECONF --help) in
for command in \ *--no-recursive*) no_recursive=--no-recursive;;
libtool \ esac
"${ACLOCAL-aclocal} --force -I '$m4_base' $ACLOCAL_FLAGS" \
"${AUTOCONF-autoconf} --force" \
"${AUTOHEADER-autoheader} --force" \
"${AUTOMAKE-automake} --add-missing --copy --force-missing"
do
if test "$command" = libtool; then
test $use_libtool = 0 \
&& continue
command="${LIBTOOLIZE-libtoolize} -c -f"
fi
echo "$0: $command ..."
eval "$command" || exit
done
# Tell autoreconf not to invoke autopoint or libtoolize; they were run above.
echo "running: AUTOPOINT=true LIBTOOLIZE=true " \
"$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS"
AUTOPOINT=true LIBTOOLIZE=true \
$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \
|| exit 1
# Get some extra files from gnulib, overriding existing files. # Get some extra files from gnulib, overriding existing files.
for file in $gnulib_extra_files; do for file in $gnulib_extra_files; do

View File

@@ -60,10 +60,12 @@ excluded_files='
m4/visibility.m4 m4/visibility.m4
' '
# Massage lib/gnulib.mk before using it later in the bootstrapping process. gnulib_tool_option_extras='--symlink --makefile-name=gnulib.mk'
gnulib_mk_hook()
bootstrap_post_import_hook()
{ {
etc/prefix-gnulib-mk $1 # Massage lib/gnulib.mk before using it later in the bootstrapping process.
etc/prefix-gnulib-mk lib/$gnulib_mk
} }
bootstrap_epilogue() bootstrap_epilogue()
@@ -78,4 +80,4 @@ bootstrap_epilogue()
# the bootstrap entry from the file .x-update-copyright, and add any # the bootstrap entry from the file .x-update-copyright, and add any
# needed copyright years to the copyright statement in the bootstrap # needed copyright years to the copyright statement in the bootstrap
# script. # script.
bootstrap_sync=true # FIXME: temporary bootstrap_sync=true

View File

@@ -26,7 +26,7 @@ sub prefix_word ($)
{ {
local ($_) = @_; local ($_) = @_;
$_ = $prefix . $_ $_ = $prefix . $_
unless m{^\$\(\w+\)} || $_ eq "Makefile"; unless /^-/ || m{^\$\(\w+\)} || $_ eq "Makefile" || $_ eq '\\';
return $_; return $_;
} }