Skip to content

Commit 184cb4d

Browse files
committed
Merge branch 'fk/relink-upon-ldflags-update' into maint
* fk/relink-upon-ldflags-update: Makefile: Track changes to LDFLAGS and relink when necessary
2 parents d5c756e + d9a25fc commit 184cb4d

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/GIT-BUILD-OPTIONS
22
/GIT-CFLAGS
3+
/GIT-LDFLAGS
34
/GIT-GUI-VARS
45
/GIT-VERSION-FILE
56
/bin-wrappers/

Makefile

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,7 @@ git.sp git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='"$(GIT_VERSION)"' \
17061706
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
17071707
'-DGIT_INFO_PATH="$(infodir_SQ)"'
17081708

1709-
git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
1709+
git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
17101710
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
17111711
$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
17121712

@@ -2004,17 +2004,17 @@ compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \
20042004
-DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR
20052005
endif
20062006

2007-
git-%$X: %.o $(GITLIBS)
2007+
git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
20082008
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
20092009

2010-
git-imap-send$X: imap-send.o $(GITLIBS)
2010+
git-imap-send$X: imap-send.o GIT-LDFLAGS $(GITLIBS)
20112011
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
20122012
$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)
20132013

2014-
git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o $(GITLIBS)
2014+
git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
20152015
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
20162016
$(LIBS) $(CURL_LIBCURL)
2017-
git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
2017+
git-http-push$X: revision.o http.o http-push.o GIT-LDFLAGS $(GITLIBS)
20182018
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
20192019
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
20202020

@@ -2024,7 +2024,7 @@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
20242024
ln -s $< $@ 2>/dev/null || \
20252025
cp $< $@
20262026

2027-
$(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o $(GITLIBS)
2027+
$(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)
20282028
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
20292029
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
20302030

@@ -2094,6 +2094,15 @@ GIT-CFLAGS: FORCE
20942094
echo "$$FLAGS" >GIT-CFLAGS; \
20952095
fi
20962096

2097+
TRACK_LDFLAGS = $(subst ','\'',$(ALL_LDFLAGS))
2098+
2099+
GIT-LDFLAGS: FORCE
2100+
@FLAGS='$(TRACK_LDFLAGS)'; \
2101+
if test x"$$FLAGS" != x"`cat GIT-LDFLAGS 2>/dev/null`" ; then \
2102+
echo 1>&2 " * new link flags"; \
2103+
echo "$$FLAGS" >GIT-LDFLAGS; \
2104+
fi
2105+
20972106
# We need to apply sq twice, once to protect from the shell
20982107
# that runs GIT-BUILD-OPTIONS, and then again to protect it
20992108
# and the first level quoting from the shell that runs "echo".
@@ -2165,7 +2174,7 @@ test-svn-fe$X: vcs-svn/lib.a
21652174

21662175
.PRECIOUS: $(TEST_OBJS)
21672176

2168-
test-%$X: test-%.o $(GITLIBS)
2177+
test-%$X: test-%.o GIT-LDFLAGS $(GITLIBS)
21692178
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
21702179

21712180
check-sha1:: test-sha1$X
@@ -2375,7 +2384,7 @@ ifndef NO_TCLTK
23752384
$(MAKE) -C gitk-git clean
23762385
$(MAKE) -C git-gui clean
23772386
endif
2378-
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
2387+
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
23792388

23802389
.PHONY: all install clean strip
23812390
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell

0 commit comments

Comments
 (0)