SummerCart64/sw/controller/Makefile

71 lines
1.6 KiB
Makefile
Raw Normal View History

2022-05-15 15:47:12 +02:00
TOOLCHAIN = arm-none-eabi-
CC = $(TOOLCHAIN)gcc
CXX = $(TOOLCHAIN)g++
OBJCOPY = $(TOOLCHAIN)objcopy
OBJDUMP = $(TOOLCHAIN)objdump
SIZE = $(TOOLCHAIN)size
2022-05-15 15:47:12 +02:00
FLAGS = -mcpu=cortex-m0plus -mthumb -DSTM32G030xx $(USER_FLAGS) -g -ggdb3
CFLAGS = -Og -Wall -ffunction-sections -fdata-sections -ffreestanding -MMD -MP -I./lib
LDFLAGS = -nostartfiles -Wl,--gc-sections
SRC_DIR = src
BUILD_DIR = build
2021-12-27 00:01:07 +01:00
SRC_FILES = \
startup.S \
cfg.c \
2022-05-15 15:47:12 +02:00
cic.c \
2022-07-22 12:43:53 +02:00
dd.c \
debug.c \
2021-12-27 00:01:07 +01:00
flash.c \
2022-05-15 15:47:12 +02:00
flashram.c \
fpga.c \
gvr.c \
hw.c \
isv.c \
2022-08-01 23:30:40 +02:00
lcmxo2.c \
2022-05-15 15:47:12 +02:00
main.c \
rtc.c \
task.c \
usb.c
SRCS = $(addprefix $(SRC_DIR)/, $(SRC_FILES))
OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(patsubst %,%.o,$(SRCS))))
DEPS = $(OBJS:.o=.d)
VPATH = $(SRC_DIR)
$(@info $(shell mkdir -p ./$(BUILD_DIR) &> /dev/null))
$(BUILD_DIR)/%.S.o: %.S
$(CC) -x assembler-with-cpp $(FLAGS) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/%.c.o: %.c
$(CC) $(FLAGS) $(CFLAGS) -c $< -o $@
2022-05-15 15:47:12 +02:00
$(BUILD_DIR)/controller.elf: $(OBJS) STM32G030F6Px_FLASH.ld
$(CXX) $(FLAGS) $(LDFLAGS) -TSTM32G030F6Px_FLASH.ld $(OBJS) -o $@
@$(OBJDUMP) -S -D $@ > $(BUILD_DIR)/controller.lst
2022-05-15 15:47:12 +02:00
$(BUILD_DIR)/controller.bin: $(BUILD_DIR)/controller.elf
@$(OBJCOPY) -O binary $< $@
2022-05-15 15:47:12 +02:00
$(BUILD_DIR)/controller.hex: $(BUILD_DIR)/controller.bin
@$(OBJCOPY) -I binary -O ihex $< $@
2022-05-15 15:47:12 +02:00
print_size: $(BUILD_DIR)/controller.elf
@echo 'Size of modules:'
@$(SIZE) -B -d -t --common $(OBJS)
2022-05-15 15:47:12 +02:00
@echo 'Size of controller:'
@$(SIZE) -B -d $<
2022-05-15 15:47:12 +02:00
all: $(BUILD_DIR)/controller.hex print_size
clean:
@rm -rf ./$(BUILD_DIR)/*
.PHONY: all clean print_size
-include $(DEPS)