[OpenBIOS] [PATCH 2/2] Introduce automatic build dependencies

Blue Swirl blauwirbel at gmail.com
Sat Nov 13 16:05:15 CET 2010


Use GCC to generate dependency files.

Signed-off-by: Blue Swirl <blauwirbel at gmail.com>
---
 Makefile.target      |    9 ++++++++-
 config/xml/rules.xml |    8 ++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index fd46e09..9ae8120 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -14,6 +14,8 @@ HOSTCFLAGS+= -Wall -Wredundant-decls -Wshadow -Wpointer-arith
 HOSTCFLAGS+= -Wstrict-prototypes -Wmissing-declarations -Wundef -Wendif-labels
 HOSTCFLAGS+= -Wstrict-aliasing -Wwrite-strings -Wmissing-prototypes
-Wnested-externs
 HOSTCFLAGS+= -W
+# Flags for dependency generation
+HOSTCFLAGS+= -MMD -MP -MT $@ -MF '$(*D)/$(*F).d'
 HOSTINCLUDES := -I$(SRCDIR)/include -I$(SRCDIR)/kernel
-I$(SRCDIR)/kernel/include -I$(ODIR)/target/include

 CC     := $(TARGET)gcc
@@ -29,6 +31,8 @@ CFLAGS+= -Wall -Wredundant-decls -Wshadow -Wpointer-arith
 CFLAGS+= -Wstrict-prototypes -Wmissing-declarations -Wundef -Wendif-labels
 CFLAGS+= -Wstrict-aliasing -Wwrite-strings -Wmissing-prototypes
-Wnested-externs
 CFLAGS+= -Werror
+# Flags for dependency generation
+CFLAGS+= -MMD -MP -MT $@ -MF '$(*D)/$(*F).d'
 INCLUDES := -I$(SRCDIR)/include -I$(SRCDIR)/kernel/include
-I$(ODIR)/target/include
 AS_FLAGS+= -g

@@ -63,7 +67,7 @@ clean:
 	@printf "Cleaning up for $(ARCH)..."
 	@rm -rf forth.dict.core forthstrap *.dict openbios-*
 	@rm -f $(ODIR)/target/include/openbios-version.h $(ODIR)/forth/version.fs
-	@find . -type f \( -name "*~" -o -name '*.o' -o -name '*.a' \) -exec
rm \{\} \;
+	@find . -type f \( -name "*~" -o -name '*.o' -o -name '*.d' -o -name
'*.a' \) -exec rm \{\} \;
 	@echo " ok"

 build-verbose: info build
@@ -71,3 +75,6 @@ build-verbose: info build
 build: all

 include rules.mak
+
+# Include automatically generated dependency files
+-include $(wildcard $(ODIR)/host/kernel/*.d $(ODIR)/target/*/*.d
$(ODIR)/target/*/*/*.d $(ODIR)/target/*/*/*/*.d)
diff --git a/config/xml/rules.xml b/config/xml/rules.xml
index 9764298..86a3b6b 100644
--- a/config/xml/rules.xml
+++ b/config/xml/rules.xml
@@ -4,11 +4,11 @@
 	$(call quiet-command,$(HOSTCC) $(HOSTCFLAGS) -o $@ $^," HOSTCC
$(TARGET_DIR)$@")
 </rule>
 <rule target="host" entity="object">
-	$(call quiet-command,$(HOSTCC) $(HOSTCFLAGS) $(HOSTINCLUDES) -c -o
$@ $^," HOSTCC $(TARGET_DIR)$@")
+	$(call quiet-command,$(HOSTCC) $(HOSTCFLAGS) $(HOSTINCLUDES) -c -o
$@ $<," HOSTCC $(TARGET_DIR)$@")
 </rule>
 <rule target="host" entity="object" extracflags="1">
 	$(call quiet-command,$(HOSTCC) $(HOSTCFLAGS) $(HOSTINCLUDES)</rule>
-<rule target="host" entity="object" extracflags="2"> -c -o $@ $^,"
HOSTCC $(TARGET_DIR)$@")
+<rule target="host" entity="object" extracflags="2"> -c -o $@ $<,"
HOSTCC $(TARGET_DIR)$@")
 </rule>
 <rule target="host" entity="library">
 	$(call quiet--command,$(AR) cru $@ $^; $(RANLIB) $@," HOSTAR $(TARGET_DIR)$@")
@@ -19,11 +19,11 @@
 	$(call quiet-command,$(CC) $(CFLAGS) -o $@ $^,"  CC    $(TARGET_DIR)$@")
 </rule>
 <rule target="target" entity="object">
-	$(call quiet-command,$(CC) $$EXTRACFLAGS $(CFLAGS) $(INCLUDES) -c -o
$@ $^,"  CC    $(TARGET_DIR)$@")
+	$(call quiet-command,$(CC) $$EXTRACFLAGS $(CFLAGS) $(INCLUDES) -c -o
$@ $<,"  CC    $(TARGET_DIR)$@")
 </rule>
 <rule target="target" entity="object" extracflags="1">
 	$(call quiet-command,$(CC) $$EXTRACFLAGS $(CFLAGS) $(INCLUDES)</rule>
-<rule target="target" entity="object" extracflags="2"> -c -o $@ $^,"
CC    $(TARGET_DIR)$@")
+<rule target="target" entity="object" extracflags="2"> -c -o $@
$<,"  CC    $(TARGET_DIR)$@")
 </rule>
 <rule target="target" entity="library">
 	$(call quiet-command,$(AR) cru $@ $^; $(RANLIB) $@,"  AR    $(TARGET_DIR)$@")
-- 
1.6.2.4



More information about the OpenBIOS mailing list