Makefile: detect when PYTHON_PATH changes

When make is run, the python scripts are created from *.py files that are changed to use the python given by PYTHON_PATH. And PYTHON_PATH is set by default to /usr/bin/python on Linux. This is nice except when you run make another time setting a different PYTHON_PATH, because, as the python scripts have already been created, make finds nothing to do. The goal of this patch is to detect when the PYTHON_PATH changes and to create the python scripts again when this happens. To do that we use the same trick that is done to track other variables like prefix, flags, tcl/tk path and shell path. We update a GIT-PYTHON-VARS file with the PYTHON_PATH and check if it changed. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Acked-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Dec 18, 2012 at 16:26 UTC 96a4647fca54031974cd6ad1971e85848a5269fd
2 files changed +15 -2
.gitignore
+1
@@ -2,6 +2,7 @@
2 /GIT-CFLAGS
3 /GIT-LDFLAGS
4 /GIT-PREFIX
5 +/GIT-PYTHON-VARS
6 /GIT-SCRIPT-DEFINES
7 /GIT-USER-AGENT
8 /GIT-VERSION-FILE
Makefile
+14 -2
@@ -2233,7 +2233,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
2233 endif # NO_PERL
2234
2235 ifndef NO_PYTHON
2236 -$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX
2236 +$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS
2237 $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
2238 $(QUIET_GEN)$(RM) $@ $@+ && \
2239 INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
@@ -2608,6 +2608,18 @@ ifdef GIT_PERF_MAKE_OPTS
2608 @echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_MAKE_OPTS)))'\' >>$@
2609 endif
2610
2611 +### Detect Python interpreter path changes
2612 +ifndef NO_PYTHON
2613 +TRACK_PYTHON = $(subst ','\'',-DPYTHON_PATH='$(PYTHON_PATH_SQ)')
2614 +
2615 +GIT-PYTHON-VARS: FORCE
2616 + @VARS='$(TRACK_PYTHON)'; \
2617 + if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
2618 + echo 1>&2 " * new Python interpreter location"; \
2619 + echo "$$VARS" >$@; \
2620 + fi
2621 +endif
2622 +
2623 test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
2624
2625 all:: $(TEST_PROGRAMS) $(test_bindir_programs)
@@ -2883,7 +2895,7 @@ ifndef NO_TCLTK
2895 $(MAKE) -C git-gui clean
2896 endif
2897 $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
2886 - $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES
2898 + $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES GIT-PYTHON-VARS
2899
2900 .PHONY: all install profile-clean clean strip
2901 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell