core: Fix OPT_DEFS for mbed build
[tmk_keyboard.git] / tmk_core / tool / mbed / gcc.mk
... / ...
CommitLineData
1# based on Makefile exported form mbed.org
2# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
3
4GCC_BIN =
5AS = $(GCC_BIN)arm-none-eabi-as
6CC = $(GCC_BIN)arm-none-eabi-gcc
7CPP = $(GCC_BIN)arm-none-eabi-g++
8LD = $(GCC_BIN)arm-none-eabi-gcc
9OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy
10OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump
11SIZE = $(GCC_BIN)arm-none-eabi-size
12CHKSUM = $(TMK_DIR)/tool/mbed/lpc-vector-checksum
13
14CC_FLAGS += \
15 $(CPU) \
16 -c \
17 -g \
18 -fno-common \
19 -fmessage-length=0 \
20 -Wall \
21 -fno-exceptions \
22 -ffunction-sections \
23 -fdata-sections \
24 -fomit-frame-pointer
25CC_FLAGS += -MMD -MP
26CC_FLAGS += $(OPT_DEFS)
27
28LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs
29#LD_FLAGS += -u _printf_float -u _scanf_float
30LD_FLAGS += -Wl,-Map=$(OBJDIR)/$(PROJECT).map,--cref
31LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
32
33ifeq ($(DEBUG), 1)
34 CC_FLAGS += -DDEBUG -O0
35else
36 CC_FLAGS += -DNDEBUG -Os
37endif
38
39all: $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).hex
40
41clean:
42 rm -f $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).elf $(OBJDIR)/$(PROJECT).hex $(OBJDIR)/$(PROJECT).map $(OBJDIR)/$(PROJECT).lst $(OBJECTS) $(DEPS)
43 rm -fr $(OBJDIR)
44
45$(OBJDIR)/%.o: %.s
46 mkdir -p $(@D)
47 $(AS) $(CPU) -o $@ $<
48
49$(OBJDIR)/%.o: %.c
50 mkdir -p $(@D)
51 $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $<
52
53$(OBJDIR)/%.o: %.cpp
54 mkdir -p $(@D)
55 $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $<
56
57
58$(OBJDIR)/$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
59 $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)
60 $(SIZE) $@
61
62$(OBJDIR)/$(PROJECT).bin: $(OBJDIR)/$(PROJECT).elf
63 @$(OBJCOPY) -O binary $< $@
64ifneq (,$(findstring TARGET_NXP,$(CC_SYMBOLS)))
65 @echo
66 @echo "For NXP writing vector checksum value into $@ ..."
67 @$(CHKSUM) $@
68 @echo
69endif
70
71$(OBJDIR)/$(PROJECT).hex: $(OBJDIR)/$(PROJECT).elf
72 @$(OBJCOPY) -O ihex $< $@
73
74$(OBJDIR)/$(PROJECT).lst: $(OBJDIR)/$(PROJECT).elf
75 @$(OBJDUMP) -Sdh $< > $@
76
77lst: $(OBJDIR)/$(PROJECT).lst
78
79size:
80 $(SIZE) $(OBJDIR)/$(PROJECT).elf
81
82prog: $(OBJDIR)/$(PROJECT).bin
83 @echo "Program..."
84ifneq ($(shell mount | grep 'CRP DISABLD'),)
85 umount /dev/nxpisp >/dev/null 2>&1
86endif
87 dd if=$< of=/dev/nxpisp seek=4
88
89DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d)
90-include $(DEPS)
Imprint / Impressum