forked from PartyPlanner64/mpsource
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (77 loc) · 2.62 KB
/
Makefile
File metadata and controls
109 lines (77 loc) · 2.62 KB
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
101
102
103
104
105
106
107
108
109
# Makefile to rebuild Mario Party (US) split image
################ Target Executable and Sources ###############
# BUILD_DIR is location where all build artifacts are placed
BUILD_DIR = build
# Directories containing source files
SRC_DIRS := src src/overlays
ASM_DIRS := asm asm/overlays
# If COMPARE is 1, check the output sha1sum when building 'all'
COMPARE = 1
# Source code files
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))
S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s))
# Object files
O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \
$(foreach file,$(S_FILES),$(BUILD_DIR)/$(file:.s=.o))
MIPSISET := -mips2
##################### Compiler Options #######################
CROSS = mips-linux-gnu-
CC = $(CROSS)gcc
LD = $(CROSS)ld
CPP := cpp -P
OBJDUMP = $(CROSS)objdump
OBJCOPY = $(CROSS)objcopy --pad-to=0x2000000 --gap-fill=0xFF
ASFLAGS := -march=vr4300 -mabi=32 -G 0 -I include
CFLAGS := -O1 -G 0 -quiet -mfix4300 -mcpu=r4300 $(MIPSISET)
LDFLAGS = undefined_syms.txt -T $(LD_SCRIPT) -Map $(BUILD_DIR)/mp1.us.map
####################### Other Tools #########################
# N64 tools
TOOLS_DIR = tools
AS = $(TOOLS_DIR)/mips-linux-gnu-as
CC1 = $(TOOLS_DIR)/mips-cc1
MIO0TOOL = $(TOOLS_DIR)/mio0
N64CKSUM = $(TOOLS_DIR)/n64cksum
N64GRAPHICS = $(TOOLS_DIR)/n64graphics
EMULATOR = mupen64plus
EMU_FLAGS = --noosd
LOADER = loader64
LOADER_FLAGS = -vwf
SHA1SUM = sha1sum
######################## Targets #############################
build/asm/libs.o: MIPSISET := -mips3
default: all
# file dependencies generated by splitter
MAKEFILE_SPLIT = Makefile.split
include $(MAKEFILE_SPLIT)
all: $(BUILD_DIR)/$(TARGET).z64
ifeq ($(COMPARE),1)
@$(SHA1SUM) -c $(TARGET).sha1
endif
clean:
$(RM) -r $(BUILD_DIR)
$(MIO0_DIR)/%.mio0: $(MIO0_DIR)/%.bin
$(MIO0TOOL) $< $@
$(BUILD_DIR):
mkdir $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS))
$(BUILD_DIR)/%.i: %.c
$(CPP) $< -o $@
$(BUILD_DIR)/%.s: $(BUILD_DIR)/%.i $(BUILD_DIR)
$(CC1) $(CFLAGS) -o $@ $<
$(BUILD_DIR)/%.o: %.s $(BUILD_DIR)
$(AS) $(ASFLAGS) -o $@ $<
$(BUILD_DIR)/$(TARGET).elf: $(O_FILES) $(LD_SCRIPT)
$(LD) $(LDFLAGS) -o $@ $(O_FILES) $(LIBS)
$(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf
$(OBJCOPY) $< $@ -O binary
# final z64 updates checksum
$(BUILD_DIR)/$(TARGET).z64: $(BUILD_DIR)/$(TARGET).bin
$(N64CKSUM) $< $@
$(BUILD_DIR)/$(TARGET).hex: $(TARGET).z64
xxd $< > $@
$(BUILD_DIR)/$(TARGET).objdump: $(BUILD_DIR)/$(TARGET).elf
$(OBJDUMP) -D $< > $@
test: $(TARGET).z64
$(EMULATOR) $(EMU_FLAGS) $<
load: $(TARGET).z64
$(LOADER) $(LOADER_FLAGS) $<
.PHONY: all clean default diff test load