From e073bc9484445a142522822088302c953bed9496 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sat, 11 May 2013 20:15:53 +0200 Subject: [PATCH] Implement dependency generation in libtools.make. Automatically generate dependency files for all sources so changes in headers are picked up automatically. Use one dependency file for each source file, since that allows to create them without using external tools (except the compiler of course). Change-Id: I246c1ceb525692547af22a2e32c4bab0c11507e1 --- rbutil/libtools.make | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rbutil/libtools.make b/rbutil/libtools.make index 054a1c2c5a..93ce9532a6 100644 --- a/rbutil/libtools.make +++ b/rbutil/libtools.make @@ -74,10 +74,12 @@ endif WINDRES = windres BUILD_DIR ?= $(TARGET_DIR)build$(COMPILETARGET) -OBJDIR = $(abspath $(BUILD_DIR)/$(RBARCH))/ ifdef RBARCH CFLAGS += -arch $(RBARCH) +OBJDIR = $(abspath $(BUILD_DIR)/$(RBARCH))/ +else +OBJDIR = $(abspath $(BUILD_DIR))/ endif all: $(BINARY) @@ -85,7 +87,11 @@ all: $(BINARY) OBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(notdir $(SOURCES)))) LIBOBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(notdir $(LIBSOURCES)))) +# create dependency files. Make sure to use the same prefix as with OBJS! $(foreach src,$(SOURCES) $(LIBSOURCES),$(eval $(addprefix $(OBJDIR),$(subst .c,.o,$(notdir $(src)))): $(src))) +$(foreach src,$(SOURCES) $(LIBSOURCES),$(eval $(addprefix $(OBJDIR),$(subst .c,.d,$(notdir $(src)))): $(src))) +DEPS = $(addprefix $(OBJDIR),$(subst .c,.d,$(notdir $(SOURCES) $(LIBSOURCES)))) +-include $(DEPS) # additional link dependencies for the standalone executable # extra dependencies: libucl @@ -135,6 +141,10 @@ clean: rm -f $(OBJS) $(OUTPUT) $(TARGET_DIR)lib$(OUTPUT)*.a $(OUTPUT).dmg rm -rf $(OUTPUT)-* i386 ppc $(OBJDIR) +%.d: + $(SILENT)$(call mkdir,$(BUILD_DIR)) + $(SILENT)$(CC) -MG -MM -MT $(subst .d,.o,$@) $(CFLAGS) -o $(BUILD_DIR)/$(notdir $@) $< + # extra tools BIN2C = $(TOP)/tools/bin2c $(BIN2C):