Update the build system to handle dependency on header files. Closes #2547.

This commit is contained in:
Michael Sullivan 2012-06-13 15:27:07 -07:00
parent f8afe107fa
commit 31f4b63dff
3 changed files with 16 additions and 19 deletions

View File

@ -214,14 +214,16 @@ ifeq ($(CFG_C_COMPILER),clang)
endif
CFG_GCCISH_CFLAGS += -Wall -Werror -fno-rtti -g
CFG_GCCISH_LINK_FLAGS += -g
CFG_DEPEND_C = $(CFG_GCCISH_CROSS)$(CXX) $(CFG_GCCISH_CFLAGS) -MT "$(1)" \
-MM $(2)
# These flags will cause the compiler to produce a .d file
# next to the .o file that lists header deps.
CFG_DEPEND_FLAGS = -MMD -MP -MT $(1) -MF $(1:%.o=%.d)
define CFG_MAKE_CC
CFG_COMPILE_C_$(1) = $$(CFG_GCCISH_CROSS)$$(CXX) \
$$(CFG_GCCISH_CFLAGS) $$(CFG_CLANG_CFLAGS) \
$$(CFG_GCCISH_CFLAGS_$$(HOST_$(1))) \
$$(CFG_CLANG_CFLAGS_$$(HOST_$(1))) \
$$(CFG_DEPEND_FLAGS) \
-c -o $$(1) $$(2)
CFG_LINK_C_$(1) = $$(CFG_GCCISH_CROSS)$$(CXX) \
$$(CFG_GCCISH_LINK_FLAGS) -o $$(1) \
@ -245,8 +247,9 @@ ifeq ($(CFG_C_COMPILER),gcc)
endif
CFG_GCCISH_CFLAGS += -Wall -Werror -fno-rtti -g
CFG_GCCISH_LINK_FLAGS += -g
CFG_DEPEND_C = $(CFG_GCCISH_CROSS)$(CXX) $(CFG_GCCISH_CFLAGS) -MT "$(1)" \
-MM $(2)
# These flags will cause the compiler to produce a .d file
# next to the .o file that lists header deps.
CFG_DEPEND_FLAGS = -MMD -MP -MT $(1) -MF $(1:%.o=%.d)
define CFG_MAKE_CC
CFG_COMPILE_C_$(1) = $$(CFG_GCCISH_CROSS)$$(CXX) \
@ -254,6 +257,7 @@ ifeq ($(CFG_C_COMPILER),gcc)
$$(CFG_GCCISH_CFLAGS_$$(HOST_$(1))) \
$$(CFG_GCC_CFLAGS) \
$$(CFG_GCC_CFLAGS_$$(HOST_$(1))) \
$$(CFG_DEPEND_FLAGS) \
-c -o $$(1) $$(2)
CFG_LINK_C_$(1) = $$(CFG_GCCISH_CROSS)$$(CXX) \
$$(CFG_GCCISH_LINK_FLAGS) -o $$(1) \
@ -272,7 +276,7 @@ endif
# We're using llvm-mc as our assembler because it supports
# .cfi pseudo-ops on mac
define CFG_MAKE_ASSEMBLER
CFG_ASSEMBLE_$(1)=$$(CPP) $$(2) | \
CFG_ASSEMBLE_$(1)=$$(CPP) $$(CFG_DEPEND_FLAGS) $$(2) | \
$$(LLVM_MC_$$(CFG_HOST_TRIPLE)) \
-assemble \
-filetype=obj \

View File

@ -79,17 +79,6 @@ RUNTIME_S_$(1) := rt/arch/$$(HOST_$(1))/_context.S \
rt/arch/$$(HOST_$(1))/ccall.S \
rt/arch/$$(HOST_$(1))/record_sp.S
RUNTIME_HDR_$(1) := $$(wildcard \
rt/*.h \
rt/bigint/*.h \
rt/isaac/*.h \
rt/msvc/*.h \
rt/sync/*.h \
rt/uthash/*.h \
rt/util/*.h \
rt/vg/*.h \
rt/arch/$$(HOST_$(1))/*.h)
ifeq ($$(HOST_$(1)), i386)
LIBUV_ARCH_$(1) := ia32
else
@ -116,14 +105,17 @@ RUNTIME_INCS_$(1) := -I $$(S)src/rt -I $$(S)src/rt/isaac -I $$(S)src/rt/uthash \
-I $$(S)src/libuv/include
RUNTIME_OBJS_$(1) := $$(RUNTIME_CS_$(1):rt/%.cpp=rt/$(1)/%.o) \
$$(RUNTIME_S_$(1):rt/%.S=rt/$(1)/%.o)
RUNTIME_DEP_FILES_$(1) := $$(RUNTIME_OBJS_$(1):%.o=%.d)
-include $$(RUNTIME_DEP_FILES_$(1))
RUNTIME_LIBS_$(1) := $$(LIBUV_LIB_$(1))
rt/$(1)/%.o: rt/%.cpp $$(RUNTIME_HDR_$(1)) $$(MKFILE_DEPS)
rt/$(1)/%.o: rt/%.cpp $$(MKFILE_DEPS)
@$$(call E, compile: $$@)
$$(Q)$$(call CFG_COMPILE_C_$(1), $$@, $$(RUNTIME_INCS_$(1)) \
$$(SNAP_DEFINES)) $$<
rt/$(1)/%.o: rt/%.S $$(RUNTIME_HDR_$(1)) $$(MKFILE_DEPS) \
rt/$(1)/%.o: rt/%.S $$(MKFILE_DEPS) \
$$(LLVM_CONFIG_$$(CFG_HOST_TRIPLE))
@$$(call E, compile: $$@)
$$(Q)$$(call CFG_ASSEMBLE_$(1),$$@,$$<)
@ -134,7 +126,6 @@ rt/$(1)/arch/$$(HOST_$(1))/libmorestack.a: \
$$(Q)ar rcs $$@ $$<
rt/$(1)/$(CFG_RUNTIME): $$(RUNTIME_OBJS_$(1)) $$(MKFILE_DEPS) \
$$(RUNTIME_HDR_$(1)) \
$$(RUNTIME_DEF_$(1)) \
$$(RUNTIME_LIBS_$(1))
@$$(call E, link: $$@)

View File

@ -20,6 +20,8 @@ RUSTLLVM_INCS_$(1) = $$(LLVM_EXTRA_INCDIRS_$(1)) \
-iquote $$(LLVM_INCDIR_$(1)) \
-iquote $$(S)src/rustllvm/include
RUSTLLVM_OBJS_OBJS_$(1) := $$(RUSTLLVM_OBJS_CS_$(1):rustllvm/%.cpp=rustllvm/$(1)/%.o)
RUSTLLVM_DEP_FILES_$(1) := $$(RUSTLLVM_OBJS_OBJS_$(1):%.o=%.d)
-include $$(RUSTLLVM_DEP_FILES_$(1))
rustllvm/$(1)/$(CFG_RUSTLLVM): $$(RUSTLLVM_OBJS_OBJS_$(1)) \
$$(MKFILE_DEPS) $$(RUSTLLVM_DEF_$(1))