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-09-25 19:49:49 +02:00
|
|
|
ROM_SIZE = 1028k
|
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)))
|
2021-08-23 21:40:37 +02:00
|
|
|
# IMG_FILES = $(wildcard $(patsubst %, %/*.png, . $(SRC_DIRS)))
|
2021-02-09 23:58:02 +01:00
|
|
|
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-18 13:54:07 +02:00
|
|
|
CFLAGS = $(COMMONFLAGS) -std=gnu11 -Os -Wall -I$(ROOTDIR)/mips64-elf/include $(INC_DIRS) -ffunction-sections -fdata-sections -Wl,--gc-sections
|
2021-08-23 21:40:37 +02: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
|
|
|
|
|
|
|
|
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
|
|
|
|
$(CHKSUM64) $(BUILD_DIR)/$(PROG_NAME).z64
|
2021-09-25 19:49:49 +02:00
|
|
|
truncate --size=90k $(BUILD_DIR)/$(PROG_NAME).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-08-23 21:40:37 +02:00
|
|
|
# $(BUILD_DIR)/%.sprite: $(IMG_FILES)
|
|
|
|
# $(MKSPRITE) 32 $< $@
|
2021-02-09 23:58:02 +01:00
|
|
|
|
2021-08-23 21:40:37 +02:00
|
|
|
# $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.sprite
|
|
|
|
# $(OBJCOPY) -I binary -O elf32-bigmips -B mips:4000 --rename-section .data=.rodata $< $@
|
2021-02-09 23:58:02 +01:00
|
|
|
|
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
|