Skip to content

Commit e4dd89a

Browse files
peffgitster
authored andcommitted
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>
1 parent 2b9391b commit e4dd89a

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/GIT-LDFLAGS
44
/GIT-GUI-VARS
55
/GIT-PREFIX
6+
/GIT-SCRIPT-DEFINES
67
/GIT-USER-AGENT
78
/GIT-VERSION-FILE
89
/bin-wrappers/

Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,6 +2007,8 @@ common-cmds.h: ./generate-cmdlist.sh command-list.txt
20072007
common-cmds.h: $(wildcard Documentation/git-*.txt)
20082008
$(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
20092009

2010+
SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
2011+
$(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ)
20102012
define cmd_munge_script
20112013
$(RM) $@ $@+ && \
20122014
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
@@ -2019,12 +2021,20 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
20192021
$@.sh >$@+
20202022
endef
20212023

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
20232033
$(QUIET_GEN)$(cmd_munge_script) && \
20242034
chmod +x $@+ && \
20252035
mv $@+ $@
20262036

2027-
$(SCRIPT_LIB) : % : %.sh
2037+
$(SCRIPT_LIB) : % : %.sh GIT-SCRIPT-DEFINES
20282038
$(QUIET_GEN)$(cmd_munge_script) && \
20292039
mv $@+ $@
20302040

@@ -2726,7 +2736,7 @@ ifndef NO_TCLTK
27262736
$(MAKE) -C git-gui clean
27272737
endif
27282738
$(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
27302740

27312741
.PHONY: all install profile-clean clean strip
27322742
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell

0 commit comments

Comments
 (0)