111 lines
3.0 KiB
Makefile
111 lines
3.0 KiB
Makefile
TARGET = firmware
|
|
|
|
DEBUG = 1
|
|
OPT = -O0
|
|
|
|
BUILD_DIR = _build
|
|
|
|
CC_SOURCES = \
|
|
Core/main.cc \
|
|
platform/stm32g0xx/Gpio.cc \
|
|
|
|
C_SOURCES = \
|
|
platform/stm32g0xx/stm32g0xx_it.c \
|
|
platform/stm32g0xx/stm32g0xx_hal_msp.c \
|
|
platform/stm32g0xx/system_stm32g0xx.c \
|
|
platform/stm32g0xx/syscalls.c \
|
|
platform/stm32g0xx/sysmem.c \
|
|
Core/print.c \
|
|
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc.c \
|
|
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal.c \
|
|
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_cortex.c \
|
|
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc_ex.c \
|
|
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr.c \
|
|
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr_ex.c \
|
|
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_iwdg.c \
|
|
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart_ex.c \
|
|
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart.c \
|
|
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_gpio.c
|
|
|
|
ASM_SOURCES = \
|
|
platform/stm32g0xx/startup_stm32g071rbtx.s
|
|
|
|
PREFIX = arm-none-eabi-
|
|
CC = $(PREFIX)gcc
|
|
CXX = $(PREFIX)g++
|
|
AS = $(PREFIX)gcc -x assembler-with-cpp
|
|
CP = $(PREFIX)objcopy
|
|
SZ = $(PREFIX)size
|
|
|
|
HEX = $(CP) -O ihex
|
|
BIN = $(CP) -O binary -S
|
|
|
|
CPU = -mcpu=cortex-m0plus
|
|
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
|
|
|
|
C_DEFS = \
|
|
-DUSE_HAL_DRIVER \
|
|
-DSTM32G071xx
|
|
|
|
C_INCLUDES = \
|
|
-I. \
|
|
-ICore \
|
|
-ILegacy/STM32G0xx_HAL_Driver/Inc \
|
|
-ILegacy/STM32G0xx_HAL_Driver/Inc/Legacy \
|
|
-Iarch/CMSIS/Device/ST/STM32G0xx/Include \
|
|
-Iarch/CMSIS/Include \
|
|
-Iplatform/stm32g0xx
|
|
|
|
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
|
|
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
CFLAGS += -ggdb3
|
|
endif
|
|
|
|
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
|
|
|
|
LDSCRIPT = platform/stm32g0xx/STM32G071RBTX_FLASH.ld
|
|
|
|
LIBS = -lc -lm -lnosys
|
|
LIBDIR =
|
|
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
|
|
|
|
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
|
|
|
|
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(CC_SOURCES:.cc=.o)))
|
|
vpath %.cc $(sort $(dir $(CC_SOURCES)))
|
|
|
|
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
|
|
vpath %.c $(sort $(dir $(C_SOURCES)))
|
|
|
|
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
|
|
vpath %.s $(sort $(dir $(ASM_SOURCES)))
|
|
|
|
$(BUILD_DIR)/%.o: %.cc Makefile | $(BUILD_DIR)
|
|
$(CXX) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.cc=.lst)) $< -o $@
|
|
|
|
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
|
|
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
|
|
|
|
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
|
|
$(AS) -c $(CFLAGS) $< -o $@
|
|
|
|
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
|
|
$(CXX) $(OBJECTS) $(LDFLAGS) -o $@
|
|
$(SZ) $@
|
|
|
|
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
|
|
$(HEX) $< $@
|
|
|
|
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
|
|
$(BIN) $< $@
|
|
|
|
$(BUILD_DIR):
|
|
mkdir $@
|
|
|
|
clean:
|
|
-rm -fR $(BUILD_DIR)
|
|
|
|
-include $(wildcard $(BUILD_DIR)/*.d)
|