SummerCart64/sw/n64/Makefile

70 lines
1.6 KiB
Makefile
Raw Normal View History

2021-11-25 23:11:36 +01:00
TOOLCHAIN = mips64-elf-
CC = $(TOOLCHAIN)gcc
CXX = $(TOOLCHAIN)g++
OBJCOPY = $(TOOLCHAIN)objcopy
OBJDUMP = $(TOOLCHAIN)objdump
SIZE = $(TOOLCHAIN)size
FLAGS = -march=vr4300 -mtune=vr4300 -falign-functions=32 $(USER_FLAGS)
2021-12-04 19:34:34 +01:00
CFLAGS = -Os -Wall -ffunction-sections -fdata-sections -ffreestanding -MMD -MP
2021-11-30 00:47:35 +01:00
ASFLAGS = -Wa,-I$(N64_INST)/mips64-elf/lib
2021-11-25 23:11:36 +01:00
LDFLAGS = -lc -nostartfiles -Wl,--gc-sections
SRC_DIR = src
BUILD_DIR = build
2021-12-04 19:34:34 +01:00
SRC_FILES = \
startup.S \
boot.c \
crc32.c \
init.c \
main.c \
sc64.c \
sys.c \
syscalls.c \
fatfs/diskio.c \
fatfs/ff.c \
fatfs/ffsystem.c \
fatfs/ffunicode.c
2021-11-25 23:11:36 +01:00
SRCS = $(addprefix $(SRC_DIR)/, $(SRC_FILES))
OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(patsubst %,%.o,$(SRCS))))
DEPS = $(OBJS:.o=.d)
2021-12-04 19:34:34 +01:00
VPATH = $(SRC_DIR) $(SRC_DIR)/fatfs
2021-11-25 23:11:36 +01:00
$(@info $(shell mkdir -p ./$(BUILD_DIR) &> /dev/null))
2021-11-25 23:11:36 +01:00
$(BUILD_DIR)/%.S.o: %.S
2021-11-30 00:47:35 +01:00
$(CC) -x assembler-with-cpp $(FLAGS) $(ASFLAGS) $(CFLAGS) -c $< -o $@
2021-11-25 23:11:36 +01:00
$(BUILD_DIR)/%.c.o: %.c
$(CC) $(FLAGS) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/n64boot.elf: $(OBJS) N64.ld
$(CXX) $(FLAGS) $(LDFLAGS) -TN64.ld $(OBJS) -o $@
2021-12-04 19:34:34 +01:00
@$(OBJDUMP) -S $@ > $(BUILD_DIR)/n64boot.lst
2021-11-25 23:11:36 +01:00
$(BUILD_DIR)/n64boot.bin: $(BUILD_DIR)/n64boot.elf
@$(OBJCOPY) -O binary $< $@
@chksum64 $@ > /dev/null
2021-11-30 00:47:35 +01:00
@truncate --size=90k $@
2021-11-25 23:11:36 +01:00
$(BUILD_DIR)/n64boot.hex: $(BUILD_DIR)/n64boot.bin
@$(OBJCOPY) -I binary -O ihex $< $@
print_size: $(BUILD_DIR)/n64boot.elf
@echo 'Size of modules:'
@$(SIZE) -B -d -t --common $(OBJS)
@echo 'Size of n64boot:'
@$(SIZE) -B -d $<
all: $(BUILD_DIR)/n64boot.hex print_size
clean:
2021-11-25 23:11:36 +01:00
@rm -rf ./$(BUILD_DIR)/*
2021-11-25 23:11:36 +01:00
.PHONY: all clean print_size
2021-11-25 23:11:36 +01:00
-include $(DEPS)