2011-03-20 23:58:23 +00:00
|
|
|
#!/bin/bash
|
|
|
|
### update_autogen - update the generated files in Emacs autogen/ directory
|
|
|
|
|
2012-01-05 09:46:05 +00:00
|
|
|
## Copyright (C) 2011-2012 Free Software Foundation, Inc.
|
2011-03-20 23:58:23 +00:00
|
|
|
|
|
|
|
## Author: Glenn Morris <rgm@gnu.org>
|
|
|
|
|
|
|
|
## This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
## GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published by
|
|
|
|
## the Free Software Foundation, either version 3 of the License, or
|
|
|
|
## (at your option) any later version.
|
|
|
|
|
|
|
|
## GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
|
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
### Commentary:
|
|
|
|
|
|
|
|
## This is a helper script to update the pre-built generated files in
|
|
|
|
## the autogen/ directory. This is suitable for running from cron.
|
|
|
|
## Only Emacs maintainers need use this, so it uses bash features.
|
2011-04-06 02:13:16 +00:00
|
|
|
##
|
|
|
|
## With the -l option, it also updates the versioned loaddefs-like
|
|
|
|
## files in lisp/. These include ldefs-boot, cl-loaddefs, rmail, etc.
|
2011-03-20 23:58:23 +00:00
|
|
|
|
|
|
|
### Code:
|
|
|
|
|
2011-03-25 18:16:41 +00:00
|
|
|
die () # write error to stderr and exit
|
2011-03-20 23:58:23 +00:00
|
|
|
{
|
|
|
|
[ $# -gt 0 ] && echo "$PN: $@" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
PN=${0##*/} # basename of script
|
|
|
|
PD=${0%/*}
|
|
|
|
|
|
|
|
[ "$PD" = "$0" ] && PD=. # if PATH includes PWD
|
|
|
|
|
|
|
|
## This should be the autogen directory.
|
|
|
|
cd $PD
|
|
|
|
cd ../
|
|
|
|
[ -d autogen ] || die "Could not locate autogen directory"
|
|
|
|
|
|
|
|
|
2011-03-25 18:16:41 +00:00
|
|
|
usage ()
|
2011-03-20 23:58:23 +00:00
|
|
|
{
|
|
|
|
cat 1>&2 <<EOF
|
2011-04-06 04:15:53 +00:00
|
|
|
Usage: ${PN} [-f] [-c] [-q] [-l [-L]] [-C] [-- make-flags]
|
2011-03-20 23:58:23 +00:00
|
|
|
Update the generated files in the Emacs autogen/ directory.
|
|
|
|
Options:
|
|
|
|
-f: force an update even if the source files are locally modified.
|
|
|
|
-c: if the update succeeds and the generated files are modified,
|
|
|
|
commit them (caution).
|
|
|
|
-q: be quiet; only give error messages, not status messages.
|
2011-04-06 02:13:16 +00:00
|
|
|
-l: also update the versioned loaddefs-like files in lisp/.
|
|
|
|
This requires a build. Passes any non-option args to make (eg -- -j2).
|
2011-04-06 04:15:53 +00:00
|
|
|
-L: also update ldefs-boot.el.
|
2011-04-06 02:13:16 +00:00
|
|
|
-C: start from a clean state. Slower, but more correct.
|
2011-03-20 23:58:23 +00:00
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
## Defaults.
|
|
|
|
|
|
|
|
force=
|
|
|
|
commit=
|
|
|
|
quiet=
|
2011-04-06 02:13:16 +00:00
|
|
|
clean=
|
|
|
|
ldefs_flag=
|
2011-04-06 04:15:53 +00:00
|
|
|
lboot_flag=
|
2011-03-20 23:58:23 +00:00
|
|
|
|
|
|
|
## Parameters.
|
2011-04-06 02:13:16 +00:00
|
|
|
ldefs_in=lisp/loaddefs.el
|
|
|
|
ldefs_out=lisp/ldefs-boot.el
|
2011-03-20 23:58:23 +00:00
|
|
|
sources="configure.in lib/Makefile.am"
|
2011-07-29 21:59:44 +00:00
|
|
|
genfiles="
|
|
|
|
configure aclocal.m4 src/config.in lib/Makefile.in
|
|
|
|
build-aux/compile build-aux/config.guess build-aux/config.sub
|
|
|
|
build-aux/depcomp build-aux/install-sh build-aux/missing
|
|
|
|
"
|
2011-03-20 23:58:23 +00:00
|
|
|
|
|
|
|
for g in $genfiles; do
|
|
|
|
basegen="$basegen ${g##*/}"
|
|
|
|
done
|
|
|
|
|
|
|
|
[ "$basegen" ] || die "internal error"
|
|
|
|
|
|
|
|
tempfile=/tmp/$PN.$$
|
|
|
|
|
|
|
|
trap "rm -f $tempfile 2> /dev/null" EXIT
|
|
|
|
|
|
|
|
|
2011-04-06 04:15:53 +00:00
|
|
|
while getopts ":hcflqCL" option ; do
|
2011-03-20 23:58:23 +00:00
|
|
|
case $option in
|
|
|
|
(h) usage ;;
|
|
|
|
|
|
|
|
(c) commit=1 ;;
|
|
|
|
|
|
|
|
(f) force=1 ;;
|
|
|
|
|
2011-04-06 02:13:16 +00:00
|
|
|
(l) ldefs_flag=1 ;;
|
|
|
|
|
2011-03-20 23:58:23 +00:00
|
|
|
(q) quiet=1 ;;
|
|
|
|
|
2011-04-06 02:13:16 +00:00
|
|
|
(C) clean=1 ;;
|
|
|
|
|
2011-04-06 04:15:53 +00:00
|
|
|
(L) lboot_flag=1 ;;
|
|
|
|
|
2011-03-20 23:58:23 +00:00
|
|
|
(\?) die "Bad option -$OPTARG" ;;
|
|
|
|
|
|
|
|
(:) die "Option -$OPTARG requires an argument" ;;
|
|
|
|
|
|
|
|
(*) die "getopts error" ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(( --OPTIND ))
|
|
|
|
OPTIND=1
|
|
|
|
|
|
|
|
|
2011-04-06 02:13:16 +00:00
|
|
|
## Does not work 100% because a lot of Emacs batch output comes on stderr (?).
|
2011-03-23 07:58:05 +00:00
|
|
|
[ "$quiet" ] && exec 1> /dev/null
|
2011-03-20 23:58:23 +00:00
|
|
|
|
|
|
|
|
2011-03-23 07:58:05 +00:00
|
|
|
echo "Running bzr status..."
|
2011-03-20 23:58:23 +00:00
|
|
|
|
2011-04-06 02:13:16 +00:00
|
|
|
bzr status -S $sources ${ldefs_flag:+lisp} >| $tempfile || \
|
|
|
|
die "bzr status error for sources"
|
2011-03-20 23:58:23 +00:00
|
|
|
|
2011-04-06 02:13:16 +00:00
|
|
|
## The lisp portion could be more permissive, eg only care about .el files.
|
2011-03-20 23:58:23 +00:00
|
|
|
while read stat file; do
|
|
|
|
|
|
|
|
case $stat in
|
|
|
|
M)
|
2011-03-23 07:58:05 +00:00
|
|
|
echo "Locally modified: $file"
|
2011-03-20 23:58:23 +00:00
|
|
|
[ "$force" ] || die "There are local modifications"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*) die "Unexpected status ($stat) for $file" ;;
|
|
|
|
esac
|
|
|
|
done < $tempfile
|
|
|
|
|
|
|
|
|
2011-04-06 02:13:16 +00:00
|
|
|
## Probably this is overkill, and there's no need to "bootstrap" just
|
|
|
|
## for making autoloads.
|
|
|
|
[ "$clean" ] && {
|
|
|
|
|
|
|
|
echo "Running 'make maintainer-clean'..."
|
|
|
|
|
|
|
|
make maintainer-clean #|| die "Cleaning error"
|
|
|
|
|
|
|
|
rm -f $ldefs_in
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-23 07:58:05 +00:00
|
|
|
echo "Running autoreconf..."
|
2011-03-20 23:58:23 +00:00
|
|
|
|
2011-04-06 02:13:16 +00:00
|
|
|
autoreconf ${clean:+-f} -i -I m4 2>| $tempfile
|
Remove some files that autoreconf can supply.
Ref: http://lists.gnu.org/archive/html/emacs-devel/2011-03/msg00863.html
* compile, config.guess, config.sub, depcomp, install-sh, missing:
Remove; autoreconf can supply them.
* Makefile.in (sync-from-gnulib): Don't sync config.sub,
config.guess, install-sh. Pass -i to autoreconf.
* autogen/update_autogen (genfiles): Add compile, config.guess,
config.sub, depcomp, install-sh, missing. Pass -i to autoreconf.
Discard non-error output from autoreconf in -q case.
* autogen/compile, autogen/config.guess, autogen/config.sub:
* autogen/depcomp, autogen/install-sh, autogen/missing: New files.
* autogen/copy_autogen: Add compile, config.guess, config.sub, depcomp,
install-sh, missing.
* autogen/README: Add compile, config.guess, config.sub, depcomp,
install-sh, missing.
* INSTALL.BZR, admin/make-tarball.txt: Add -i to autoreconf args.
* .bzrignore: Add compile, config.guess, config.sub, depcomp,
install-sh, missing.
2011-03-25 07:14:31 +00:00
|
|
|
|
|
|
|
retval=$?
|
|
|
|
|
|
|
|
## Annoyingly, autoreconf puts the "installing `./foo' messages on stderr.
|
|
|
|
if [ "$quiet" ]; then
|
|
|
|
grep -v 'installing `\.' $tempfile 1>&2
|
|
|
|
else
|
|
|
|
cat "$tempfile" 1>&2
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ $retval -ne 0 ] && die "autoreconf error"
|
2011-03-20 23:58:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
cp $genfiles autogen/
|
|
|
|
|
|
|
|
|
|
|
|
cd autogen
|
|
|
|
|
2011-03-23 07:58:05 +00:00
|
|
|
echo "Checking status of generated files..."
|
2011-03-20 23:58:23 +00:00
|
|
|
|
|
|
|
bzr status -S $basegen >| $tempfile || \
|
|
|
|
die "bzr status error for generated files"
|
|
|
|
|
|
|
|
|
|
|
|
modified=
|
|
|
|
|
|
|
|
while read stat file; do
|
|
|
|
|
|
|
|
[ "$stat" != "M" ] && die "Unexpected status ($stat) for generated $file"
|
|
|
|
|
|
|
|
modified="$modified $file"
|
|
|
|
|
|
|
|
done < $tempfile
|
|
|
|
|
|
|
|
|
2011-04-06 02:13:16 +00:00
|
|
|
cd ../
|
|
|
|
|
|
|
|
|
|
|
|
## Uses global $commit.
|
|
|
|
commit ()
|
|
|
|
{
|
|
|
|
local type=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
[ $# -gt 0 ] || {
|
|
|
|
echo "No files were modified"
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "Modified file(s): $@"
|
|
|
|
|
|
|
|
[ "$commit" ] || return 0
|
|
|
|
|
|
|
|
echo "Committing..."
|
|
|
|
|
|
|
|
## bzr status output is always relative to top-level, not PWD.
|
|
|
|
bzr commit -m "Auto-commit of $type files." "$@" || return $?
|
|
|
|
|
|
|
|
echo "Committed files: $@"
|
|
|
|
} # function commit
|
|
|
|
|
|
|
|
|
|
|
|
commit "generated" $modified || die "bzr commit error"
|
|
|
|
|
|
|
|
|
|
|
|
[ "$ldefs_flag" ] || exit 0
|
|
|
|
|
|
|
|
|
|
|
|
echo "Finding loaddef targets..."
|
|
|
|
|
|
|
|
sed -n -e '/^AUTOGEN_VCS/,/^$/ s/\\//p' lisp/Makefile.in | \
|
|
|
|
sed '/AUTOGEN_VCS/d' >| $tempfile || die "sed error"
|
|
|
|
|
|
|
|
genfiles=
|
|
|
|
|
|
|
|
while read genfile; do
|
|
|
|
|
|
|
|
[ -r lisp/$genfile ] || die "Unable to read $genfile"
|
|
|
|
|
|
|
|
genfiles="$genfiles $genfile"
|
|
|
|
done < $tempfile
|
|
|
|
|
|
|
|
|
|
|
|
[ "$genfiles" ] || die "Error setting genfiles"
|
|
|
|
|
|
|
|
|
|
|
|
[ -e Makefile ] || {
|
|
|
|
echo "Running ./configure..."
|
|
|
|
|
2011-04-06 02:23:28 +00:00
|
|
|
## Minimize required packages.
|
|
|
|
./configure --without-x || die "configure error"
|
2011-03-20 23:58:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-06 02:13:16 +00:00
|
|
|
## Build the minimum needed to get the autoloads.
|
|
|
|
echo "Running lib/ make..."
|
|
|
|
|
|
|
|
make -C lib "$@" all || die "make lib error"
|
|
|
|
|
|
|
|
|
|
|
|
echo "Running src/ make..."
|
|
|
|
|
|
|
|
make -C src "$@" bootstrap-emacs || die "make src error"
|
|
|
|
|
|
|
|
|
|
|
|
echo "Running lisp/ make..."
|
|
|
|
|
|
|
|
make -C lisp "$@" autoloads EMACS=../src/bootstrap-emacs || die "make src error"
|
|
|
|
|
|
|
|
|
2011-04-07 03:22:10 +00:00
|
|
|
## Ignore comment differences.
|
|
|
|
[ ! "$lboot_flag" ] || \
|
|
|
|
diff -q -I '^;' $ldefs_in $ldefs_out || \
|
|
|
|
cp $ldefs_in $ldefs_out || die "cp ldefs_boot error"
|
2011-03-20 23:58:23 +00:00
|
|
|
|
|
|
|
|
2011-04-06 02:13:16 +00:00
|
|
|
cd lisp
|
|
|
|
|
|
|
|
echo "Checking status of loaddef files..."
|
|
|
|
|
|
|
|
## It probably would be fine to just check+commit lisp/, since
|
|
|
|
## making autoloads should not effect any other files. But better
|
|
|
|
## safe than sorry.
|
|
|
|
bzr status -S $genfiles ${ldefs_out#lisp/} >| $tempfile || \
|
|
|
|
die "bzr status error for generated files"
|
|
|
|
|
|
|
|
|
|
|
|
modified=
|
|
|
|
|
|
|
|
while read stat file; do
|
|
|
|
|
|
|
|
[ "$stat" != "M" ] && die "Unexpected status ($stat) for generated $file"
|
|
|
|
modified="$modified $file"
|
|
|
|
|
|
|
|
done < $tempfile
|
|
|
|
|
2011-03-20 23:58:23 +00:00
|
|
|
|
|
|
|
cd ../
|
|
|
|
|
|
|
|
|
2011-04-06 02:13:16 +00:00
|
|
|
commit "loaddefs" $modified || die "bzr commit error"
|
2011-03-20 23:58:23 +00:00
|
|
|
|
|
|
|
|
2011-04-06 02:13:16 +00:00
|
|
|
exit 0
|
2011-03-20 23:58:23 +00:00
|
|
|
|
|
|
|
### update_autogen ends here
|