candleLight_fw/Makefile

85 lines
2.2 KiB
Makefile
Raw Normal View History

TOOLCHAIN ?= arm-none-eabi-
2016-04-17 13:02:03 +02:00
CC = $(TOOLCHAIN)gcc
OBJCOPY = $(TOOLCHAIN)objcopy
SIZE = $(TOOLCHAIN)size
2016-04-17 13:02:03 +02:00
CFLAGS = -c -std=gnu11 -mcpu=cortex-m0 -mthumb -Os
2016-04-17 13:02:03 +02:00
CFLAGS += -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants
CFLAGS += -Wall -Wextra -g3 -D$(CHIP) -D BOARD=BOARD_$(BOARD)
2016-04-17 13:02:03 +02:00
INCLUDES = -I"include"
INCLUDES += -I"system/include" -I"system/include/cmsis" -I"system/include/stm32f0xx" -I"system/include/cmsis/device"
INCLUDES += -I"Middlewares/ST/STM32_USB_Device_Library/Core/Inc"
LDFLAGS = -mcpu=cortex-m0 -mthumb -O
LDFLAGS += -Wall -Wextra -g3
LDFLAGS += -T ldscripts/mem.ld -T ldscripts/libs.ld -T ldscripts/sections.ld
LDFLAGS += -nostartfiles -Xlinker --gc-sections --specs=nano.specs
2016-04-17 13:02:03 +02:00
2016-04-17 13:05:30 +02:00
SRC = $(wildcard src/*.c)
SRC += $(wildcard system/src/stm32f0xx/*.c)
SRC += $(wildcard system/src/newlib/*.c)
SRC += $(wildcard system/src/cortexm/*.c)
SRC += $(wildcard system/src/cmsis/*.c)
SRC += $(wildcard Middlewares/ST/STM32_USB_Device_Library/Core/Src/*.c)
OBJ = $(patsubst %.c,build/$(BOARD)/%.o,$(SRC))
DEP = $(OBJ:%.o=%.d)
2017-05-12 23:31:39 +02:00
ASM_SRC = system/src/cmsis/startup_stm32f042x6.S
ASM_OBJ += $(patsubst %.S,build/$(BOARD)/%.asmo,$(ASM_SRC))
DEP += $(ASM_OBJ:%.asmo=%.d)
2016-04-17 13:02:03 +02:00
ELF = build/$(BOARD)/gsusb_$(BOARD).elf
BIN = bin/gsusb_$(BOARD).bin
all: candleLight cantact
2016-04-18 16:21:35 +02:00
.PHONY : clean all
clean:
$(MAKE) BOARD=candleLight board-clean
$(MAKE) BOARD=cantact board-clean
2016-04-17 13:02:03 +02:00
candleLight:
2017-05-12 23:31:39 +02:00
$(MAKE) CHIP=STM32F042x6 BOARD=candleLight bin
2016-04-17 13:02:03 +02:00
flash-candleLight:
2017-05-12 23:31:39 +02:00
$(MAKE) CHIP=STM32F042x6 BOARD=candleLight board-flash
2016-04-17 13:02:03 +02:00
cantact:
$(MAKE) CHIP=STM32F072xB BOARD=cantact bin
flash-cantact:
$(MAKE) CHIP=STM32F072xB BOARD=cantact board-flash
board-flash: bin
sudo dfu-util -d 1d50:606f -a 0 -s 0x08000000 -D $(BIN)
2016-04-17 13:02:03 +02:00
bin: $(BIN)
$(BIN): $(ELF)
@mkdir -p $(dir $@)
$(OBJCOPY) -O binary $(ELF) $(BIN)
$(SIZE) --format=berkeley $(ELF)
$(ELF): $(OBJ) $(ASM_OBJ)
2016-04-17 13:02:03 +02:00
@mkdir -p $(dir $@)
$(CC) $(LDFLAGS) -o $@ $(OBJ) $(ASM_OBJ)
-include $(DEP)
2016-04-17 13:02:03 +02:00
build/$(BOARD)/%.o : %.c
@echo $<
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INCLUDES) -MMD -c $< -o $@
build/$(BOARD)/%.asmo : %.S
@echo $<
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INCLUDES) -MMD -c $< -o $@
.PHONY : board-clean
board-clean :
-rm -f $(BIN) $(OBJ) $(ASM_OBJ) $(DEP)