2021-09-25 20:00:36 +02:00
|
|
|
TOOLCHAIN = riscv32-unknown-elf-
|
|
|
|
CC = $(TOOLCHAIN)gcc
|
2021-12-10 17:36:30 +01:00
|
|
|
CXX = $(TOOLCHAIN)g++
|
2021-09-25 20:00:36 +02:00
|
|
|
OBJCOPY = $(TOOLCHAIN)objcopy
|
2021-11-16 22:37:48 +01:00
|
|
|
OBJDUMP = $(TOOLCHAIN)objdump
|
2021-09-25 20:00:36 +02:00
|
|
|
SIZE = $(TOOLCHAIN)size
|
|
|
|
|
2021-12-10 17:36:30 +01:00
|
|
|
FLAGS = -mabi=ilp32 -march=rv32i $(USER_FLAGS)
|
2021-09-25 20:00:36 +02:00
|
|
|
CFLAGS = -Os -Wall -ffunction-sections -fdata-sections -ffreestanding -MMD -MP
|
|
|
|
LDFLAGS = -nostartfiles -Wl,--gc-sections
|
|
|
|
|
|
|
|
SRC_DIR = src
|
|
|
|
BUILD_DIR = build
|
|
|
|
|
2021-12-27 00:01:07 +01:00
|
|
|
SRC_FILES = \
|
|
|
|
startup.S \
|
|
|
|
process.c \
|
|
|
|
usb.c \
|
|
|
|
cfg.c \
|
|
|
|
dma.c \
|
|
|
|
joybus.c \
|
|
|
|
rtc.c \
|
|
|
|
i2c.c \
|
|
|
|
flashram.c \
|
|
|
|
uart.c \
|
|
|
|
flash.c \
|
|
|
|
dd.c \
|
|
|
|
isv.c
|
2021-11-16 22:37:48 +01:00
|
|
|
|
|
|
|
SRCS = $(addprefix $(SRC_DIR)/, $(SRC_FILES))
|
|
|
|
OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(patsubst %,%.o,$(SRCS))))
|
2021-09-25 20:00:36 +02:00
|
|
|
DEPS = $(OBJS:.o=.d)
|
|
|
|
|
|
|
|
VPATH = $(SRC_DIR)
|
|
|
|
|
|
|
|
$(@info $(shell mkdir -p ./$(BUILD_DIR) &> /dev/null))
|
|
|
|
|
2021-12-10 17:36:30 +01:00
|
|
|
$(BUILD_DIR)/%.S.o: %.S
|
|
|
|
$(CC) -x assembler-with-cpp $(FLAGS) $(CFLAGS) -c $< -o $@
|
2021-09-25 20:00:36 +02:00
|
|
|
|
2021-11-16 22:37:48 +01:00
|
|
|
$(BUILD_DIR)/%.c.o: %.c
|
2021-12-10 17:36:30 +01:00
|
|
|
$(CC) $(FLAGS) $(CFLAGS) -c $< -o $@
|
2021-09-25 20:00:36 +02:00
|
|
|
|
2021-12-10 17:36:30 +01:00
|
|
|
$(BUILD_DIR)/governor.elf: $(OBJS) SC64.ld
|
|
|
|
$(CXX) $(FLAGS) $(LDFLAGS) -TSC64.ld $(OBJS) -o $@
|
|
|
|
@$(OBJDUMP) -D $@ > $(BUILD_DIR)/governor.lst
|
|
|
|
|
|
|
|
$(BUILD_DIR)/governor.bin: $(BUILD_DIR)/governor.elf
|
|
|
|
@$(OBJCOPY) -O binary $< $@
|
2021-09-25 20:00:36 +02:00
|
|
|
|
2021-12-10 17:36:30 +01:00
|
|
|
$(BUILD_DIR)/governor.hex: $(BUILD_DIR)/governor.bin
|
|
|
|
@$(OBJCOPY) -I binary -O ihex $< $@
|
|
|
|
|
|
|
|
print_size: $(BUILD_DIR)/governor.elf
|
2021-11-16 22:37:48 +01:00
|
|
|
@echo 'Size of modules:'
|
2021-12-10 17:36:30 +01:00
|
|
|
@$(SIZE) -B -d -t --common $(OBJS)
|
2021-11-16 22:37:48 +01:00
|
|
|
@echo 'Size of governor:'
|
2021-12-10 17:36:30 +01:00
|
|
|
@$(SIZE) -B -d $<
|
|
|
|
|
|
|
|
all: $(BUILD_DIR)/governor.hex print_size
|
2021-09-25 20:00:36 +02:00
|
|
|
|
|
|
|
clean:
|
2021-12-10 17:36:30 +01:00
|
|
|
@rm -rf ./$(BUILD_DIR)/*
|
2021-09-25 20:00:36 +02:00
|
|
|
|
2021-12-10 17:36:30 +01:00
|
|
|
.PHONY: all clean print_size
|
2021-09-25 20:00:36 +02:00
|
|
|
|
|
|
|
-include $(DEPS)
|