Add keyboard/mbed_onekey
[tmk_keyboard.git] / keyboard / mbed_onekey / gcc.mk
1 ###############################################################################
2 GCC_BIN =
3 AS = $(GCC_BIN)arm-none-eabi-as
4 CC = $(GCC_BIN)arm-none-eabi-gcc
5 CPP = $(GCC_BIN)arm-none-eabi-g++
6 LD = $(GCC_BIN)arm-none-eabi-gcc
7 OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy
8 OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump
9 SIZE = $(GCC_BIN)arm-none-eabi-size
10 CHKSUM = ~/Dropbox/MBED/tool/lpc-vector-checksum
11
12 CPU = -mcpu=cortex-m0 -mthumb
13 CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections
14 CC_FLAGS += -MMD -MP
15 CC_SYMBOLS = -DTARGET_LPC11U35_401 -DTARGET_M0 -DTARGET_NXP -DTARGET_LPC11UXX -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M0 -DARM_MATH_CM0 -DMBED_BUILD_TIMESTAMP=1399108688.49 -D__MBED__=1
16
17 LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs
18 LD_FLAGS += -Wl,-Map=$(OBJDIR)/$(PROJECT).map,--cref
19 LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
20
21 ifeq ($(DEBUG), 1)
22 CC_FLAGS += -DDEBUG -O0
23 else
24 CC_FLAGS += -DNDEBUG -Os
25 endif
26
27 all: $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).hex size
28
29 clean:
30 rm -f $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).elf $(OBJDIR)/$(PROJECT).hex $(OBJDIR)/$(PROJECT).map $(OBJDIR)/$(PROJECT).lst $(OBJECTS) $(DEPS)
31 rm -fr $(OBJDIR)
32
33 $(OBJDIR)/%.o: %.s
34 mkdir -p $(@D)
35 $(AS) $(CPU) -o $@ $<
36
37 $(OBJDIR)/%.o: %.c
38 mkdir -p $(@D)
39 $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $<
40
41 $(OBJDIR)/%.o: %.cpp
42 mkdir -p $(@D)
43 $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 $(INCLUDE_PATHS) -o $@ $<
44
45
46 $(OBJDIR)/$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
47 $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)
48 @echo ""
49 @echo "*****"
50 @echo "***** You must modify vector checksum value in *.bin and *.hex files."
51 @echo "*****"
52 @echo ""
53
54 $(OBJDIR)/$(PROJECT).bin: $(OBJDIR)/$(PROJECT).elf
55 @$(OBJCOPY) -O binary $< $@
56 @echo "Writing vector checksum value into $@ ..."
57 @$(CHKSUM) $@
58 @echo
59
60 $(OBJDIR)/$(PROJECT).hex: $(OBJDIR)/$(PROJECT).elf
61 @$(OBJCOPY) -O ihex $< $@
62
63 $(OBJDIR)/$(PROJECT).lst: $(OBJDIR)/$(PROJECT).elf
64 @$(OBJDUMP) -Sdh $< > $@
65
66 lst: $(OBJDIR)/$(PROJECT).lst
67
68 size:
69 $(SIZE) $(OBJDIR)/$(PROJECT).elf
70
71 prog: $(OBJDIR)/$(PROJECT).bin
72 @echo "Program..."
73 ifneq ($(shell mount | grep 'CRP DISABLD'),)
74 umount /dev/nxpisp >/dev/null 2>&1
75 endif
76 dd if=$< of=/dev/nxpisp seek=4
77
78 DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d)
79 -include $(DEPS)
Imprint / Impressum