# [PATCH] Makefile: limit specifying -DGIT_USER_AGENT=... to keep ccache efficient

2 messages from 2012-06-24 to 2012-06-24. Participants: Nguyễn Thái Ngọc Duy, Nguyen Thai Ngoc Duy.
Thread: https://gitlist.dev/t/30884

## Nguyễn Thái Ngọc Duy, 2012-06-24 12:37

Subject: [PATCH] Makefile: limit specifying -DGIT_USER_AGENT=... to keep ccache efficient
Message-ID: <1340541457-9056-1-git-send-email-pclouds@gmail.com>
URL: https://gitlist.dev/e/1340541457-9056-1-git-send-email-pclouds%40gmail.com

```
GIT_USER_AGENT changes as HEAD changes. Defining it in BASIC_FLAGS
means every time HEAD changes, the compiling options for every object
file is changed, which defeats the purpose of using ccache.

As version.c is the only file that uses this definition, limit
defining only when compiling this file.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Makefile |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index f62ca2a..b3ce00d 100644
--- a/Makefile
+++ b/Makefile
@@ -1929,7 +1929,6 @@ endif
 GIT_USER_AGENT_SQ = $(subst ','\'',$(GIT_USER_AGENT))
 GIT_USER_AGENT_CQ = "$(subst ",\",$(subst \,\\,$(GIT_USER_AGENT)))"
 GIT_USER_AGENT_CQ_SQ = $(subst ','\'',$(GIT_USER_AGENT_CQ))
-BASIC_CFLAGS += -DGIT_USER_AGENT='$(GIT_USER_AGENT_CQ_SQ)'
 
 ifdef DEFAULT_HELP_FORMAT
 BASIC_CFLAGS += -DDEFAULT_HELP_FORMAT='"$(DEFAULT_HELP_FORMAT)"'
@@ -2000,7 +1999,8 @@ builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
 	'-DGIT_INFO_PATH="$(infodir_SQ)"'
 
 version.sp version.s version.o: EXTRA_CPPFLAGS = \
-	'-DGIT_VERSION="$(GIT_VERSION)"'
+	'-DGIT_VERSION="$(GIT_VERSION)"' \
+	'-DGIT_USER_AGENT="$(GIT_USER_AGENT)"'
 
 $(BUILT_INS): git$X
 	$(QUIET_BUILT_IN)$(RM) $@ && \
-- 
1.7.8

```

## Nguyen Thai Ngoc Duy, 2012-06-24 14:56

Subject: Re: [PATCH] Makefile: limit specifying -DGIT_USER_AGENT=... to keep ccache efficient
Message-ID: <CACsJy8BJmDy4pXoKM2eHhh-R0BvTxgfYTn87qZsGffEfpOQDuA@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8BJmDy4pXoKM2eHhh-R0BvTxgfYTn87qZsGffEfpOQDuA%40mail.gmail.com
In-Reply-To: <1340541457-9056-1-git-send-email-pclouds@gmail.com>

```
On Sun, Jun 24, 2012 at 7:37 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> GIT_USER_AGENT changes as HEAD changes. Defining it in BASIC_FLAGS
> means every time HEAD changes, the compiling options for every object
> file is changed, which defeats the purpose of using ccache.
>
> As version.c is the only file that uses this definition, limit
> defining only when compiling this file.

Uhm.. something like this is in jk/version-string-dependency already.
Sorry for the noise.
-- 
Duy

```
