2 ### update_autogen - update some auto-generated files in the Emacs tree
4 ## Copyright (C) 2011-2017 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"
52 elif [ -e .git
]; then
55 die
"Cannot determine vcs"
62 Usage: ${PN} [-f] [-c] [-q] [-A dir] [-I] [-L] [-C] [-- make-flags]
63 Update some auto-generated files in the Emacs tree.
64 By default, only does the versioned loaddefs-like files in lisp/.
65 This requires a build. Passes any non-option args to make (eg -- -j2).
67 -f: force an update even if the source files are locally modified.
68 -c: if the update succeeds and the generated files are modified,
69 commit them (caution).
70 -q: be quiet; only give error messages, not status messages.
71 -A: only update autotools files, copying into specified dir.
72 -H: also update ChangeLog.${changelog_n}
73 -I: also update info/dir.
74 -L: also update ldefs-boot.el.
75 -C: start from a clean state. Slower, but more correct.
87 autogendir
= # was "autogen"
94 ldefs_in
=lisp
/loaddefs.el
95 ldefs_out
=lisp
/ldefs-boot.el
96 changelog_n
=$
(sed -n 's/CHANGELOG_HISTORY_INDEX_MAX *= *//p' Makefile.
in)
97 changelog_files
="ChangeLog.$changelog_n"
98 sources
="configure.ac lib/Makefile.am"
99 ## Files to copy into autogendir.
102 configure aclocal.m4 src/config.in lib/Makefile.in
103 build-aux/compile build-aux/config.guess build-aux/config.sub
104 build-aux/depcomp build-aux/install-sh build-aux/missing
107 genfiles
="src/config.in lib/Makefile.in"
109 for g
in $genfiles; do
110 basegen
="$basegen ${g##*/}"
113 [ "$basegen" ] || die
"internal error"
117 trap "rm -f $tempfile 2> /dev/null" EXIT
120 while getopts ":hcfqA:HCIL" option
; do
130 (A
) autogendir
=$OPTARG
131 [ -d "$autogendir" ] || die
"No autogen directory: $autogendir"
136 (H
) changelog_flag
=1 ;;
142 (\?) die
"Bad option -$OPTARG" ;;
144 (:) die
"Option -$OPTARG requires an argument" ;;
146 (*) die
"getopts error" ;;
149 shift $
(( --OPTIND ))
153 ## Does not work 100% because a lot of Emacs batch output comes on stderr (?).
154 [ "$quiet" ] && exec 1> /dev
/null
157 ## Run status on inputs, list modified files on stdout.
161 [ "$vcs" = "git" ] && statflag
="-s"
163 $vcs status
$statflag "$@" >|
$tempfile || die
"$vcs status error for $@"
165 local stat
file modified
167 while read stat
file; do
169 [ "$stat" != "M" ] && \
170 die
"Unexpected status ($stat) for generated $file"
171 modified
="$modified $file"
181 echo "Checking input file status..."
183 ## The lisp portion could be more permissive, eg only care about .el files.
184 modified
=$
(status
${autogendir:+$sources} ${ldefs_flag:+lisp} ${info_flag:+doc}) || die
187 echo "Locally modified: $modified"
188 [ "$force" ] || die
"There are local modifications"
192 ## Probably this is overkill, and there's no need to "bootstrap" just
193 ## for making autoloads.
196 echo "Running 'make maintainer-clean'..."
198 make maintainer-clean
#|| die "Cleaning error"
204 [ -e nt
/gnulib.mk
] ||
touch nt
/gnulib.mk
# bug#25359
206 echo "Running autoreconf..."
208 autoreconf
${clean:+-f} -i -I m4 2>|
$tempfile
212 ## Annoyingly, autoreconf puts the "installing `./foo' messages on stderr.
213 if [ "$quiet" ]; then
214 grep -v 'installing `\.' $tempfile 1>&2
219 [ $retval -ne 0 ] && die
"autoreconf error"
222 ## Uses global $commit.
229 echo "No files were modified"
233 echo "Modified file(s): $@"
235 [ "$commit" ] ||
return 0
239 $vcs commit
-m "; Auto-commit of $type files." "$@" ||
return $?
241 [ "$vcs" = "git" ] && {
242 $vcs push ||
return $?
245 echo "Committed files: $@"
249 ## No longer used since info/dir is now generated at install time if needed,
250 ## and is not in the repository any more.
253 local basefile
=build-aux
/dir_top outfile
=info
/dir
255 echo "Regenerating info/dir..."
257 ## Header contains non-printing characters, so this is more
258 ## reliable than using echo.
260 cp $basefile $outfile
262 local topic
file dircat dirent
264 ## FIXME inefficient looping.
265 for topic
in "Texinfo documentation system" "Emacs" "GNU Emacs Lisp" \
266 "Emacs editing modes" "Emacs network features" "Emacs misc features" \
267 "Emacs lisp libraries"; do
269 cat - <<EOF >> $outfile
273 ## Bit faster than doc/*/*.texi.
274 for file in doc
/emacs
/emacs.texi
doc
/lispintro
/*.texi \
275 doc
/lispref
/elisp.texi
doc
/misc
/*.texi
; do
277 ## FIXME do not ignore w32 if OS is w32.
279 *-xtra.texi|
*efaq-w32.texi
) continue ;;
282 dircat
=$
(sed -n -e 's/@value{emacsname}/Emacs/' -e 's/^@dircategory //p' $file)
284 ## TODO warn about unknown topics (check-info in top-level
285 ## Makefile does this).
286 [ "$dircat" = "$topic" ] ||
continue
288 sed -n -e 's/@value{emacsname}/Emacs/' \
289 -e 's/@acronym{\([A-Z]*\)}/\1/' \
290 -e '/^@direntry/,/^@end direntry/ s/^\([^@]\)/\1/p' \
298 modified
=$
(status
$outfile) || die
300 commit
"info/dir" $modified || die
"commit error"
301 } # function info_dir
304 [ "$autogendir" ] && {
308 cp $genfiles $autogendir/
310 cd $autogendir || die
"cd error for $autogendir"
312 echo "Checking status of generated files..."
314 modified
=$
(status
$basegen) || die
316 commit
"generated" $modified || die
"commit error"
322 [ "$info_flag" ] && info_dir
325 [ "$ldefs_flag" ] ||
exit 0
328 echo "Finding loaddef targets..."
330 find lisp
-name '*.el' -exec grep '^;.*generated-autoload-file:' {} + | \
331 sed -e '/loaddefs\|esh-groups/d' -e 's|/[^/]*: "|/|' -e 's/"//g' \
332 >|
$tempfile || die
"Error finding targets"
336 while read genfile
; do
338 ## Or we can just use sort -u when making tempfile...
339 case " $genfiles " in
340 *" $genfile "*) continue ;;
343 [ -r $genfile ] || die
"Unable to read $genfile"
345 genfiles
="$genfiles $genfile"
349 [ "$genfiles" ] || die
"Error setting genfiles"
353 echo "Running ./configure..."
355 ## Minimize required packages.
356 .
/configure
--without-x || die
"configure error"
360 ## Build the minimum needed to get the autoloads.
361 echo "Running lib/ make..."
363 make -C lib
"$@" all || die
"make lib error"
366 echo "Running src/ make..."
368 make -C src
"$@" bootstrap-emacs || die
"make src error"
371 echo "Running lisp/ make..."
373 make -C lisp
"$@" autoloads EMACS
=..
/src
/bootstrap-emacs || die
"make src error"
376 ## Ignore comment differences.
377 [ ! "$lboot_flag" ] || \
378 diff -q -I '^;' $ldefs_in $ldefs_out || \
379 cp $ldefs_in $ldefs_out || die
"cp ldefs_boot error"
382 echo "Checking status of loaddef files..."
384 ## It probably would be fine to just check+commit lisp/, since
385 ## making autoloads should not effect any other files. But better
387 modified
=$
(status
$genfiles $ldefs_out) || die
390 commit
"loaddefs" $modified || die
"commit error"
393 ## Less important than the other stuff, so do it last.
394 [ ! "$changelog_flag" ] ||
{
395 make change-history-nocommit || die
"make change-history error"
396 modified
=$
(status
$changelog_files) || die
397 commit
"ChangeLog" $modified || die
"commit error"
403 ### update_autogen ends here