summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredrik Kuivinen <frekui@gmail.com>2011-08-18 20:34:39 +0200
committerJunio C Hamano <gitster@pobox.com>2011-08-18 13:54:58 -0700
commit111ee18c31f9bac9436426399355facc79238566 (patch)
treeeb27c60f04c22ead24fabcdb762a8876be101bf1
parentf85a051d13884c5a1059edb6ef7f2a6f8c55f0e9 (diff)
downloadgit-fk/make-auto-header-dependencies.tar.gz
Makefile: Use computed header dependencies if the compiler supports itfk/make-auto-header-dependencies
Previously you had to manually define COMPUTE_HEADER_DEPENDENCIES to enable this feature. It seemed a bit sad that such a useful feature had to be enabled manually. To avoid the small overhead we don't do the auto-detection if COMPUTE_HEADER_DEPENDENCIES is already set. Signed-off-by: Fredrik Kuivinen <frekui@gmail.com> Acked-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--Makefile13
1 files changed, 9 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 89cc6245a7..c131439a34 100644
--- a/Makefile
+++ b/Makefile
@@ -250,10 +250,6 @@ all::
# DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
# DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
#
-# Define COMPUTE_HEADER_DEPENDENCIES if your compiler supports the -MMD option
-# and you want to avoid rebuilding objects when an unrelated header file
-# changes.
-#
# Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
# dependency rules.
#
@@ -1236,6 +1232,15 @@ endif
ifdef CHECK_HEADER_DEPENDENCIES
COMPUTE_HEADER_DEPENDENCIES =
USE_COMPUTED_HEADER_DEPENDENCIES =
+else
+ifndef COMPUTE_HEADER_DEPENDENCIES
+dep_check = $(shell sh -c \
+ '$(CC) -c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \
+ echo $$?')
+ifeq ($(dep_check),0)
+COMPUTE_HEADER_DEPENDENCIES=YesPlease
+endif
+endif
endif
ifdef COMPUTE_HEADER_DEPENDENCIES