Makefile: introduce template for GIT-VERSION-GEN
Introduce a new template to call GIT-VERSION-GEN. This will allow us to iterate on how exactly the script is called in subsequent commits without having to adapt all call sites every time. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Dec 20, 2024 at 20:44 UTC
114494ae2c6f473dd9c9745a9b4fc6c55b70f2e8
3 files changed
+13
-5
Documentation/Makefile
+2
-2
@@ -211,10 +211,10 @@ XMLTO_EXTRA += --skip-validation
211
XMLTO_EXTRA += -x manpage.xsl
212
213
asciidoctor-extensions.rb: asciidoctor-extensions.rb.in FORCE
214
- $(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ../GIT-VERSION-GEN "$(shell pwd)/.." $< $@
214
+ $(QUIET_GEN)$(call version_gen,"$(shell pwd)/..",$<,$@)
215
else
216
asciidoc.conf: asciidoc.conf.in FORCE
217
- $(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ../GIT-VERSION-GEN "$(shell pwd)/.." $< $@
217
+ $(QUIET_GEN)$(call version_gen,"$(shell pwd)/..",$<,$@)
218
endif
219
220
ASCIIDOC_DEPS += docinfo.html
Makefile
+3
-3
@@ -593,7 +593,7 @@ include shared.mak
593
594
GIT-VERSION-FILE: FORCE
595
@OLD=$$(cat $@ 2>/dev/null || :) && \
596
- $(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" GIT-VERSION-FILE.in $@ && \
596
+ $(call version_gen,"$(shell pwd)",GIT-VERSION-FILE.in,$@) && \
597
NEW=$$(cat $@ 2>/dev/null || :) && \
598
if test "$$OLD" != "$$NEW"; then echo "$$NEW" >&2; fi
599
-include GIT-VERSION-FILE
@@ -2509,7 +2509,7 @@ pager.sp pager.s pager.o: EXTRA_CPPFLAGS = \
2509
-DPAGER_ENV='$(PAGER_ENV_CQ_SQ)'
2510
2511
version-def.h: version-def.h.in GIT-VERSION-GEN GIT-VERSION-FILE GIT-USER-AGENT
2512
- $(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" $< $@
2512
+ $(QUIET_GEN)$(call version_gen,"$(shell pwd)",$<,$@)
2513
2514
version.sp version.s version.o: version-def.h
2515
@@ -2550,7 +2550,7 @@ $(SCRIPT_SH_GEN) $(SCRIPT_LIB) : % : %.sh generate-script.sh GIT-BUILD-OPTIONS G
2550
mv $@+ $@
2551
2552
git.rc: git.rc.in GIT-VERSION-GEN GIT-VERSION-FILE
2553
- $(QUIET_GEN)$(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" $< $@
2553
+ $(QUIET_GEN)$(call version_gen,"$(shell pwd)",$<,$@)
2554
2555
git.res: git.rc GIT-PREFIX
2556
$(QUIET_RC)$(RC) -i $< -o $@
shared.mak
+8
@@ -116,3 +116,11 @@ endef
116
define libpath_template
117
-L$(1) $(if $(filter-out -L,$(CC_LD_DYNPATH)),$(CC_LD_DYNPATH)$(1))
118
endef
119
+
120
+# Populate build information into a file via GIT-VERSION-GEN. Requires the
121
+# absolute path to the root source directory as well as input and output files
122
+# as arguments, in that order.
123
+define version_gen
124
+GIT_USER_AGENT="$(GIT_USER_AGENT)" \
125
+$(SHELL_PATH) "$(1)/GIT-VERSION-GEN" "$(1)" "$(2)" "$(3)"
126
+endef