SummerCart64/sw/bootloader/Makefile

71 lines
2.4 KiB
Makefile
Raw Normal View History

2020-10-08 02:04:42 +02:00
ROOTDIR = $(N64_INST)
2021-02-09 23:58:02 +01:00
2020-10-08 02:04:42 +02:00
GCCN64PREFIX = $(ROOTDIR)/bin/mips64-elf-
CC = $(GCCN64PREFIX)gcc
AS = $(GCCN64PREFIX)as
LD = $(GCCN64PREFIX)ld
OBJCOPY = $(GCCN64PREFIX)objcopy
OBJDUMP = $(GCCN64PREFIX)objdump
2021-02-09 23:58:02 +01:00
CHKSUM64 = $(ROOTDIR)/bin/chksum64
MKSPRITE = $(ROOTDIR)/bin/mksprite
N64TOOL = $(ROOTDIR)/bin/n64tool
HEADER_PATH = $(ROOTDIR)/mips64-elf/lib
HEADER_NAME = header
PROG_NAME = SummerLoader64
2020-10-08 02:04:42 +02:00
2021-08-12 21:07:47 +02:00
ROM_SIZE = 1k
2020-10-08 02:04:42 +02:00
2021-02-09 23:58:02 +01:00
SOURCE_DIR = src
BUILD_DIR = build
2020-10-08 02:04:42 +02:00
2021-02-09 23:58:02 +01:00
SRC_DIRS = $(SOURCE_DIR) $(sort $(dir $(wildcard $(SOURCE_DIR)/*/.)))
2021-03-11 00:10:32 +01:00
INC_DIRS = $(addprefix -I, . $(SRC_DIRS)) -I./libsc64/inc
2021-02-09 23:58:02 +01:00
SRC_FILES = $(wildcard $(patsubst %, %/*.c, . $(SRC_DIRS)))
IMG_FILES = $(wildcard $(patsubst %, %/*.png, . $(SRC_DIRS)))
OBJ_FILES = $(addprefix $(BUILD_DIR)/, $(notdir $(IMG_FILES:.png=.o) $(SRC_FILES:.c=.o)))
VPATH = $(SRC_DIRS)
2020-10-08 02:04:42 +02:00
2021-02-09 23:58:02 +01:00
COMMONFLAGS = -march=vr4300 -mtune=vr4300
ASFLAGS = $(COMMONFLAGS)
2021-08-12 21:07:47 +02:00
CFLAGS = $(COMMONFLAGS) -std=gnu11 -Os -Wall -I$(ROOTDIR)/mips64-elf/include $(INC_DIRS)
2021-03-11 00:10:32 +01:00
LINK_FLAGS = -L$(ROOTDIR)/mips64-elf/lib -ldragon -lc -lm -ldragonsys -Tn64.ld -L./libsc64/lib -lsc64_libdragon
2021-02-09 23:58:02 +01:00
N64_FLAGS = -l $(ROM_SIZE) -h $(HEADER_PATH)/$(HEADER_NAME) -o $(BUILD_DIR)/$(PROG_NAME).z64
N64_FLAGS_PADDED = -l 1028k -h $(HEADER_PATH)/$(HEADER_NAME) -o $(BUILD_DIR)/$(PROG_NAME)_padded.z64
2021-02-09 23:58:02 +01:00
all: make_output_dir $(BUILD_DIR)/$(PROG_NAME).z64
2020-10-08 02:04:42 +02:00
$(OBJ_FILES): Makefile
2021-02-09 23:58:02 +01:00
$(BUILD_DIR)/$(PROG_NAME).z64: $(BUILD_DIR)/$(PROG_NAME).elf
$(OBJCOPY) $(BUILD_DIR)/$(PROG_NAME).elf $(BUILD_DIR)/$(PROG_NAME).bin -O binary
$(OBJDUMP) -S $(BUILD_DIR)/$(PROG_NAME).elf > $(BUILD_DIR)/$(PROG_NAME).lst
$(N64TOOL) $(N64_FLAGS) -t $(PROG_NAME) $(BUILD_DIR)/$(PROG_NAME).bin
$(N64TOOL) $(N64_FLAGS_PADDED) -t $(PROG_NAME) $(BUILD_DIR)/$(PROG_NAME).bin
2021-02-09 23:58:02 +01:00
$(CHKSUM64) $(BUILD_DIR)/$(PROG_NAME).z64
$(CHKSUM64) $(BUILD_DIR)/$(PROG_NAME)_padded.z64
2021-02-09 23:58:02 +01:00
$(OBJCOPY) $(BUILD_DIR)/$(PROG_NAME).z64 $(BUILD_DIR)/$(PROG_NAME).hex -I binary -O ihex
2020-10-08 02:04:42 +02:00
2021-02-09 23:58:02 +01:00
$(BUILD_DIR)/$(PROG_NAME).elf: $(OBJ_FILES)
$(LD) -o $(BUILD_DIR)/$(PROG_NAME).elf $(OBJ_FILES) $(LINK_FLAGS)
2020-10-08 02:04:42 +02:00
2021-02-09 23:58:02 +01:00
$(BUILD_DIR)/%.o: %.c
2020-10-08 02:04:42 +02:00
$(COMPILE.c) $(OUTPUT_OPTION) $<
2021-02-09 23:58:02 +01:00
$(BUILD_DIR)/%.sprite: $(IMG_FILES)
$(MKSPRITE) 32 $< $@
$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.sprite
$(OBJCOPY) -I binary -O elf32-bigmips -B mips:4000 --rename-section .data=.rodata $< $@
2020-10-08 02:04:42 +02:00
make_output_dir:
2021-02-09 23:58:02 +01:00
$(shell mkdir ./$(BUILD_DIR) 2> /dev/null)
2020-10-08 02:04:42 +02:00
clean:
2021-02-09 23:58:02 +01:00
$(shell rm -rf ./$(BUILD_DIR) 2> /dev/null)
2020-10-08 02:04:42 +02:00
.PHONY: all clean make_output_dir