Makefile: avoid infinite loop on configure.ac change

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>

Jeff King committed Feb 21, 2013 at 01:26 UTC 7f1b69763272f9d07e612309f53190da0c97ca70
1 file changed +8 -6
Makefile
+8 -6
@@ -2159,12 +2159,14 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : unimplemented.sh
2159 mv $@+ $@
2160 endif # NO_PYTHON
2161
2162 +CONFIGURE_RECIPE = $(RM) configure configure.ac+ && \
2163 + sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
2164 + configure.ac >configure.ac+ && \
2165 + autoconf -o configure configure.ac+ && \
2166 + $(RM) configure.ac+
2167 +
2168 configure: configure.ac GIT-VERSION-FILE
2163 - $(QUIET_GEN)$(RM) $@ $<+ && \
2164 - sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
2165 - $< > $<+ && \
2166 - autoconf -o $@ $<+ && \
2167 - $(RM) $<+
2169 + $(QUIET_GEN)$(CONFIGURE_RECIPE)
2170
2171 ifdef AUTOCONFIGURED
2172 # We avoid depending on 'configure' here, because it gets rebuilt
@@ -2173,7 +2175,7 @@ ifdef AUTOCONFIGURED
2175 # do want to recheck when the platform/environment detection logic
2176 # changes, hence this depends on configure.ac.
2177 config.status: configure.ac
2176 - $(QUIET_GEN)$(MAKE) configure && \
2178 + $(QUIET_GEN)$(CONFIGURE_RECIPE) && \
2179 if test -f config.status; then \
2180 ./config.status --recheck; \
2181 else \