HV: make: consider header depenencies when rebuilding

With Kconfig, it would be common to rebuild the hypervisor with a few
configuration symbols changed. But for a proper rebuild, users are required to
execute ''make clean'' first, which deletes the configuration file at all.

This patch leverages the compiler to generate a target that add involved headers
as dependencies to a specific file. Any change to a header will now trigger the
rebuilding of related sources properly.

Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Junjie Mao 2018-07-15 16:15:40 +08:00 committed by lijinxia
parent 11239ae654
commit 116038fafc

View File

@ -279,10 +279,13 @@ $(VERSION):
echo "#define HV_BUILD_TIME "\""$$TIME"\""" >> $(VERSION);\ echo "#define HV_BUILD_TIME "\""$$TIME"\""" >> $(VERSION);\
echo "#define HV_BUILD_USER "\""$$USER"\""" >> $(VERSION) echo "#define HV_BUILD_USER "\""$$USER"\""" >> $(VERSION)
-include $(C_OBJS:.o=.d)
-include $(S_OBJS:.o=.d)
$(HV_OBJDIR)/%.o: %.c $(HV_OBJDIR)/$(HV_CONFIG_H) $(HV_OBJDIR)/%.o: %.c $(HV_OBJDIR)/$(HV_CONFIG_H)
[ ! -e $@ ] && mkdir -p $(dir $@); \ [ ! -e $@ ] && mkdir -p $(dir $@); \
$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -c $(CFLAGS) $(ARCH_CFLAGS) $< -o $@ $(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -c $(CFLAGS) $(ARCH_CFLAGS) $< -o $@ -MMD -MT $@
$(HV_OBJDIR)/%.o: %.S $(HV_OBJDIR)/$(HV_CONFIG_H) $(HV_OBJDIR)/%.o: %.S $(HV_OBJDIR)/$(HV_CONFIG_H)
[ ! -e $@ ] && mkdir -p $(dir $@); \ [ ! -e $@ ] && mkdir -p $(dir $@); \
$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. $(ASFLAGS) $(ARCH_ASFLAGS) -c $< -o $@ $(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. $(ASFLAGS) $(ARCH_ASFLAGS) -c $< -o $@ -MMD -MT $@