2 ### update_autogen - update the generated files in Emacs autogen/ directory
4 ## Copyright (C) 2011 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 the pre-built generated files in
26 ## the autogen/ directory. This is suitable for running from cron.
27 ## Only Emacs maintainers need use this, so it uses bash features.
29 ## With the -l option, it also updates the versioned loaddefs-like
30 ## files in lisp/. These include ldefs-boot, cl-loaddefs, rmail, etc.
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 autogen directory.
48 [ -d autogen
] || die
"Could not locate autogen directory"
54 Usage: ${PN} [-f] [-c] [-q] [-l [-L]] [-C] [-- make-flags]
55 Update the generated files in the Emacs autogen/ directory.
57 -f: force an update even if the source files are locally modified.
58 -c: if the update succeeds and the generated files are modified,
59 commit them (caution).
60 -q: be quiet; only give error messages, not status messages.
61 -l: also update the versioned loaddefs-like files in lisp/.
62 This requires a build. Passes any non-option args to make (eg -- -j2).
63 -L: also update ldefs-boot.el.
64 -C: start from a clean state. Slower, but more correct.
80 ldefs_in
=lisp
/loaddefs.el
81 ldefs_out
=lisp
/ldefs-boot.el
82 sources
="configure.in lib/Makefile.am"
83 genfiles
="configure aclocal.m4 src/config.in lib/Makefile.in compile config.guess config.sub depcomp install-sh missing"
85 for g
in $genfiles; do
86 basegen
="$basegen ${g##*/}"
89 [ "$basegen" ] || die
"internal error"
93 trap "rm -f $tempfile 2> /dev/null" EXIT
96 while getopts ":hcflqCL" option
; do
112 (\?) die
"Bad option -$OPTARG" ;;
114 (:) die
"Option -$OPTARG requires an argument" ;;
116 (*) die
"getopts error" ;;
119 shift $
(( --OPTIND ))
123 ## Does not work 100% because a lot of Emacs batch output comes on stderr (?).
124 [ "$quiet" ] && exec 1> /dev
/null
127 echo "Running bzr status..."
129 bzr status
-S $sources ${ldefs_flag:+lisp} >|
$tempfile || \
130 die
"bzr status error for sources"
132 ## The lisp portion could be more permissive, eg only care about .el files.
133 while read stat
file; do
137 echo "Locally modified: $file"
138 [ "$force" ] || die
"There are local modifications"
141 *) die
"Unexpected status ($stat) for $file" ;;
146 ## Probably this is overkill, and there's no need to "bootstrap" just
147 ## for making autoloads.
150 echo "Running 'make maintainer-clean'..."
152 make maintainer-clean
#|| die "Cleaning error"
158 echo "Running autoreconf..."
160 autoreconf
${clean:+-f} -i -I m4 2>|
$tempfile
164 ## Annoyingly, autoreconf puts the "installing `./foo' messages on stderr.
165 if [ "$quiet" ]; then
166 grep -v 'installing `\.' $tempfile 1>&2
171 [ $retval -ne 0 ] && die
"autoreconf error"
174 cp $genfiles autogen
/
179 echo "Checking status of generated files..."
181 bzr status
-S $basegen >|
$tempfile || \
182 die
"bzr status error for generated files"
187 while read stat
file; do
189 [ "$stat" != "M" ] && die
"Unexpected status ($stat) for generated $file"
191 modified
="$modified $file"
199 ## Uses global $commit.
206 echo "No files were modified"
210 echo "Modified file(s): $@"
212 [ "$commit" ] ||
return 0
216 ## bzr status output is always relative to top-level, not PWD.
217 bzr commit
-m "Auto-commit of $type files." "$@" ||
return $?
219 echo "Committed files: $@"
223 commit
"generated" $modified || die
"bzr commit error"
226 [ "$ldefs_flag" ] ||
exit 0
229 echo "Finding loaddef targets..."
231 sed -n -e '/^AUTOGEN_VCS/,/^$/ s/\\//p' lisp
/Makefile.
in | \
232 sed '/AUTOGEN_VCS/d' >|
$tempfile || die
"sed error"
236 while read genfile
; do
238 [ -r lisp
/$genfile ] || die
"Unable to read $genfile"
240 genfiles
="$genfiles $genfile"
244 [ "$genfiles" ] || die
"Error setting genfiles"
248 echo "Running ./configure..."
250 ## Minimize required packages.
251 .
/configure
--without-x || die
"configure error"
255 ## Build the minimum needed to get the autoloads.
256 echo "Running lib/ make..."
258 make -C lib
"$@" all || die
"make lib error"
261 echo "Running src/ make..."
263 make -C src
"$@" bootstrap-emacs || die
"make src error"
266 echo "Running lisp/ make..."
268 make -C lisp
"$@" autoloads EMACS
=..
/src
/bootstrap-emacs || die
"make src error"
271 ## Ignore comment differences.
272 [ ! "$lboot_flag" ] || \
273 diff -q -I '^;' $ldefs_in $ldefs_out || \
274 cp $ldefs_in $ldefs_out || die
"cp ldefs_boot error"
279 echo "Checking status of loaddef files..."
281 ## It probably would be fine to just check+commit lisp/, since
282 ## making autoloads should not effect any other files. But better
284 bzr status
-S $genfiles ${ldefs_out#lisp/} >|
$tempfile || \
285 die
"bzr status error for generated files"
290 while read stat
file; do
292 [ "$stat" != "M" ] && die
"Unexpected status ($stat) for generated $file"
293 modified
="$modified $file"
301 commit
"loaddefs" $modified || die
"bzr commit error"
306 ### update_autogen ends here