Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-02-15 14:38:28 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-03-02 10:38:37 +0300
commit533f34359bb9c5964c0b36cce1f86a309b15e84d (patch)
tree83782e88ad28cc1777b626c6234518c4139d6700
parent4e5774f37ab8581cf0a988ffca97a6252078ddc8 (diff)
Makefile: Test variables dynamically to make targets reusable
When building Git we define both the GIT_PATCHES and GIT_EXTRA_VERSION variables to influence the way Git is built. This is currently done via `ifdef` conditionals, which are notably evaluated at the time of parsing the Makefile. As a consequence, even if their values change at a later point, we'll already have stripped or retained the code snippets they're guarding because they won't be reevaluated. This is not an issue currently, but it is going to be an issue when we ruse the target to build multiple different Git versions. Prepare for this by dynamically testing whether those variables are set or not as part of the recipe itself.
-rw-r--r--Makefile10
1 files changed, 2 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 6dda56e5e..7f508dcb5 100644
--- a/Makefile
+++ b/Makefile
@@ -623,17 +623,11 @@ ${GIT_SOURCE_DIR}/Makefile: ${DEPENDENCY_DIR}/git.version
${Q}${GIT} -C "${GIT_SOURCE_DIR}" fetch --depth 1 ${GIT_QUIET} origin ${GIT_VERSION}
${Q}${GIT} -C "${GIT_SOURCE_DIR}" reset --hard
${Q}${GIT} -C "${GIT_SOURCE_DIR}" checkout ${GIT_QUIET} --detach FETCH_HEAD
-ifdef GIT_PATCHES
- ${Q}${GIT} -C "${GIT_SOURCE_DIR}" apply $(addprefix "${SOURCE_DIR}"/_support/git-patches/,${GIT_PATCHES})
-endif
+ ${Q}if test -n "${GIT_PATCHES}"; then ${GIT} -C "${GIT_SOURCE_DIR}" apply $(addprefix "${SOURCE_DIR}"/_support/git-patches/,${GIT_PATCHES}); fi
@ # We're writing the version into the "version" file in Git's own source
@ # directory. If it exists, Git's Makefile will pick it up and use it as
@ # the version instead of auto-detecting via git-describe(1).
-ifdef GIT_EXTRA_VERSION
- ${Q}echo ${GIT_VERSION}.${GIT_EXTRA_VERSION} >"${GIT_SOURCE_DIR}"/version
-else
- ${Q}rm -f "${GIT_SOURCE_DIR}"/version
-endif
+ ${Q}if test -n "${GIT_EXTRA_VERSION}"; then echo ${GIT_VERSION}.${GIT_EXTRA_VERSION} >"${GIT_SOURCE_DIR}"/version; else rm -f "${GIT_SOURCE_DIR}"/version; fi
${Q}touch $@
${GIT_SOURCE_DIR}/%: ${GIT_SOURCE_DIR}/Makefile