]> git.scripts.mit.edu Git - git.git/commitdiff
Makefile: avoid infinite loop on configure.ac change
authorJeff King <peff@peff.net>
Thu, 21 Feb 2013 06:26:14 +0000 (01:26 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 Feb 2013 07:56:05 +0000 (23:56 -0800)
If you are using autoconf and change the configure.ac, the
Makefile will notice that config.status is older than
configure.ac, and will attempt to rebuild and re-run the
configure script to pick up your changes. The first step in
doing so is to run "make configure". Unfortunately, this
tries to include config.mak.autogen, which depends on
config.status, which depends on configure.ac; so we must
rebuild config.status. Which leads to us running "make
configure", and so on.

It's easy to demonstrate with:

  make configure
  ./configure
  touch configure.ac
  make

We can break this cycle by not re-invoking make to build
"configure", and instead just putting its rules inline into
our config.status rebuild procedure.  We can avoid a copy by
factoring the rules into a make variable.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile

index 8dc2dbc2eeae18b67a5af5322e5c86c8bb102c18..b51b564162ee042bf1e4a96cf84e1fe730d32923 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2159,12 +2159,14 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : unimplemented.sh
        mv $@+ $@
 endif # NO_PYTHON
 
+CONFIGURE_RECIPE = $(RM) configure configure.ac+ && \
+                  sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
+                       configure.ac >configure.ac+ && \
+                  autoconf -o configure configure.ac+ && \
+                  $(RM) configure.ac+
+
 configure: configure.ac GIT-VERSION-FILE
-       $(QUIET_GEN)$(RM) $@ $<+ && \
-       sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
-           $< > $<+ && \
-       autoconf -o $@ $<+ && \
-       $(RM) $<+
+       $(QUIET_GEN)$(CONFIGURE_RECIPE)
 
 ifdef AUTOCONFIGURED
 # We avoid depending on 'configure' here, because it gets rebuilt
@@ -2173,7 +2175,7 @@ ifdef AUTOCONFIGURED
 # do want to recheck when the platform/environment detection logic
 # changes, hence this depends on configure.ac.
 config.status: configure.ac
-       $(QUIET_GEN)$(MAKE) configure && \
+       $(QUIET_GEN)$(CONFIGURE_RECIPE) && \
        if test -f config.status; then \
          ./config.status --recheck; \
        else \