diff options
| author | Glenn Morris <rgm@gnu.org> | 2013-11-04 23:54:03 -0800 |
|---|---|---|
| committer | Glenn Morris <rgm@gnu.org> | 2013-11-04 23:54:03 -0800 |
| commit | 4dde498bceb259c0ce670a846224da39a118459b (patch) | |
| tree | 4921ecdf1f78a92095cded1b598acc3ac42b7ffc /admin/update_autogen | |
| parent | ceb486d4970c9080d2974d6852de9e9eb846d990 (diff) | |
| download | emacs-4dde498bceb259c0ce670a846224da39a118459b.tar.gz | |
Remove the autogen/ directory
Ref: http://lists.gnu.org/archive/html/emacs-devel/2013-10/msg00806.html
* autogen: Remove directory. Move update_autogen to admin/.
* autogen.sh: Remove reference to copy_autogen.
* GNUmakefile (configure):
* Makefile.in (bootstrap): Do not try to run copy_autogen.
* config.bat: Use msdos/autogen rather than autogen.
* admin/update_autogen: Move here from ../autogen.
(usage): Update. Remove -l, add -A.
(autogendir): New variable.
(ldefs_flag): Default to set.
(genfiles): Reduce to only ms-dos relevant files.
(main): Make checking autogen sources optional.
Make copying of autogen files optional.
* msdos/autogen/config.in:
* msdos/autogen/Makefile.in: Move here from ../autogen.
* nt/INSTALL: Remove reference to copy_autogen.
* nt/config.nt: Comment.
Diffstat (limited to 'admin/update_autogen')
| -rwxr-xr-x | admin/update_autogen | 322 |
1 files changed, 322 insertions, 0 deletions
diff --git a/admin/update_autogen b/admin/update_autogen new file mode 100755 index 00000000000..316c9330b62 --- /dev/null +++ b/admin/update_autogen @@ -0,0 +1,322 @@ +#!/bin/bash +### update_autogen - update some auto-generated files in the Emacs tree + +## Copyright (C) 2011-2013 Free Software Foundation, Inc. + +## 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 some generated files in the Emacs +## repository. This is suitable for running from cron. +## Only Emacs maintainers need use this, so it uses bash features. +## +## By default, it updates the versioned loaddefs-like files in lisp, +## except ldefs-boot.el. + +### Code: + +die () # write error to stderr and exit +{ + [ $# -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 admin directory. +cd $PD +cd ../ +[ -d admin ] || die "Could not locate admin directory" + + +usage () +{ + cat 1>&2 <<EOF +Usage: ${PN} [-f] [-c] [-q] [-A dir] [-L] [-C] [-- make-flags] +Update some auto-generated files in the Emacs tree. +By default, only does the versioned loaddefs-like files in lisp/. +This requires a build. Passes any non-option args to make (eg -- -j2). +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. +-A: only update autotools files, copying into specified dir. +-L: also update ldefs-boot.el. +-C: start from a clean state. Slower, but more correct. +EOF + exit 1 +} + + +## Defaults. + +force= +commit= +quiet= +clean= +autogendir= # was "autogen" +ldefs_flag=1 +lboot_flag= + +## Parameters. +ldefs_in=lisp/loaddefs.el +ldefs_out=lisp/ldefs-boot.el +sources="configure.ac lib/Makefile.am" +## Files to copy into autogendir. +## Everything: +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 +" +## msdos-only: +genfiles="src/config.in lib/Makefile.in" + +for g in $genfiles; do + basegen="$basegen ${g##*/}" +done + +[ "$basegen" ] || die "internal error" + +tempfile=/tmp/$PN.$$ + +trap "rm -f $tempfile 2> /dev/null" EXIT + + +while getopts ":hcfqA:CL" option ; do + case $option in + (h) usage ;; + + (c) commit=1 ;; + + (f) force=1 ;; + + (q) quiet=1 ;; + + (A) autogendir=$OPTARG + [ -d "$autogendir" ] || die "No autogen directory: $autogendir" + ;; + + (C) clean=1 ;; + + (L) lboot_flag=1 ;; + + (\?) die "Bad option -$OPTARG" ;; + + (:) die "Option -$OPTARG requires an argument" ;; + + (*) die "getopts error" ;; + esac +done +shift $(( --OPTIND )) +OPTIND=1 + + +## Does not work 100% because a lot of Emacs batch output comes on stderr (?). +[ "$quiet" ] && exec 1> /dev/null + + +echo "Running bzr status..." + +bzr status -S ${autogendir:+$sources} ${ldefs_flag:+lisp} >| $tempfile || \ + die "bzr status error for input files" + +## The lisp portion could be more permissive, eg only care about .el files. +while read stat file; do + + case $stat in + M) + echo "Locally modified: $file" + [ "$force" ] || die "There are local modifications" + ;; + + *) die "Unexpected status ($stat) for $file" ;; + esac +done < $tempfile + + +## 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 +} + + +echo "Running autoreconf..." + +autoreconf ${clean:+-f} -i -I m4 2>| $tempfile + +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" + + +## 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 + + +[ "$autogendir" ] && { + + oldpwd=$PWD + + cp $genfiles $autogendir/ + + cd $autogendir || die "cd error for $autogendir" + + echo "Checking status of generated files..." + + 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 + + cd $oldpwd + + commit "generated" $modified || die "bzr commit error" + + exit 0 +} # $autogendir + + +[ "$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..." + + ## Minimize required packages. + ./configure --without-x || die "configure error" +} + + +## 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" + + +## Ignore comment differences. +[ ! "$lboot_flag" ] || \ + diff -q -I '^;' $ldefs_in $ldefs_out || \ + cp $ldefs_in $ldefs_out || die "cp ldefs_boot error" + + +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 + + +cd ../ + + +commit "loaddefs" $modified || die "bzr commit error" + + +exit 0 + +### update_autogen ends here |
