Skip to content

Commit be1dbd0

Browse files
peffgitster
authored andcommitted
Makefile: split prefix flags from GIT-CFLAGS
Most of the build targets do not care about the setting of $prefix (or its derivative variables), but will be rebuilt if the prefix changes. For most setups this doesn't matter (they set prefix once and never change it), but for a setup which puts each branch or version in its own prefix, this unnecessarily causes a full rebuild whenever the branc is changed. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 33ddbcb commit be1dbd0

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/GIT-CFLAGS
33
/GIT-LDFLAGS
44
/GIT-GUI-VARS
5+
/GIT-PREFIX
56
/GIT-USER-AGENT
67
/GIT-VERSION-FILE
78
/bin-wrappers/

Makefile

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,7 @@ shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
19731973
strip: $(PROGRAMS) git$X
19741974
$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
19751975

1976+
git.sp git.s git.o: GIT-PREFIX
19761977
git.sp git.s git.o: EXTRA_CPPFLAGS = \
19771978
'-DGIT_HTML_PATH="$(htmldir_SQ)"' \
19781979
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
@@ -1984,7 +1985,7 @@ git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
19841985

19851986
help.sp help.s help.o: common-cmds.h
19861987

1987-
builtin/help.sp builtin/help.s builtin/help.o: common-cmds.h
1988+
builtin/help.sp builtin/help.s builtin/help.o: common-cmds.h GIT-PREFIX
19881989
builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
19891990
'-DGIT_HTML_PATH="$(htmldir_SQ)"' \
19901991
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
@@ -2031,7 +2032,7 @@ $(SCRIPT_LIB) : % : %.sh
20312032
ifndef NO_PERL
20322033
$(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
20332034

2034-
perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
2035+
perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL
20352036
$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
20362037

20372038
$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
@@ -2075,7 +2076,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
20752076
endif # NO_PERL
20762077

20772078
ifndef NO_PYTHON
2078-
$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS
2079+
$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX
20792080
$(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
20802081
$(QUIET_GEN)$(RM) $@ $@+ && \
20812082
INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
@@ -2235,20 +2236,25 @@ else
22352236
$(OBJECTS): $(LIB_H)
22362237
endif
22372238

2239+
exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX
22382240
exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
22392241
'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
22402242
'-DBINDIR="$(bindir_relative_SQ)"' \
22412243
'-DPREFIX="$(prefix_SQ)"'
22422244

2245+
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
22432246
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
22442247
-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
22452248

2249+
config.sp config.s config.o: GIT-PREFIX
22462250
config.sp config.s config.o: EXTRA_CPPFLAGS = \
22472251
-DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"'
22482252

2253+
attr.sp attr.s attr.o: GIT-PREFIX
22492254
attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \
22502255
-DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"'
22512256

2257+
gettext.sp gettext.s gettext.o: GIT-PREFIX
22522258
gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \
22532259
-DGIT_LOCALE_PATH='"$(localedir_SQ)"'
22542260

@@ -2372,14 +2378,22 @@ cscope:
23722378
$(FIND_SOURCE_FILES) | xargs cscope -b
23732379

23742380
### Detect prefix changes
2375-
TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):\
2376-
$(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\
2377-
$(localedir_SQ):$(USE_GETTEXT_SCHEME)
2381+
TRACK_PREFIX = $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\
2382+
$(localedir_SQ)
2383+
2384+
GIT-PREFIX: FORCE
2385+
@FLAGS='$(TRACK_PREFIX)'; \
2386+
if test x"$$FLAGS" != x"`cat GIT-PREFIX 2>/dev/null`" ; then \
2387+
echo 1>&2 " * new prefix flags"; \
2388+
echo "$$FLAGS" >GIT-PREFIX; \
2389+
fi
2390+
2391+
TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):$(USE_GETTEXT_SCHEME)
23782392

23792393
GIT-CFLAGS: FORCE
23802394
@FLAGS='$(TRACK_CFLAGS)'; \
23812395
if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
2382-
echo 1>&2 " * new build flags or prefix"; \
2396+
echo 1>&2 " * new build flags"; \
23832397
echo "$$FLAGS" >GIT-CFLAGS; \
23842398
fi
23852399

@@ -2715,7 +2729,7 @@ ifndef NO_TCLTK
27152729
$(MAKE) -C git-gui clean
27162730
endif
27172731
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
2718-
$(RM) GIT-USER-AGENT
2732+
$(RM) GIT-USER-AGENT GIT-PREFIX
27192733

27202734
.PHONY: all install profile-clean clean strip
27212735
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell

0 commit comments

Comments
 (0)