1
0
tmk_keyboard/tool/mbed/gcc.mk

90 lines
2.3 KiB
Makefile
Raw Normal View History

2014-12-14 04:59:22 +00:00
# based on Makefile exported form mbed.org
# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
2014-06-15 04:56:17 +00:00
GCC_BIN =
AS = $(GCC_BIN)arm-none-eabi-as
CC = $(GCC_BIN)arm-none-eabi-gcc
CPP = $(GCC_BIN)arm-none-eabi-g++
LD = $(GCC_BIN)arm-none-eabi-gcc
OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy
OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump
SIZE = $(GCC_BIN)arm-none-eabi-size
2014-06-20 06:30:10 +00:00
CHKSUM = $(TMK_DIR)/tool/mbed/lpc-vector-checksum
2014-06-15 04:56:17 +00:00
2014-12-14 04:59:22 +00:00
CC_FLAGS += \
$(CPU) \
-c \
-g \
-fno-common \
-fmessage-length=0 \
-Wall \
-fno-exceptions \
-ffunction-sections \
-fdata-sections \
-fomit-frame-pointer
2014-06-15 04:56:17 +00:00
CC_FLAGS += -MMD -MP
2014-12-14 04:59:22 +00:00
LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs
#LD_FLAGS += -u _printf_float -u _scanf_float
2014-06-15 04:56:17 +00:00
LD_FLAGS += -Wl,-Map=$(OBJDIR)/$(PROJECT).map,--cref
LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
ifeq ($(DEBUG), 1)
CC_FLAGS += -DDEBUG -O0
else
CC_FLAGS += -DNDEBUG -Os
endif
2014-12-14 04:59:22 +00:00
all: $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).hex
2014-06-15 04:56:17 +00:00
clean:
rm -f $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).elf $(OBJDIR)/$(PROJECT).hex $(OBJDIR)/$(PROJECT).map $(OBJDIR)/$(PROJECT).lst $(OBJECTS) $(DEPS)
rm -fr $(OBJDIR)
$(OBJDIR)/%.o: %.s
mkdir -p $(@D)
$(AS) $(CPU) -o $@ $<
$(OBJDIR)/%.o: %.c
mkdir -p $(@D)
$(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $<
$(OBJDIR)/%.o: %.cpp
mkdir -p $(@D)
2014-12-14 04:59:22 +00:00
$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $<
2014-06-15 04:56:17 +00:00
$(OBJDIR)/$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
$(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)
2014-12-14 04:59:22 +00:00
$(SIZE) $@
2014-06-15 04:56:17 +00:00
$(OBJDIR)/$(PROJECT).bin: $(OBJDIR)/$(PROJECT).elf
@$(OBJCOPY) -O binary $< $@
2014-12-14 04:59:22 +00:00
ifneq (,$(findstring TARGET_NXP,$(CC_SYMBOLS)))
@echo
@echo "For NXP writing vector checksum value into $@ ..."
2014-06-15 04:56:17 +00:00
@$(CHKSUM) $@
@echo
2014-12-14 04:59:22 +00:00
endif
2014-06-15 04:56:17 +00:00
$(OBJDIR)/$(PROJECT).hex: $(OBJDIR)/$(PROJECT).elf
@$(OBJCOPY) -O ihex $< $@
$(OBJDIR)/$(PROJECT).lst: $(OBJDIR)/$(PROJECT).elf
@$(OBJDUMP) -Sdh $< > $@
lst: $(OBJDIR)/$(PROJECT).lst
size:
$(SIZE) $(OBJDIR)/$(PROJECT).elf
prog: $(OBJDIR)/$(PROJECT).bin
@echo "Program..."
ifneq ($(shell mount | grep 'CRP DISABLD'),)
umount /dev/nxpisp >/dev/null 2>&1
endif
dd if=$< of=/dev/nxpisp seek=4
DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d)
-include $(DEPS)