2 ### update_autogen - update some auto-generated files in the Emacs tree
4 ## Copyright (C) 2011-2013 Free Software Foundation, Inc.
6 ## Author: Glenn Morris <rgm@gnu.org>
8 ## This file is part of GNU Emacs.
10 ## GNU Emacs is free software: you can redistribute it and/or modify
11 ## it under the terms of the GNU General Public License as published by
12 ## the Free Software Foundation, either version 3 of the License, or
13 ## (at your option) any later version.
15 ## GNU Emacs is distributed in the hope that it will be useful,
16 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ## GNU General Public License for more details.
20 ## You should have received a copy of the GNU General Public License
21 ## along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ## This is a helper script to update some generated files in the Emacs
26 ## repository. This is suitable for running from cron.
27 ## Only Emacs maintainers need use this, so it uses bash features.
29 ## By default, it updates the versioned loaddefs-like files in lisp,
30 ## except ldefs-boot.el.
34 die
() # write error to stderr and exit
36 [ $# -gt 0 ] && echo "$PN: $@" >&2
40 PN
=${0##*/} # basename of script
43 [ "$PD" = "$0" ] && PD
=.
# if PATH includes PWD
45 ## This should be the admin directory.
48 [ -d admin
] || die
"Could not locate admin directory"
54 Usage: ${PN} [-f] [-c] [-q] [-A dir] [-L] [-C] [-- make-flags]
55 Update some auto-generated files in the Emacs tree.
56 By default, only does the versioned loaddefs-like files in lisp/.
57 This requires a build. Passes any non-option args to make (eg -- -j2).
59 -f: force an update even if the source files are locally modified.
60 -c: if the update succeeds and the generated files are modified,
61 commit them (caution).
62 -q: be quiet; only give error messages, not status messages.
63 -A: only update autotools files, copying into specified dir.
64 -L: also update ldefs-boot.el.
65 -C: start from a clean state. Slower, but more correct.
77 autogendir
= # was "autogen"
82 ldefs_in
=lisp
/loaddefs.el
83 ldefs_out
=lisp
/ldefs-boot.el
84 sources
="configure.ac lib/Makefile.am"
85 ## Files to copy into autogendir.
88 configure aclocal.m4 src/config.in lib/Makefile.in
89 build-aux/compile build-aux/config.guess build-aux/config.sub
90 build-aux/depcomp build-aux/install-sh build-aux/missing
93 genfiles
="src/config.in lib/Makefile.in"
95 for g
in $genfiles; do
96 basegen
="$basegen ${g##*/}"
99 [ "$basegen" ] || die
"internal error"
103 trap "rm -f $tempfile 2> /dev/null" EXIT
106 while getopts ":hcfqA:CL" option
; do
116 (A
) autogendir
=$OPTARG
117 [ -d "$autogendir" ] || die
"No autogen directory: $autogendir"
124 (\?) die
"Bad option -$OPTARG" ;;
126 (:) die
"Option -$OPTARG requires an argument" ;;
128 (*) die
"getopts error" ;;
131 shift $
(( --OPTIND ))
135 ## Does not work 100% because a lot of Emacs batch output comes on stderr (?).
136 [ "$quiet" ] && exec 1> /dev
/null
139 echo "Running bzr status..."
141 bzr status
-S ${autogendir:+$sources} ${ldefs_flag:+lisp} >|
$tempfile || \
142 die
"bzr status error for input files"
144 ## The lisp portion could be more permissive, eg only care about .el files.
145 while read stat
file; do
149 echo "Locally modified: $file"
150 [ "$force" ] || die
"There are local modifications"
153 *) die
"Unexpected status ($stat) for $file" ;;
158 ## Probably this is overkill, and there's no need to "bootstrap" just
159 ## for making autoloads.
162 echo "Running 'make maintainer-clean'..."
164 make maintainer-clean
#|| die "Cleaning error"
170 echo "Running autoreconf..."
172 autoreconf
${clean:+-f} -i -I m4 2>|
$tempfile
176 ## Annoyingly, autoreconf puts the "installing `./foo' messages on stderr.
177 if [ "$quiet" ]; then
178 grep -v 'installing `\.' $tempfile 1>&2
183 [ $retval -ne 0 ] && die
"autoreconf error"
186 ## Uses global $commit.
193 echo "No files were modified"
197 echo "Modified file(s): $@"
199 [ "$commit" ] ||
return 0
203 ## bzr status output is always relative to top-level, not PWD.
204 bzr commit
-m "Auto-commit of $type files." "$@" ||
return $?
206 echo "Committed files: $@"
210 [ "$autogendir" ] && {
214 cp $genfiles $autogendir/
216 cd $autogendir || die
"cd error for $autogendir"
218 echo "Checking status of generated files..."
220 bzr status
-S $basegen >|
$tempfile || \
221 die
"bzr status error for generated files"
225 while read stat
file; do
227 [ "$stat" != "M" ] && \
228 die
"Unexpected status ($stat) for generated $file"
230 modified
="$modified $file"
236 commit
"generated" $modified || die
"bzr commit error"
242 [ "$ldefs_flag" ] ||
exit 0
245 echo "Finding loaddef targets..."
247 sed -n -e '/^AUTOGEN_VCS/,/^$/ s/\\//p' lisp
/Makefile.
in | \
248 sed '/AUTOGEN_VCS/d' >|
$tempfile || die
"sed error"
252 while read genfile
; do
254 [ -r lisp
/$genfile ] || die
"Unable to read $genfile"
256 genfiles
="$genfiles $genfile"
260 [ "$genfiles" ] || die
"Error setting genfiles"
264 echo "Running ./configure..."
266 ## Minimize required packages.
267 .
/configure
--without-x || die
"configure error"
271 ## Build the minimum needed to get the autoloads.
272 echo "Running lib/ make..."
274 make -C lib
"$@" all || die
"make lib error"
277 echo "Running src/ make..."
279 make -C src
"$@" bootstrap-emacs || die
"make src error"
282 echo "Running lisp/ make..."
284 make -C lisp
"$@" autoloads EMACS
=..
/src
/bootstrap-emacs || die
"make src error"
287 ## Ignore comment differences.
288 [ ! "$lboot_flag" ] || \
289 diff -q -I '^;' $ldefs_in $ldefs_out || \
290 cp $ldefs_in $ldefs_out || die
"cp ldefs_boot error"
295 echo "Checking status of loaddef files..."
297 ## It probably would be fine to just check+commit lisp/, since
298 ## making autoloads should not effect any other files. But better
300 bzr status
-S $genfiles ${ldefs_out#lisp/} >|
$tempfile || \
301 die
"bzr status error for generated files"
306 while read stat
file; do
308 [ "$stat" != "M" ] && die
"Unexpected status ($stat) for generated $file"
309 modified
="$modified $file"
317 commit
"loaddefs" $modified || die
"bzr commit error"
322 ### update_autogen ends here