Skip to content

Commit 024c843

Browse files
jrngitster
authored andcommitted
Makefile: add option to disable automatic dependency generation
Now that the COMPUTE_HEADER_DEPENDENCIES feature is turned on automatically for compilers that support it (see v1.7.8-rc0~142^2~1, 2011-08-18), there is no easy way to force it off. For example, setting COMPUTE_HEADER_DEPENDENCIES to the empty string in config.mak just tells the makefile to treat it as undefined and run a test command to see if the -MMD option is supported. So allow setting COMPUTE_HEADER_DEPENDENCIES=no to explicitly force the feature off. The new semantics: - "yes" means to explicitly enable the feature - "no" means to disable it - "auto" means to autodetect The default is still "auto". Any value other than these three will cause the build to error out with a descriptive message so typos and stale settings in config.mak don't result in mysterious behavior. Makefile:1278: *** please set COMPUTE_HEADER_DEPENDENCIES to yes, no, or auto (not "1"). Stop. So now when someone using a compiler without -MMD support reports trouble building git, you can reproduce it by running "make COMPUTE_HEADER_DEPENDENCIES=no". Suggested-by: Nguyễn Thái Ngọc Duy <[email protected]> Improved-by: Junio C Hamano <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Tested-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4c00c85 commit 024c843

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

Makefile

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ all::
250250
# DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
251251
# DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
252252
#
253+
# Define COMPUTE_HEADER_DEPENDENCIES to "yes" if you want dependencies on
254+
# header files to be automatically computed, to avoid rebuilding objects when
255+
# an unrelated header file changes. Define it to "no" to use the hard-coded
256+
# dependency rules. The default is "auto", which means to use computed header
257+
# dependencies if your compiler is detected to support it.
258+
#
253259
# Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
254260
# dependency rules.
255261
#
@@ -1246,21 +1252,32 @@ endif
12461252
endif
12471253

12481254
ifdef CHECK_HEADER_DEPENDENCIES
1249-
COMPUTE_HEADER_DEPENDENCIES =
1255+
COMPUTE_HEADER_DEPENDENCIES = no
12501256
USE_COMPUTED_HEADER_DEPENDENCIES =
1251-
else
1257+
endif
1258+
12521259
ifndef COMPUTE_HEADER_DEPENDENCIES
1260+
COMPUTE_HEADER_DEPENDENCIES = auto
1261+
endif
1262+
1263+
ifeq ($(COMPUTE_HEADER_DEPENDENCIES),auto)
12531264
dep_check = $(shell $(CC) $(ALL_CFLAGS) \
12541265
-c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \
12551266
echo $$?)
12561267
ifeq ($(dep_check),0)
1257-
COMPUTE_HEADER_DEPENDENCIES=YesPlease
1258-
endif
1268+
override COMPUTE_HEADER_DEPENDENCIES = yes
1269+
else
1270+
override COMPUTE_HEADER_DEPENDENCIES = no
12591271
endif
12601272
endif
12611273

1262-
ifdef COMPUTE_HEADER_DEPENDENCIES
1274+
ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
12631275
USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease
1276+
else
1277+
ifneq ($(COMPUTE_HEADER_DEPENDENCIES),no)
1278+
$(error please set COMPUTE_HEADER_DEPENDENCIES to yes, no, or auto \
1279+
(not "$(COMPUTE_HEADER_DEPENDENCIES)"))
1280+
endif
12641281
endif
12651282

12661283
ifdef SANE_TOOL_PATH
@@ -1907,7 +1924,7 @@ OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(VCSSVN_OBJS)
19071924
dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
19081925
dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
19091926

1910-
ifdef COMPUTE_HEADER_DEPENDENCIES
1927+
ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
19111928
$(dep_dirs):
19121929
@mkdir -p $@
19131930

@@ -1920,7 +1937,7 @@ Please unset CHECK_HEADER_DEPENDENCIES and try again)
19201937
endif
19211938
endif
19221939

1923-
ifndef COMPUTE_HEADER_DEPENDENCIES
1940+
ifneq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
19241941
ifndef CHECK_HEADER_DEPENDENCIES
19251942
dep_dirs =
19261943
missing_dep_dirs =

0 commit comments

Comments
 (0)