summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-02-05 09:31:48 -0800
committerPixel <pixel@nobis-crew.org>2011-02-05 09:34:55 -0800
commitafdbb22838d7528b70924232814cb84e25890d83 (patch)
tree2f8b734839f23ac9b7592d62fcf527758449714b
parent0044f9480cfa8d5cf0a3d84e84be25e32b588726 (diff)
Adding automatic dependency tree building.
-rw-r--r--Makefile12
-rw-r--r--target-rules.mk33
2 files changed, 42 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 800541a..4c3e49b 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ clean: clean-generic
$(Q)$(MAKE) $(MAKE_OPTS) -C tools clean
$(Q)rm -f test-romfs.bin
-.PHONY: libs FreeRTOS arch os libc tools
+.PHONY: libs FreeRTOS arch os libc tools deps
FreeRTOS/libFreeRTOS.a: FreeRTOS
arch/libarch.a: arch
@@ -53,6 +53,16 @@ test-romfs.o: tools/mkromfs
$(Q) $(TARGET_OBJCOPY_BIN) --prefix-sections '.romfs' test-romfs.bin test-romfs.o
$(Q)$(MAKE) $(MAKE_OPTS) -C tools
+deps: ldeps
+ $(E) "[DEPS] Creating dependency tree for FreeRTOS"
+ $(Q)$(MAKE) $(MAKE_OPTS) -C FreeRTOS ldeps
+ $(E) "[DEPS] Creating dependency tree for arch"
+ $(Q)$(MAKE) $(MAKE_OPTS) -C arch ldeps
+ $(E) "[DEPS] Creating dependency tree for os"
+ $(Q)$(MAKE) $(MAKE_OPTS) -C os ldeps
+ $(E) "[DEPS] Creating dependency tree for libc"
+ $(Q)$(MAKE) $(MAKE_OPTS) -C libc ldeps
+
include FreeRTOS/config.mk
include arch/config.mk
include os/config.mk
diff --git a/target-rules.mk b/target-rules.mk
index fe6b710..efb2bba 100644
--- a/target-rules.mk
+++ b/target-rules.mk
@@ -2,17 +2,42 @@
$(E) "[TC] Compiling $<"
$(Q)$(TARGET_CC) -ffunction-sections -Wall -Werror $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -g -c -o $@ $<
+%.o: %.cc
+ $(E) "[TCXX] Compiling $<"
+ $(Q)$(TARGET_CXX) -ffunction-sections -Wall -Werror $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -g -c -o $@ $<
+
+%.o: %.cpp
+ $(E) "[TCXX] Compiling $<"
+ $(Q)$(TARGET_CXX) -ffunction-sections -Wall -Werror $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -g -c -o $@ $<
+
%.o: %.s
$(E) "[TS] Compiling $<"
$(Q)$(TARGET_AS) $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_ASFLAGS) $(TARGET_CPPFLAGS) -g -c -o $@ $<
+%.dep: %.c
+ $(Q)$(TARGET_CC) -ffunction-sections -Wall -Werror $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -g -M -MF $@ $<
+
+%.dep: %.cc
+ $(Q)$(TARGET_CXX) -ffunction-sections -Wall -Werror $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -g -M -MF $@ $<
+
+%.dep: %.cpp
+ $(Q)$(TARGET_CXX) -ffunction-sections -Wall -Werror $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -g -M -MF $@ $<
+
+%.dep: %.s
+ $(Q)touch $@
+
+%.dep: %.o
+ $(Q)touch $@
+
TARGET_OBJS = $(addsuffix .o, $(basename $(TARGET_SRCS)))
+TARGET_DEPS = $(addsuffix .dep, $(basename $(TARGET_SRCS)))
ifneq ($(TARGET),)
TARGET_ELF = $(addsuffix .elf, $(basename $(TARGET)))
TARGET_BIN = $(addsuffix .bin, $(basename $(TARGET)))
TARGET_MAP = $(addsuffix .map, $(basename $(TARGET)))
TARGET_OBJS += $(addsuffix .o, $(basename $(TARGET)))
+TARGET_DEPS += $(addsuffix .dep, $(basename $(TARGET)))
endif
$(TARGET_ELF): $(TARGET_OBJS) $(LIBDEPS) $(LDSCRIPT) $(SPECS)
@@ -29,8 +54,12 @@ $(TARGET_LIB): $(TARGET_OBJS)
$(E) "[TLIB] Creating $@"
$(Q)$(TARGET_AR) rcs $@ $^
-.PHONY: clean-generic
+.PHONY: clean-generic ldeps
clean-generic:
$(E) "[CLEAN] $(CURDIR)"
- $(Q)rm -f $(TARGET_LIB) $(TARGET_OBJS) $(TARGET) $(TARGET_ELF) $(TARGET_BIN) $(TARGET_MAP)
+ $(Q)rm -f $(TARGET_LIB) $(TARGET_OBJS) $(TARGET) $(TARGET_ELF) $(TARGET_BIN) $(TARGET_MAP) $(TARGET_DEPS)
+
+ldeps: $(TARGET_DEPS)
+
+-include $(TARGET_DEPS)