-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile.rom
100 lines (75 loc) · 4.25 KB
/
makefile.rom
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
ROOTDIR = $(N64_INST)
#Specify fs wrapper (FS_N64_ROMFS , FS_N64_FATFS , FS_STD )
FS_FLAGS = -DFS_REDUCE_HEAP_FRAGMENTION -DFS_MAX_HANDLES=2 -D__FS_BUILD__=FS_N64_ROMFS -DMAX_FS_FILE_PATH=1024 -DMAX_SAVE_SLOTS=0
#-DHAVE_HW_EXTENDED_MEM
#Specify fs driver
FS_DRIVER = filesystem/drivers/dummy
#Default fs library libff or anything else
FS_DEFAULT_LIB = -lff
#NOTE (Myth64 only) : DO NOT REMOVE "N64 Myth" or the menu's loader will FAIL to detect it as mythaware app
ROM_HEADER_TITLE = "GNUBOY64rom"
#if you use these non-callee regs in inline asm make sure to save/restore them since they're manually mapped
#by the cpu interpreter (NOTE:20-23 are callee ~so skip those)
MANUALLY_ALLOCATED_REGS = -ffixed-20 -ffixed-21 -ffixed-22 -ffixed-23
HEADERDIR = $(ROOTDIR)/headers
HEADER = $(HEADERDIR)/header
TOOLDIR = $(ROOTDIR)/bin
CHKSUM64 = $(TOOLDIR)/chksum64
MKDFS = $(TOOLDIR)/mkdfs
N64TOOL = $(TOOLDIR)/n64tool
LDSCRIPTSDIR = $(ROOTDIR)/ldscripts
LINK_FLAGS = -T$(LDSCRIPTSDIR)/n64.ld -Map map.txt -nostdlib
LIBPATH = -L$(ROOTDIR)/mips64-elf/lib -L$(ROOTDIR)/mips64-elf/lib/gcc/mips64-elf/4.6.2 -L$(ROOTDIR)/mips64-elf/mips64-elf/lib
INCPATH = -I$(CURDIR)/include -I$(ROOTDIR)/mips64-elf/include -I$(ROOTDIR)/mips64-elf/mips64-elf/include
CCFLAGS = $(FS_FLAGS) -DGNUBOY_DISABLE_DEBUG_DISASSEMBLE -DHAVE_CONFIG_H -DGNUBOY_NO_MINIZIP -std=gnu99 -march=vr4300 \
-mtune=vr4300 -G 0 -O1 -Wall -c $(INCPATH) -iquoteinclude $(MANUALLY_ALLOCATED_REGS)
CCFLAGS_NO_OPT = $(FS_FLAGS) -DGNUBOY_DISABLE_DEBUG_DISASSEMBLE -DHAVE_CONFIG_H -DGNUBOY_NO_MINIZIP -std=gnu99 -march=vr4300 \
-mtune=vr4300 -O0 -G 0 -Wall -c $(INCPATH) -iquoteinclude $(MANUALLY_ALLOCATED_REGS)
#Compile emu with full opts
CCFLAGS_OPT = $(FS_FLAGS) -DGNUBOY_DISABLE_DEBUG_DISASSEMBLE -DHAVE_CONFIG_H -DGNUBOY_NO_MINIZIP -std=gnu99 -march=vr4300 \
-mtune=vr4300 -G 0 -O3 -Wall -c $(INCPATH) -iquoteinclude -ffast-math -mno-split-addresses -mno-explicit-relocs \
-mno-fp-exceptions -mno-mips16 -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop -fno-exceptions\
-fstrength-reduce -fno-delayed-branch -fschedule-insns -fschedule-insns2 -fcaller-saves -funit-at-a-time \
--param max-cse-path-length=500000 -ftracer -funswitch-loops \
-ffunction-sections -fdata-sections -fbranch-target-load-optimize2 --param max-reload-search-insns=10000 \
--param max-last-value-rtl=100000 --param max-reload-search-insns=100000 --param max-cse-path-length=500000 \
--param max-crossjump-edges=100000 --param max-delay-slot-insn-search=10000 --param max-delay-slot-live-search=1000 \
-fbranch-target-load-optimize -frename-registers -foptimize-register-move \
-fmodulo-sched -fgcse-lm $(MANUALLY_ALLOCATED_REGS)
#
ASFLAGS = -mtune=vr4300 -march=vr4300
N64PREFIX = $(ROOTDIR)/mips64-elf/bin/mips64-elf-
CC = $(N64PREFIX)gcc
AS = $(N64PREFIX)as
LD = $(N64PREFIX)ld
OBJCOPY = $(N64PREFIX)objcopy
PROG_NAME = gnuboy64
OBJS = ctl.no_opt stack_based_qsort.emu_opt rdp_srec.no_opt rdp_srec_tex_format.emu_opt pcm_ring_buf.emu_opt main.emu_opt \
media.emu_opt wstring.emu_opt $(patsubst %.c,%.o,$(wildcard filesystem/*.c)) \
$(patsubst %.c,%.emu_opt,$(wildcard emu_core/*.c)) $(patsubst %.c,%.no_opt,$(wildcard emu_asm/*.c)) \
$(patsubst %.c,%.emu_opt,$(wildcard umem/*.c)) $(patsubst %.c,%.no_opt,$(wildcard emu_core/no_opt/*.c)) \
$(patsubst %.c,%.emu_opt,$(wildcard mem_map/*.c))
LIBS = -ldragon -lc -lm -ldragonsys $(FS_DEFAULT_LIB)
OBJS += $(patsubst %.c,%.o,$(wildcard $(FS_DRIVER)/*.c)) $(patsubst %.s,%.o,$(wildcard $(FS_DRIVER)/*.s))
$(PROG_NAME).z64: $(PROG_NAME).elf
$(OBJCOPY) $(PROG_NAME).elf $(PROG_NAME).bin -O binary
rm -f $(PROG_NAME).z64
$(N64TOOL) -l 2M -t $(ROM_HEADER_TITLE) -h $(HEADER) -o $(PROG_NAME).z64 $(PROG_NAME).bin
$(CHKSUM64) $(PROG_NAME).z64
$(PROG_NAME).elf : $(OBJS)
$(LD) -o $(PROG_NAME).elf $(OBJS) $(LINK_FLAGS) $(LIBPATH) $(LIBS)
%.o: %.c
$(CC) $(CCFLAGS) $< -o $@
#Turn on max optimizations only for EMU CORE
#-S -fverbose-asm
%.emu_opt: %.c
$(CC) $(CCFLAGS_OPT) $< -o $@
%.no_opt: %.c
$(CC) $(CCFLAGS_NO_OPT) $< -o $@
#%.emu_opt: %.c
# $(CC) $(CCFLAGS_OPT) -S $< -o $@
%.o: %.s
$(AS) $(ASFLAGS) $< -o $@
all: $(PROG_NAME).z64
clean:
rm -f *.z64 *.elf *.o *.emu_opt *.bin map.txt filesystem/*.o emu_core/*.o emu_core/*.emu_opt $(FS_DRIVER)/*.o emu_asm/*.no_opt umem/*.emu_opt *.no_opt emu_core/no_opt/*.no_opt mem_map/*.emu_opt