-
Notifications
You must be signed in to change notification settings - Fork 7
/
target-rules.mk
69 lines (51 loc) · 2.39 KB
/
target-rules.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
%.o: %.c
$(E) "[TC] Compiling $<"
$(Q)$(TARGET_CC) -ffunction-sections -Wall -Werror $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -g3 -c -o $@ $<
%.o: %.cc
$(E) "[TCXX] Compiling $<"
$(Q)$(TARGET_CXX) -ffunction-sections -Wall -Werror $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_CXXFLAGS) $(TARGET_CPPFLAGS) -g3 -c -o $@ $<
%.o: %.cpp
$(E) "[TCXX] Compiling $<"
$(Q)$(TARGET_CXX) -ffunction-sections -Wall -Werror $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_CXXFLAGS) $(TARGET_CPPFLAGS) -g3 -c -o $@ $<
%.o: %.s
$(E) "[TS] Compiling $<"
$(Q)$(TARGET_AS) $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_ASFLAGS) $(TARGET_CPPFLAGS) -g3 -c -o $@ $<
%.dep: %.c
$(Q)$(TARGET_CC) -ffunction-sections -Wall -Werror $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -g3 -M -MT $(addsuffix .o, $(basename $@)) -MF $@ $<
%.dep: %.cc
$(Q)$(TARGET_CXX) -ffunction-sections -Wall -Werror $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_CXXFLAGS) $(TARGET_CPPFLAGS) -g3 -M -MT $(addsuffix .o, $(basename $@)) -MF $@ $<
%.dep: %.cpp
$(Q)$(TARGET_CXX) -ffunction-sections -Wall -Werror $(addprefix -I, $(TARGET_INCLUDES)) $(TARGET_CXXFLAGS) $(TARGET_CPPFLAGS) -g3 -M -MT $(addsuffix .o, $(basename $@)) -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_DEPS += $(addsuffix .dep, $(basename $(TARGET)))
endif
$(TARGET_ELF): $(TARGET_OBJS) $(LIBDEPS) $(LDSCRIPT)
$(E) "[TL] Linking $@"
$(Q)$(TARGET_LD) -Wl,--gc-sections -Wl,-Map=$(TARGET_MAP) -o $@ $(TARGET_OBJS) $(TARGET_LDFLAGS) -g3 -T$(LDSCRIPT) $(LIBS)
$(TARGET_MAP): $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(E) "[TB] Creating $@"
$(Q)$(TARGET_OBJCOPY) $< -O binary $@
ifeq ($(CPU_FAMILY),CM3)
$(Q)$(ROOTDIR)/tools/cm3-checksum/cm3-checksum $@
endif
ifneq ($(TARGET_LIB),)
$(TARGET_LIB): $(TARGET_OBJS)
$(E) "[TLIB] Creating $@"
$(Q)$(TARGET_AR) rcs $@ $^
endif
.PHONY: clean-generic ldeps
clean-generic:
$(E) "[CLEAN] $(CURDIR)"
$(Q)rm -f $(TARGET_LIB) $(TARGET_OBJS) $(TARGET) $(TARGET_ELF) $(TARGET_BIN) $(TARGET_MAP) $(TARGET_DEPS)
ldeps: $(TARGET_DEPS)
-include $(TARGET_DEPS)