217
# DEFAULT_EDITOR='~/bin/vi',
218
# DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
219
# DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
220
+#
221
+# Define COMPUTE_HEADER_DEPENDENCIES if your compiler supports the -MMD option
222
+# and you want to avoid rebuilding objects when an unrelated header file
223
+# changes.
224
225
GIT-VERSION-FILE: FORCE
226
@$(SHELL_PATH) ./GIT-VERSION-GEN
1681
ASM_OBJ := $(ASM_SRC:S=o)
1682
C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS))
1683
1684
+ifdef COMPUTE_HEADER_DEPENDENCIES
1685
+dep_dirs := $(addsuffix deps,$(sort $(dir $(OBJECTS))))
1686
+$(dep_dirs):
1687
+ mkdir -p $@
1688
+
1689
+missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
1690
+else
1691
+dep_dirs =
1692
+missing_dep_dirs =
1693
+endif
1694
+
1695
.SUFFIXES:
1696
1682
-$(C_OBJ): %.o: %.c GIT-CFLAGS
1683
- $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
1697
+$(C_OBJ): %.o: %.c GIT-CFLAGS $(missing_dep_dirs)
1698
+ $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<
1699
%.s: %.c GIT-CFLAGS FORCE
1700
$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
1686
-$(ASM_OBJ): %.o: %.S GIT-CFLAGS
1687
- $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
1701
+$(ASM_OBJ): %.o: %.S GIT-CFLAGS $(missing_dep_dirs)
1702
+ $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $<
1703
+
1704
+ifdef COMPUTE_HEADER_DEPENDENCIES
1705
+# Take advantage of gcc's on-the-fly dependency generation
1706
+# See <http://gcc.gnu.org/gcc-3.0/features.html>.
1707
+dep_files := $(wildcard $(foreach f,$(OBJECTS),$(dir f)deps/$(notdir $f).d))
1708
+ifneq ($(dep_files),)
1709
+include $(dep_files)
1710
+endif
1711
+
1712
+dep_file = $(dir $@)deps/$(notdir $@).d
1713
+dep_args = -MF $(dep_file) -MMD -MP
1714
+else
1715
+dep_args =
1716
+
1717
+# Dependencies on header files, for platforms that do not support
1718
+# the gcc -MMD option.
1719
+#
1720
+# Dependencies on automatically generated headers such as common-cmds.h
1721
+# should _not_ be included here, since they are necessary even when
1722
+# building an object for the first time.
1723
+#
1724
+# XXX. Please check occasionally that these include all dependencies
1725
+# gcc detects!
1726
1727
$(GIT_OBJS): $(LIB_H)
1728
builtin-branch.o builtin-checkout.o builtin-clone.o builtin-reset.o branch.o transport.o: branch.h
1738
http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h
1739
http.o http-walker.o http-push.o remote-curl.o: http.h
1740
1703
-
1741
xdiff-interface.o $(XDIFF_OBJS): \
1742
xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
1743
xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
1744
+endif
1745
1746
exec_cmd.s exec_cmd.o: ALL_CFLAGS += \
1747
'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
2049
$(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
2050
$(RM) $(TEST_PROGRAMS)
2051
$(RM) -r bin-wrappers
2052
+ $(RM) -r $(dep_dirs)
2053
$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
2054
$(RM) -r autom4te.cache
2055
$(RM) config.log config.mak.autogen config.mak.append config.status config.cache