Improve robustness of 'make bootstrap'.
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 10 Sep 2012 01:03:27 +0000 (18:03 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 10 Sep 2012 01:03:27 +0000 (18:03 -0700)
Run autogen.sh after bootstrap-clean, to avoid bzr pull issues.
* INSTALL, README: Document autogen.sh.
* Makefile.in (Makefile): Mark it as precious, since it's updated
atomically.
(MAKE_CONFIG_STATUS): New macro.
(config.status, bootstrap): Use it.  This causes 'make bootstrap'
to run config.status with the --recheck option, which is more
appropriate for a bootstrap.
(bootstrap): Run autogen.sh right after cleaning.  Don't worry
about failures due to missing tools.
* autogen.sh: Exit with status 101 when failing due to missing tools.
* make-dist: Distribute autogen.sh.

Fixes: debbugs:12376

ChangeLog
INSTALL
Makefile.in
README
autogen.sh
make-dist

index 198670e..7d1c19a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2012-09-10  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Improve robustness of 'make bootstrap' (Bug#12376).
+       Run autogen.sh after bootstrap-clean, to avoid bzr pull issues.
+       * INSTALL, README: Document autogen.sh.
+       * Makefile.in (Makefile): Mark it as precious, since it's updated
+       atomically.
+       (MAKE_CONFIG_STATUS): New macro.
+       (config.status, bootstrap): Use it.  This causes 'make bootstrap'
+       to run config.status with the --recheck option, which is more
+       appropriate for a bootstrap.
+       (bootstrap): Run autogen.sh right after cleaning.  Don't worry
+       about failures due to missing tools.
+       * autogen.sh: Exit with status 101 when failing due to missing tools.
+       * make-dist: Distribute autogen.sh.
+
 2012-09-09  Paul Eggert  <eggert@cs.ucla.edu>
 
        Assume C89 or later for math functions (Bug#12381).
diff --git a/INSTALL b/INSTALL
index f0cf5d6..4716bbe 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -695,9 +695,9 @@ running the `configure' program, you have to perform the following steps.
 corresponding `Makefile.in' files.  This isn't so hard, just a matter
 of editing in appropriate substitutions for the @...@ constructs.
 
-The `configure' script is built from `configure.ac' by the `autoconf'
-program.  You need at least the version of autoconf specified in the
-AC_PREREQ(...) command to rebuild `configure' from `configure.ac'.
+The `configure' script is built from `configure.ac' by the
+`autogen.sh' script, which checks that `autoconf' and other build
+tools are sufficiently up to date and then runs the build tools.
 
 BUILDING GNU EMACS BY HAND
 
index 122a35d..800f116 100644 (file)
@@ -360,15 +360,17 @@ $(MAKEFILE_NAME): config.status $(srcdir)/src/config.in \
           $(srcdir)/Makefile.in $(SUBDIR_MAKEFILES_IN)
        ./config.status
 
-# Don't erase config.status if make is interrupted while refreshing it.
-.PRECIOUS: config.status
+# Don't erase these files if make is interrupted while refreshing them.
+.PRECIOUS: Makefile config.status
 
-config.status: ${srcdir}/configure ${srcdir}/lisp/version.el
+MAKE_CONFIG_STATUS = \
        if [ -x ./config.status ]; then \
            ./config.status --recheck;  \
        else                            \
            ./configure $(CONFIGURE_FLAGS); \
        fi
+config.status: ${srcdir}/configure ${srcdir}/lisp/version.el
+       $(MAKE_CONFIG_STATUS)
 
 AUTOCONF_INPUTS = $(srcdir)/configure.ac $(srcdir)/aclocal.m4
 
@@ -383,6 +385,10 @@ AUTOMAKE_INPUTS = $(srcdir)/aclocal.m4 $(srcdir)/lib/Makefile.am \
   $(srcdir)/lib/gnulib.mk
 $(srcdir)/lib/Makefile.in: $(AUTOMAKE_INPUTS)
        cd $(srcdir) && automake --gnu -a -c lib/Makefile
+
+# Regenerate files that this makefile would have made, if this makefile
+# had been built by Automake.  The name 'am--refresh' is for
+# compatibility with subsidiary Automake-generated makefiles.
 am--refresh: $(srcdir)/aclocal.m4 $(srcdir)/configure $(srcdir)/src/config.in
 .PHONY: am--refresh
 
@@ -776,8 +782,6 @@ bootstrap-clean: FRC
        (cd lisp;     $(MAKE) $(MFLAGS) bootstrap-clean)
        [ ! -f config.log ] || mv -f config.log config.log~
        ${top_bootclean}
-## configure; make bootstrap replaces the real config.log from configure
-## with the truncated one from config.status.  The former is more useful.
 
 ### `maintainer-clean'
 ###      Delete everything from the current directory that can be
@@ -883,14 +887,14 @@ dvi:
 
 .PHONY: bootstrap
 
-## configure; make bootstrap replaces the real config.log from configure
-## with the truncated one from config.status.  The former is more useful.
+# Bootstrapping does the following:
+#  * Remove files to start from a clean slate.
+#  * Run autogen.sh, but don't worry about exit status 101 (missing tools).
+#  * Build Makefile, to build the build procedure itself.
+#  * Do the actual build.
 bootstrap: bootstrap-clean FRC
-       if [ -x ./config.status ]; then           \
-           ./config.status;                      \
-       else                                      \
-           ./configure $(CONFIGURE_FLAGS);       \
-       fi
+       cd $(srcdir) && { ./autogen.sh || test $$? -eq 101; }
+       $(MAKE_CONFIG_STATUS)
        $(MAKE) $(MFLAGS) info all
 
 .PHONY: check-declare
diff --git a/README b/README
index a11935e..2c50c5b 100644 (file)
--- a/README
+++ b/README
@@ -41,9 +41,14 @@ The file `configure.ac' is the input used by the autoconf program to
 construct the `configure' script.  Since Emacs has some configuration
 requirements that autoconf can't meet directly, and for historical
 reasons, `configure.ac' uses an unholy marriage of custom-baked
-configuration code and autoconf macros.  If you want to rebuild
-`configure' from `configure.ac', you will need to install a recent
-version of autoconf and GNU m4.
+configuration code and autoconf macros.
+
+The shell script `autogen.sh' generates 'configure' and other files by
+running the GNU build tools autoconf and automake, which in turn use
+GNU m4 and Perl.  If you want to use it, you will need to install
+recent versions of these build tools.  This should be needed only if
+you edit files like `configure.ac' that specify Emacs's autobuild
+procedure.
 
 The file `Makefile.in' is a template used by `configure' to create
 `Makefile'.
index 9cfaa40..dc8d53e 100755 (executable)
@@ -201,7 +201,7 @@ This is not recommended - see the comments in \`copy_autogen'.
 Please report any problems with this script to bug-gnu-emacs@gnu.org .
 EOF
 
-    exit 1
+    exit 101 # Exit status 101 means tools were missing.
 fi
 
 echo "Your system has the required tools, running autoreconf..."
index b157d9a..28d2ec1 100755 (executable)
--- a/make-dist
+++ b/make-dist
@@ -273,7 +273,7 @@ mkdir ${tempdir}
 ### README while the rest of the tar file is still unpacking.  Whoopee.
 echo "Making links to top-level files"
 ln INSTALL README BUGS ${tempdir}
-ln ChangeLog Makefile.in configure configure.ac ${tempdir}
+ln ChangeLog Makefile.in autogen.sh configure configure.ac ${tempdir}
 ln config.bat make-dist .dir-locals.el ${tempdir}
 ln aclocal.m4 ${tempdir}