summaryrefslogtreecommitdiffstats
path: root/rbutil
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2013-05-11 20:15:53 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2013-05-11 20:34:12 +0200
commite073bc9484445a142522822088302c953bed9496 (patch)
tree8c55a02d545c05e63c62f727cf50ba5a29656084 /rbutil
parent9a9efefdb2ec7af52ca6946b78cb8610d8391ecf (diff)
downloadrockbox-e073bc9484445a142522822088302c953bed9496.tar.gz
rockbox-e073bc9484445a142522822088302c953bed9496.tar.bz2
rockbox-e073bc9484445a142522822088302c953bed9496.zip
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
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/libtools.make12
1 files changed, 11 insertions, 1 deletions
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):