mirror of
https://github.com/candle-usb/candleLight_fw.git
synced 2025-01-14 05:42:53 +08:00
72 lines
1.9 KiB
Makefile
72 lines
1.9 KiB
Makefile
TOOLCHAIN ?= arm-none-eabi-
|
|
|
|
CC = $(TOOLCHAIN)gcc
|
|
OBJCOPY = $(TOOLCHAIN)objcopy
|
|
SIZE = $(TOOLCHAIN)size
|
|
|
|
CFLAGS = -c -std=gnu11 -mcpu=cortex-m0 -mthumb -Os
|
|
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)
|
|
|
|
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 = -T ldscripts/mem.ld -T ldscripts/libs.ld -T ldscripts/sections.ld -nostartfiles -Xlinker --gc-sections --specs=nano.specs
|
|
|
|
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)
|
|
|
|
ASM_SRC = system/src/cmsis/startup_stm32f072xb.S
|
|
ASM_OBJ += $(patsubst %.S,build/$(BOARD)/%.asmo,$(ASM_SRC))
|
|
DEP += $(ASM_OBJ:%.asmo=%.d)
|
|
|
|
ELF = build/$(BOARD)/gsusb_$(BOARD).elf
|
|
BIN = bin/gsusb_$(BOARD).bin
|
|
|
|
all: candleLight cantact
|
|
|
|
.PHONY : clean
|
|
clean:
|
|
$(MAKE) BOARD=candleLight board-clean
|
|
$(MAKE) BOARD=cantact board-clean
|
|
|
|
candleLight:
|
|
$(MAKE) CHIP=STM32F072xB BOARD=candleLight bin
|
|
|
|
cantact:
|
|
$(MAKE) CHIP=STM32F072xB BOARD=cantact bin
|
|
|
|
bin: $(BIN)
|
|
|
|
$(BIN): $(ELF)
|
|
@mkdir -p $(dir $@)
|
|
$(OBJCOPY) -O binary $(ELF) $(BIN)
|
|
$(SIZE) --format=berkeley $(ELF)
|
|
|
|
$(ELF): $(OBJ) $(ASM_OBJ)
|
|
@mkdir -p $(dir $@)
|
|
$(CC) $(LDFLAGS) $(OBJ) $(ASM_OBJ) -o $@
|
|
|
|
-include $(DEP)
|
|
|
|
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)
|