{"thread":{"id":"27687","subject":"[PATCH v2] Makefile: Track changes to LDFLAGS and relink when necessary","startedAt":"2011-06-22T10:50:56Z","lastAt":"2011-06-22T10:50:56Z","messageCount":1,"participants":["Fredrik Kuivinen"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"170459","messageId":"1308739856-2726-1-git-send-email-frekui@gmail.com","threadId":"27687","inReplyTo":null,"subject":"[PATCH v2] Makefile: Track changes to LDFLAGS and relink when necessary","fromName":"Fredrik Kuivinen","fromEmail":"frekui@gmail.com","sentAt":"2011-06-22T10:50:56Z","receivedAt":"2011-06-22T10:50:56Z","isPatch":true,"sender":{"key":"frekui@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13770967?v=4"},"body":"Some profiling tools (e.g., google-perftools and mutrace) work by\nlinking in a new library into the executables. When using these tools\nit is convenient to only relink instead of doing a full make clean;\nmake cycle.\n\nThis change complements the auto-detection of changes to CFLAGS that\nwe already have. Tracking of more variables that affect the build can\nbe added when the need arise.\n\nSigned-off-by: Fredrik Kuivinen <frekui@gmail.com>\n---\n .gitignore |    1 +\n Makefile   |   25 +++++++++++++++++--------\n 2 files changed, 18 insertions(+), 8 deletions(-)\n\ndiff --git a/.gitignore b/.gitignore\nindex acffdfa..8572c8c 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -1,5 +1,6 @@\n /GIT-BUILD-OPTIONS\n /GIT-CFLAGS\n+/GIT-LDFLAGS\n /GIT-GUI-VARS\n /GIT-VERSION-FILE\n /bin-wrappers/\ndiff --git a/Makefile b/Makefile\nindex e40ac0c..75b407c 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1706,7 +1706,7 @@ git.sp git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='\"$(GIT_VERSION)\"' \\\n \t'-DGIT_MAN_PATH=\"$(mandir_SQ)\"' \\\n \t'-DGIT_INFO_PATH=\"$(infodir_SQ)\"'\n \n-git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)\n+git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \\\n \t\t$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)\n \n@@ -2004,17 +2004,17 @@ compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \\\n \t-DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR\n endif\n \n-git-%$X: %.o $(GITLIBS)\n+git-%$X: %.o GIT-LDFLAGS $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n \n-git-imap-send$X: imap-send.o $(GITLIBS)\n+git-imap-send$X: imap-send.o GIT-LDFLAGS $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)\n \n-git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o $(GITLIBS)\n+git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(CURL_LIBCURL)\n-git-http-push$X: revision.o http.o http-push.o $(GITLIBS)\n+git-http-push$X: revision.o http.o http-push.o GIT-LDFLAGS $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n \n@@ -2024,7 +2024,7 @@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)\n \tln -s $< $@ 2>/dev/null || \\\n \tcp $< $@\n \n-$(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o $(GITLIBS)\n+$(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n \n@@ -2094,6 +2094,15 @@ GIT-CFLAGS: FORCE\n \t\techo \"$$FLAGS\" >GIT-CFLAGS; \\\n             fi\n \n+TRACK_LDFLAGS = $(subst ','\\'',$(ALL_LDFLAGS))\n+\n+GIT-LDFLAGS: FORCE\n+\t@FLAGS='$(TRACK_LDFLAGS)'; \\\n+\t    if test x\"$$FLAGS\" != x\"`cat GIT-LDFLAGS 2>/dev/null`\" ; then \\\n+\t\techo 1>&2 \"    * new link flags\"; \\\n+\t\techo \"$$FLAGS\" >GIT-LDFLAGS; \\\n+            fi\n+\n # We need to apply sq twice, once to protect from the shell\n # that runs GIT-BUILD-OPTIONS, and then again to protect it\n # and the first level quoting from the shell that runs \"echo\".\n@@ -2165,7 +2174,7 @@ test-svn-fe$X: vcs-svn/lib.a\n \n .PRECIOUS: $(TEST_OBJS)\n \n-test-%$X: test-%.o $(GITLIBS)\n+test-%$X: test-%.o GIT-LDFLAGS $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n \n check-sha1:: test-sha1$X\n@@ -2375,7 +2384,7 @@ ifndef NO_TCLTK\n \t$(MAKE) -C gitk-git clean\n \t$(MAKE) -C git-gui clean\n endif\n-\t$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS\n+\t$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS\n \n .PHONY: all install clean strip\n .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell\n-- \n1.7.5.3.368.g8b1b7.dirty\n"}]}