+# Allow the user (or more likely the developer) to ask for a bootstrap
+# of the package.
+#
+# Two issues that must be kept in mind in the implementation below:
+#
+# [1] "make bootstrap" can be invoked before 'configure' is run (and in
+# fact, even before it is created, if we are bootstrapping from a
+# freshly-cloned checkout).
+#
+# [2] When re-bootstrapping an already configured tree, we must ensure
+# that the automatic remake rules for Makefile and company do not
+# kick in, because the tree might be in an inconsistent state (e.g.,
+# we have just switched from 'maint' to 'master', and have the built
+# 'automake' script left from 'maint', but the files 'lib/am/*.am'
+# are from 'master': if 'automake' gets run and uses those files --
+# boom!).
+
+ifdef config-status # Bootstrap from an already-configured tree.
+ # We need the definition of $(srcdir) in the 'bootstrap' rule
+ # below.
+ srcdir := $(shell echo @srcdir@ | $(config-status) --file=-)
+ ifndef srcdir
+ $(error Could not obtain $$(srcdir) from $(config-status))
+ endif
+ # Also, if we are re-bootstrapping an already-configured tree, we
+ # want to re-configure it with the same pre-existing configuration.
+ old-configure-flags := $(shell $(config-status) --config)
+else # Assume we are bootstrapping from an unconfigured srcdir.
+ srcdir := .
+ old-configure-flags :=