From: Fredrik Kuivinen Date: Wed, 22 Jun 2011 10:50:56 +0000 (+0200) Subject: Makefile: Track changes to LDFLAGS and relink when necessary X-Git-Tag: v1.7.6.1~29^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d9a25fca5fc01ab4e2e114795c442906bc67de26;p=git.git Makefile: Track changes to LDFLAGS and relink when necessary Some profiling tools (e.g., google-perftools and mutrace) work by linking in a new library into the executables. When using these tools it is convenient to only relink instead of doing a full make clean; make cycle. This change complements the auto-detection of changes to CFLAGS that we already have. Tracking of more variables that affect the build can be added when the need arise. Signed-off-by: Fredrik Kuivinen Signed-off-by: Junio C Hamano --- diff --git a/.gitignore b/.gitignore index acffdfaae..8572c8c0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /GIT-BUILD-OPTIONS /GIT-CFLAGS +/GIT-LDFLAGS /GIT-GUI-VARS /GIT-VERSION-FILE /bin-wrappers/ diff --git a/Makefile b/Makefile index e40ac0c7f..75b407c27 100644 --- a/Makefile +++ b/Makefile @@ -1706,7 +1706,7 @@ git.sp git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='"$(GIT_VERSION)"' \ '-DGIT_MAN_PATH="$(mandir_SQ)"' \ '-DGIT_INFO_PATH="$(infodir_SQ)"' -git$X: git.o $(BUILTIN_OBJS) $(GITLIBS) +git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \ $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS) @@ -2004,17 +2004,17 @@ compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \ -DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR endif -git-%$X: %.o $(GITLIBS) +git-%$X: %.o GIT-LDFLAGS $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) -git-imap-send$X: imap-send.o $(GITLIBS) +git-imap-send$X: imap-send.o GIT-LDFLAGS $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO) -git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o $(GITLIBS) +git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(LIBS) $(CURL_LIBCURL) -git-http-push$X: revision.o http.o http-push.o $(GITLIBS) +git-http-push$X: revision.o http.o http-push.o GIT-LDFLAGS $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) @@ -2024,7 +2024,7 @@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY) ln -s $< $@ 2>/dev/null || \ cp $< $@ -$(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o $(GITLIBS) +$(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) @@ -2094,6 +2094,15 @@ GIT-CFLAGS: FORCE echo "$$FLAGS" >GIT-CFLAGS; \ fi +TRACK_LDFLAGS = $(subst ','\'',$(ALL_LDFLAGS)) + +GIT-LDFLAGS: FORCE + @FLAGS='$(TRACK_LDFLAGS)'; \ + if test x"$$FLAGS" != x"`cat GIT-LDFLAGS 2>/dev/null`" ; then \ + echo 1>&2 " * new link flags"; \ + echo "$$FLAGS" >GIT-LDFLAGS; \ + fi + # We need to apply sq twice, once to protect from the shell # that runs GIT-BUILD-OPTIONS, and then again to protect it # and the first level quoting from the shell that runs "echo". @@ -2165,7 +2174,7 @@ test-svn-fe$X: vcs-svn/lib.a .PRECIOUS: $(TEST_OBJS) -test-%$X: test-%.o $(GITLIBS) +test-%$X: test-%.o GIT-LDFLAGS $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS) check-sha1:: test-sha1$X @@ -2375,7 +2384,7 @@ ifndef NO_TCLTK $(MAKE) -C gitk-git clean $(MAKE) -C git-gui clean endif - $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS + $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS .PHONY: all install clean strip .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell