Makefile: Use computed header dependencies if the compiler supports it
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>
Fredrik Kuivinen committed
Aug 18, 2011 at 20:34 UTC
111ee18c31f9bac9436426399355facc79238566
1 file changed
+9
-4
Makefile
+9
-4
@@ -250,10 +250,6 @@ all::
250
# DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
251
# DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
252
#
253
-# Define COMPUTE_HEADER_DEPENDENCIES if your compiler supports the -MMD option
254
-# and you want to avoid rebuilding objects when an unrelated header file
255
-# changes.
256
-#
253
# Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
254
# dependency rules.
255
#
@@ -1236,6 +1232,15 @@ endif
1232
ifdef CHECK_HEADER_DEPENDENCIES
1233
COMPUTE_HEADER_DEPENDENCIES =
1234
USE_COMPUTED_HEADER_DEPENDENCIES =
1235
+else
1236
+ifndef COMPUTE_HEADER_DEPENDENCIES
1237
+dep_check = $(shell sh -c \
1238
+ '$(CC) -c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \
1239
+ echo $$?')
1240
+ifeq ($(dep_check),0)
1241
+COMPUTE_HEADER_DEPENDENCIES=YesPlease
1242
+endif
1243
+endif
1244
endif
1245
1246
ifdef COMPUTE_HEADER_DEPENDENCIES