Makefile: update scripts when build-time parameters change
Currently, running: make SHELL_PATH=/bin/bash && make SHELL_PATH=/bin/sh will not rebuild any shell scripts in the second command, leading to incorrect results when building from an unclean working directory. This patch introduces a new dependency meta-file to notice the change. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jun 20, 2012 at 14:32 UTC
e4dd89ab98466e4d8e5fdadb0576f7e074992f48
2 files changed
+14
-3
.gitignore
+1
@@ -3,6 +3,7 @@
3
/GIT-LDFLAGS
4
/GIT-GUI-VARS
5
/GIT-PREFIX
6
+/GIT-SCRIPT-DEFINES
7
/GIT-USER-AGENT
8
/GIT-VERSION-FILE
9
/bin-wrappers/
Makefile
+13
-3
@@ -2007,6 +2007,8 @@ common-cmds.h: ./generate-cmdlist.sh command-list.txt
2007
common-cmds.h: $(wildcard Documentation/git-*.txt)
2008
$(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
2009
2010
+SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
2011
+ $(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ)
2012
define cmd_munge_script
2013
$(RM) $@ $@+ && \
2014
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
@@ -2019,12 +2021,20 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
2021
$@.sh >$@+
2022
endef
2023
2022
-$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
2024
+GIT-SCRIPT-DEFINES: FORCE
2025
+ @FLAGS='$(SCRIPT_DEFINES)'; \
2026
+ if test x"$$FLAGS" != x"`cat $@ 2>/dev/null`" ; then \
2027
+ echo 1>&2 " * new script parameters"; \
2028
+ echo "$$FLAGS" >$@; \
2029
+ fi
2030
+
2031
+
2032
+$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh GIT-SCRIPT-DEFINES
2033
$(QUIET_GEN)$(cmd_munge_script) && \
2034
chmod +x $@+ && \
2035
mv $@+ $@
2036
2027
-$(SCRIPT_LIB) : % : %.sh
2037
+$(SCRIPT_LIB) : % : %.sh GIT-SCRIPT-DEFINES
2038
$(QUIET_GEN)$(cmd_munge_script) && \
2039
mv $@+ $@
2040
@@ -2726,7 +2736,7 @@ ifndef NO_TCLTK
2736
$(MAKE) -C git-gui clean
2737
endif
2738
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
2729
- $(RM) GIT-USER-AGENT GIT-PREFIX
2739
+ $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES
2740
2741
.PHONY: all install profile-clean clean strip
2742
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell