-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (62 loc) · 2.86 KB
/
Makefile
File metadata and controls
74 lines (62 loc) · 2.86 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
PRINT := printf '
ENDCOLOR := \033[0m
WHITE := \033[0m
ENDWHITE := $(ENDCOLOR)
GREEN := \033[0;32m
ENDGREEN := $(ENDCOLOR)
BLUE := \033[0;34m
ENDBLUE := $(ENDCOLOR)
YELLOW := \033[0;33m
ENDYELLOW := $(ENDCOLOR)
PURPLE := \033[0;35m
ENDPURPLE := $(ENDCOLOR)
ENDLINE := \n'
# List of source files
SOURCES = $(wildcard src/*.c)
SOURCES_ASM = $(wildcard asm/*.asm)
SOURCES_ASM_BEFORE_HEADERSIZE = $(wildcard asm/!image_bin.s) $(filter-out asm/!image_bin.s,$(wildcard asm/*.s))
# List of object files, generated from the source files
OBJECTS = $(SOURCES:src/%.c=obj/%.o)
OUTPUT_FILE = main.asm
CC := mips64-elf-gcc
STANDARDFLAGS := -O2 -Wall -mtune=vr4300 -march=vr4300 -mabi=32 -fomit-frame-pointer -mno-abicalls -fno-pic -G0
SPEEDFLAGS := -Os -Wall -mtune=vr4300 -march=vr4300 -mabi=32 -fomit-frame-pointer -mno-abicalls -fno-pic -G0
# Default target
all: verify_data $(OBJECTS) genMain assemble
# Rule for building object files from source files
obj/%.o: src/%.c | obj
@$(PRINT)$(GREEN)Compiling C file: $(ENDGREEN)$(BLUE)$<$(ENDBLUE)$(ENDCOLOR)$(ENDLINE)
@$(CC) $(STANDARDFLAGS) -c $< -o $@
assemble: $(OBJECTS)
@$(PRINT)$(GREEN)Assembling with armips: $(ENDGREEN)$(BLUE)main.asm$(ENDBLUE)$(ENDCOLOR)$(ENDLINE)
@armips main.asm
@$(PRINT)$(GREEN)n64crc $(ENDGREEN)$(BLUE)"rom/Quest64.mod.z64"$(ENDBLUE)$(ENDCOLOR)$(ENDLINE)
@./n64crc.exe "rom/Quest64.mod.z64"
#max size of asm files total is 0x80400000 - 0x80500000 (1MB)
#max size of C files total is 0x80500000 - 0x80800000 (3MB)
genMain:
@$(PRINT)$(GREEN)Generating: $(ENDGREEN)$(BLUE)main.asm$(ENDBLUE)$(ENDCOLOR)$(ENDLINE)
$(file > $(OUTPUT_FILE),//Automatically generated by makefile, do not edit)
$(file >> $(OUTPUT_FILE),.n64 // Let armips know we're coding for the N64 architecture)
$(file >> $(OUTPUT_FILE),.open "rom/Quest64.z64", "rom/Quest64.mod.z64", 0 // Open the ROM file)
$(file >> $(OUTPUT_FILE),.org 0xD305E0)
$(file >> $(OUTPUT_FILE),.fill 0xB860 //zero out old text)
$(foreach obj_file,$(SOURCES_ASM_BEFORE_HEADERSIZE),$(file >> $(OUTPUT_FILE),.include "$(obj_file)"))
$(file >> $(OUTPUT_FILE),.headersize 0x7F400000)
$(file >> $(OUTPUT_FILE),.org 0x80400000)
$(file >> $(OUTPUT_FILE),PAYLOAD_START_RAM:)
$(file >> $(OUTPUT_FILE),.incbin "bin/QuestNewText.bin")
$(foreach obj_file,$(SOURCES_ASM),$(file >> $(OUTPUT_FILE),.include "$(obj_file)"))
$(foreach obj_file,$(OBJECTS),$(file >> $(OUTPUT_FILE),.importobj "$(obj_file)"))
$(file >> $(OUTPUT_FILE),PAYLOAD_END_RAM:)
$(file >> $(OUTPUT_FILE),.close //close file)
# Rule for creating the obj folder
obj:
@mkdir -p obj
# Rule for cleaning up the project
clean:
@rm -f $(OBJECTS)
# Rule to verify data before generating main.asm
verify_data:
@$(PRINT)$(GREEN)Verifying data before generating main.asm...$(ENDCOLOR)$(ENDLINE)
@python3 tools/import_text_changes_from_quest_edit.py