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 <pclouds@gmail.com> Improved-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Tested-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4c00c852b3
commit
024c843d47
31
Makefile
31
Makefile
@ -250,6 +250,12 @@ all::
|
|||||||
# DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
|
# DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
|
||||||
# DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
|
# DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
|
||||||
#
|
#
|
||||||
|
# Define COMPUTE_HEADER_DEPENDENCIES to "yes" if you want dependencies on
|
||||||
|
# header files to be automatically computed, to avoid rebuilding objects when
|
||||||
|
# an unrelated header file changes. Define it to "no" to use the hard-coded
|
||||||
|
# dependency rules. The default is "auto", which means to use computed header
|
||||||
|
# dependencies if your compiler is detected to support it.
|
||||||
|
#
|
||||||
# Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
|
# Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
|
||||||
# dependency rules.
|
# dependency rules.
|
||||||
#
|
#
|
||||||
@ -1246,21 +1252,32 @@ endif
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef CHECK_HEADER_DEPENDENCIES
|
ifdef CHECK_HEADER_DEPENDENCIES
|
||||||
COMPUTE_HEADER_DEPENDENCIES =
|
COMPUTE_HEADER_DEPENDENCIES = no
|
||||||
USE_COMPUTED_HEADER_DEPENDENCIES =
|
USE_COMPUTED_HEADER_DEPENDENCIES =
|
||||||
else
|
endif
|
||||||
|
|
||||||
ifndef COMPUTE_HEADER_DEPENDENCIES
|
ifndef COMPUTE_HEADER_DEPENDENCIES
|
||||||
|
COMPUTE_HEADER_DEPENDENCIES = auto
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(COMPUTE_HEADER_DEPENDENCIES),auto)
|
||||||
dep_check = $(shell $(CC) $(ALL_CFLAGS) \
|
dep_check = $(shell $(CC) $(ALL_CFLAGS) \
|
||||||
-c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \
|
-c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \
|
||||||
echo $$?)
|
echo $$?)
|
||||||
ifeq ($(dep_check),0)
|
ifeq ($(dep_check),0)
|
||||||
COMPUTE_HEADER_DEPENDENCIES=YesPlease
|
override COMPUTE_HEADER_DEPENDENCIES = yes
|
||||||
endif
|
else
|
||||||
|
override COMPUTE_HEADER_DEPENDENCIES = no
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef COMPUTE_HEADER_DEPENDENCIES
|
ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
|
||||||
USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease
|
USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease
|
||||||
|
else
|
||||||
|
ifneq ($(COMPUTE_HEADER_DEPENDENCIES),no)
|
||||||
|
$(error please set COMPUTE_HEADER_DEPENDENCIES to yes, no, or auto \
|
||||||
|
(not "$(COMPUTE_HEADER_DEPENDENCIES)"))
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef SANE_TOOL_PATH
|
ifdef SANE_TOOL_PATH
|
||||||
@ -1907,7 +1924,7 @@ OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(VCSSVN_OBJS)
|
|||||||
dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
|
dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
|
||||||
dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
|
dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
|
||||||
|
|
||||||
ifdef COMPUTE_HEADER_DEPENDENCIES
|
ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
|
||||||
$(dep_dirs):
|
$(dep_dirs):
|
||||||
@mkdir -p $@
|
@mkdir -p $@
|
||||||
|
|
||||||
@ -1920,7 +1937,7 @@ Please unset CHECK_HEADER_DEPENDENCIES and try again)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef COMPUTE_HEADER_DEPENDENCIES
|
ifneq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
|
||||||
ifndef CHECK_HEADER_DEPENDENCIES
|
ifndef CHECK_HEADER_DEPENDENCIES
|
||||||
dep_dirs =
|
dep_dirs =
|
||||||
missing_dep_dirs =
|
missing_dep_dirs =
|
||||||
|
Loading…
Reference in New Issue
Block a user