-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
149 lines (119 loc) · 5.54 KB
/
Makefile
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
.PHONY: all compare_alpha compare_beta clean alpha beta
.SUFFIXES:
.SUFFIXES: .asm .o .gbc .png .wav .wikitext
.SECONDEXPANSION:
BASE_DIR := baseroms
BUILD_DIR := build
ROMS_ALPHA := ${BUILD_DIR}/bugsite_alpha.gbc
BASEROM_ALPHA := ${BASE_DIR}/baserom_alpha.gbc
ROMS_BETA := ${BUILD_DIR}/bugsite_beta.gbc
BASEROM_BETA := ${BASE_DIR}/baserom_beta.gbc
OBJS := component/bugvm/decode.o component/bugvm/optable.o component/bugvm/vm_state.o \
component/bugvm/datastack.o component/bugvm/predicate.o \
component/windowmanager/contents_config.o component/windowmanager/drawframe.o \
component/windowmanager/menu_config.o component/windowmanager/print_tools.o \
component/windowmanager/cursor.o component/windowmanager/winclr.o \
component/windowmanager/choices.o \
component/mainscript/window.o component/mainscript/scene.o \
component/lcdc/poke.o component/lcdc/vmemcopy.o \
component/system/banking.o component/system/version.o \
component/bugfs/indexlinkage.o \
component/mainscript/player_name.o \
component/nameinput/string_temporary.o component/nameinput/nickname_datablock.o \
component/mobilemenu/vars.o
OBJS_ALPHA :=
OBJS_BETA :=
OBJS_ALL := ${OBJS} ${OBJS_ALPHA} ${OBJS_BETA}
#Directory objects have to be treated separately since this makefile would
#otherwise attempt to run it through rgbasm and wonder why there's no .asm file
OBJS_DIR_ALPHA := versions/alpha/component/bugfs/directory.bugfs.o
OBJS_DIR_BETA := versions/beta/component/bugfs/directory.bugfs.o
OBJS_DIR_ALL := ${OBJS_DIR_ALPHA} ${OBJS_DIR_BETA}
OBJS_EXTRA := versions/alpha/script/encounters.atbl.o versions/beta/script/encounters.atbl.o \
versions/alpha/script/monsters.atbl.o versions/beta/script/monsters.atbl.o \
script/chips.atbl.o script/keyitems.atbl.o script/moves.atbl.o
#Only Python 3 is supported this time.
PYTHON := utilities/find_python.sh
PRET := pokemon-reverse-engineering-tools/pokemontools
$(foreach obj, $(OBJS), \
$(eval $(obj:.o=)_dep := $(addprefix ${BUILD_DIR}/,$(shell $(PYTHON) utilities/scan_includes.py $(obj:.o=.asm)))) \
)
$(foreach obj, $(OBJS_ALPHA), \
$(eval $(obj:.o=)_dep := $(addprefix ${BUILD_DIR}/,$(shell $(PYTHON) utilities/scan_includes.py $(obj:.o=.asm)))) \
)
$(foreach obj, $(OBJS_BETA), \
$(eval $(obj:.o=)_dep := $(addprefix ${BUILD_DIR}/,$(shell $(PYTHON) utilities/scan_includes.py $(obj:.o=.asm)))) \
)
$(foreach obj, $(OBJS_DIR_ALL), \
$(eval $(obj:.bugfs.o=)_dep := $(shell $(PYTHON) utilities/bfsdeps.py $(obj:.bugfs.o=.bfs) --basedir=$(BUILD_DIR) --basedir=.)) \
)
# Link objects together to build a rom.
all: alpha beta
alpha: $(ROMS_ALPHA) compare_alpha
beta: $(ROMS_BETA) compare_beta
# Assemble source files into objects.
# Use rgbasm -h to use halts without nops.
$(OBJS_ALL:%.o=${BUILD_DIR}/%.o): $(BUILD_DIR)/%.o : %.asm $$($$*_dep)
@echo "Assembling" $<
@mkdir -p $(dir $@)
@rgbasm -h -o $@ $<
# Assemble the BugFS directory...
$(OBJS_DIR_ALL:%.bugfs.o=${BUILD_DIR}/%.bugfs.o): $(BUILD_DIR)/%.bugfs.o : %.bfs $$($$*_dep)
@echo "Building BugFS filesystem" $<
@mkdir -p $(dir $@)
@$(PYTHON) utilities/bfsbuild.py $< $@ --basedir=$(BUILD_DIR) --basedir=.
$(ROMS_ALPHA): $(OBJS:%.o=${BUILD_DIR}/%.o) $(OBJS_DIR_ALPHA:%.o=${BUILD_DIR}/%.o) $(OBJS_ALPHA:%.o=${BUILD_DIR}/%.o) $(OBJS_EXTRA:%.o=${BUILD_DIR}/%.o)
rgblink -n $(ROMS_ALPHA:.gbc=.sym) -m $(ROMS_ALPHA:.gbc=.map) -O $(BASEROM_ALPHA) -o $@ $^
rgbfix -v -C -i BAUJ -k 2N -l 0x33 -m 0x1B -p 0 -r 3 -t "BUGSITE ALP" $@
$(ROMS_BETA): $(OBJS:%.o=${BUILD_DIR}/%.o) $(OBJS_DIR_BETA:%.o=${BUILD_DIR}/%.o) $(OBJS_BETA:%.o=${BUILD_DIR}/%.o) $(OBJS_EXTRA:%.o=${BUILD_DIR}/%.o)
rgblink -n $(ROMS_BETA:.gbc=.sym) -m $(ROMS_BETA:.gbc=.map) -O $(BASEROM_BETA) -o $@ $^
rgbfix -v -C -i BBUJ -k 2N -l 0x33 -m 0x1B -p 0 -r 3 -t "BUGSITE BET" $@
# The compare target is a shortcut to check that the build matches the original roms exactly.
# This is for contributors to make sure a change didn't affect the contents of the rom.
# More thorough comparison can be made by diffing the output of hexdump -C against both roms.
compare_alpha: $(ROMS_ALPHA) $(BASEROM_ALPHA)
cmp $^
compare_beta: $(ROMS_BETA) $(BASEROM_BETA)
cmp $^
# Remove files generated by the build process.
clean:
rm -r build
#This rule is needed if we want make to not die. It expects to see .inc files in
#the build directory now that we moved all resources there. We DO want to see
#.inc files as dependencies but I can't be arsed to fiddle with any more arcane
#makefile bullshit to get it to not prefix .inc files.
$(BUILD_DIR)/%.inc: %.inc
@mkdir -p $(dir $@)
@cp $< $@
$(BUILD_DIR)/%.2bpp: %.png
@echo "Building" $<
@mkdir -p $(dir $@)
@rgbgfx -d 2 -o $@ $<
$(BUILD_DIR)/%.1bpp: %.png
@echo "Building" $<
@mkdir -p $(dir $@)
@rgbgfx -d 1 -o $@ $<
$(BUILD_DIR)/%.bof: %.bvm
@echo "Assembling" $<
@mkdir -p $(dir $@)
@$(PYTHON) utilities/bvmasm.py $< --deffile script/bugvm_strings.csv --language Japanese script/charmap.txt $@
$(BUILD_DIR)/%.spranim.bof: %.banim
@echo "Assembling" $<
@mkdir -p $(dir $@)
@$(PYTHON) utilities/banimasm.py $< $@
$(BUILD_DIR)/%.tmap.bin: %.btmap.csv
@echo "Assembling" $<
@mkdir -p $(dir $@)
@$(PYTHON) utilities/btmapasm.py $< $@
$(BUILD_DIR)/%.metrics: %.bfont
@echo "Compiling font metrics from " $<
@mkdir -p $(dir $@)
@$(PYTHON) utilities/bfontmetrics.py $< script/charmap.txt $@
$(BUILD_DIR)/%.palette.bin: %.bpal
@echo "Assembling" $<
@mkdir -p $(dir $@)
@$(PYTHON) utilities/bpalasm.py $< $@
$(BUILD_DIR)/%.atbl.o: %.csv
@echo "Building" $<
@mkdir -p $(dir $@)
@$(PYTHON) utilities/montable_compile.py $< script/charmap.txt $@