Squashed 'tmk_core/' content from commit 05caacc
[tmk_keyboard.git] / tool / mbed / gcc.mk
CommitLineData
a074364c 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
26
27LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs
28#LD_FLAGS += -u _printf_float -u _scanf_float
29LD_FLAGS += -Wl,-Map=$(OBJDIR)/$(PROJECT).map,--cref
30LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
31
32ifeq ($(DEBUG), 1)
33 CC_FLAGS += -DDEBUG -O0
34else
35 CC_FLAGS += -DNDEBUG -Os
36endif
37
38all: $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).hex
39
40clean:
41 rm -f $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).elf $(OBJDIR)/$(PROJECT).hex $(OBJDIR)/$(PROJECT).map $(OBJDIR)/$(PROJECT).lst $(OBJECTS) $(DEPS)
42 rm -fr $(OBJDIR)
43
44$(OBJDIR)/%.o: %.s
45 mkdir -p $(@D)
46 $(AS) $(CPU) -o $@ $<
47
48$(OBJDIR)/%.o: %.c
49 mkdir -p $(@D)
50 $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $<
51
52$(OBJDIR)/%.o: %.cpp
53 mkdir -p $(@D)
54 $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $<
55
56
57$(OBJDIR)/$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
58 $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)
59 $(SIZE) $@
60
61$(OBJDIR)/$(PROJECT).bin: $(OBJDIR)/$(PROJECT).elf
62 @$(OBJCOPY) -O binary $< $@
63ifneq (,$(findstring TARGET_NXP,$(CC_SYMBOLS)))
64 @echo
65 @echo "For NXP writing vector checksum value into $@ ..."
66 @$(CHKSUM) $@
67 @echo
68endif
69
70$(OBJDIR)/$(PROJECT).hex: $(OBJDIR)/$(PROJECT).elf
71 @$(OBJCOPY) -O ihex $< $@
72
73$(OBJDIR)/$(PROJECT).lst: $(OBJDIR)/$(PROJECT).elf
74 @$(OBJDUMP) -Sdh $< > $@
75
76lst: $(OBJDIR)/$(PROJECT).lst
77
78size:
79 $(SIZE) $(OBJDIR)/$(PROJECT).elf
80
81prog: $(OBJDIR)/$(PROJECT).bin
82 @echo "Program..."
83ifneq ($(shell mount | grep 'CRP DISABLD'),)
84 umount /dev/nxpisp >/dev/null 2>&1
85endif
86 dd if=$< of=/dev/nxpisp seek=4
87
88DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d)
89-include $(DEPS)
Imprint / Impressum