]> code.delx.au - gnu-emacs/blobdiff - autogen/update_autogen
Fix bug #13734 with errors in lisp.h macro expansion.
[gnu-emacs] / autogen / update_autogen
index 0b26dd27d2b5a3c9c59424f08dcc6643476337f2..264d8d83d6d011fd7f7cf967d85fd9ab5d888436 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 ### update_autogen - update the generated files in Emacs autogen/ directory
 
-## Copyright (C) 2011  Free Software Foundation, Inc.
+## Copyright (C) 2011-2013 Free Software Foundation, Inc.
 
 ## Author: Glenn Morris <rgm@gnu.org>
 
 ## 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.
+##
+## With the -l option, it also updates the versioned loaddefs-like
+## files in lisp/.  These include ldefs-boot, cl-loaddefs, rmail, etc.
 
 ### Code:
 
-function die ()                 # write error to stderr and exit
+die ()                 # write error to stderr and exit
 {
     [ $# -gt 0 ] && echo "$PN: $@" >&2
     exit 1
@@ -45,16 +48,20 @@ cd ../
 [ -d autogen ] || die "Could not locate autogen directory"
 
 
-function usage ()
+usage ()
 {
     cat 1>&2 <<EOF
-Usage: ${PN} [-f] [-c] [-q]
+Usage: ${PN} [-f] [-c] [-q] [-l [-L]] [-C] [-- make-flags]
 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.
+-l: also update the versioned loaddefs-like files in lisp/.
+This requires a build.  Passes any non-option args to make (eg -- -j2).
+-L: also update ldefs-boot.el.
+-C: start from a clean state.  Slower, but more correct.
 EOF
     exit 1
 }
@@ -65,10 +72,19 @@ EOF
 force=
 commit=
 quiet=
+clean=
+ldefs_flag=
+lboot_flag=
 
 ## Parameters.
-sources="configure.in lib/Makefile.am"
-genfiles="configure aclocal.m4 src/config.in lib/Makefile.in"
+ldefs_in=lisp/loaddefs.el
+ldefs_out=lisp/ldefs-boot.el
+sources="configure.ac lib/Makefile.am"
+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
+"
 
 for g in $genfiles; do
     basegen="$basegen ${g##*/}"
@@ -81,7 +97,7 @@ tempfile=/tmp/$PN.$$
 trap "rm -f $tempfile 2> /dev/null" EXIT
 
 
-while getopts ":hcfq" option ; do
+while getopts ":hcflqCL" option ; do
     case $option in
         (h) usage ;;
 
@@ -89,8 +105,14 @@ while getopts ":hcfq" option ; do
 
         (f) force=1 ;;
 
+        (l) ldefs_flag=1 ;;
+
         (q) quiet=1 ;;
 
+        (C) clean=1 ;;
+
+        (L) lboot_flag=1 ;;
+
         (\?) die "Bad option -$OPTARG" ;;
 
         (:) die "Option -$OPTARG requires an argument" ;;
@@ -101,25 +123,22 @@ done
 shift $(( --OPTIND ))
 OPTIND=1
 
-[ $# -eq 0 ] || die "Wrong number of arguments"
 
-
-function msg ()
-{
-    [ "$quiet" ] && return 0
-    echo "$@"
-}                               # function msg
+## Does not work 100% because a lot of Emacs batch output comes on stderr (?).
+[ "$quiet" ] && exec 1> /dev/null
 
 
-msg "Running bzr status..."
+echo "Running bzr status..."
 
-bzr status -S $sources >| $tempfile || die "bzr status error for sources"
+bzr status -S $sources ${ldefs_flag:+lisp} >| $tempfile || \
+    die "bzr status error for sources"
 
+## The lisp portion could be more permissive, eg only care about .el files.
 while read stat file; do
 
     case $stat in
         M)
-            msg "Locally modified: $file"
+            echo "Locally modified: $file"
             [ "$force" ] || die "There are local modifications"
             ;;
 
@@ -128,9 +147,32 @@ while read stat file; do
 done < $tempfile
 
 
-msg "Running autoreconf..."
+## 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
+}
 
-autoreconf -I m4 || die "autoreconf error"
+
+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"
 
 
 cp $genfiles autogen/
@@ -138,6 +180,7 @@ cp $genfiles autogen/
 
 cd autogen
 
+echo "Checking status of generated files..."
 
 bzr status -S $basegen >| $tempfile || \
     die "bzr status error for generated files"
@@ -154,30 +197,114 @@ while read stat file; do
 done < $tempfile
 
 
-[ "$modified" ] || {
-    msg "No files were modified"
-    exit 0
+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..."
+
+    ## Minimize required packages.
+    ./configure --without-x || die "configure error"
 }
 
-msg "Modified file(s): $modified"
 
-[ "$commit" ] || exit 0
+## Build the minimum needed to get the autoloads.
+echo "Running lib/ make..."
 
+make -C lib "$@" all || die "make lib error"
 
-msg "Committing..."
 
-## bzr status output is annoyingly always relative to top-level, not PWD.
-cd ../
+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"
+
 
-opt=
-[ "$quiet" ] || opt=-q
+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 ../
 
-bzr commit $opt -m "Auto-commit of generated files." $modified || \
-    die "bzr commit error"
 
+commit "loaddefs" $modified || die "bzr commit error"
 
-msg "Committed files: $modified"
 
-exit
+exit 0
 
 ### update_autogen ends here