-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
539 lines (413 loc) · 18.5 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
# Makefile to build DKR
############################ Shell ###########################
SHELL := /bin/bash
################## Preprocessor definitions ##################
# Currently, only US 1.0 is supported.
VERSION := us_1.0
NON_MATCHING ?= 1
$(eval $(call validate-option,NON_MATCHING,0 1))
ifeq ($(VERSION),us_1.0)
DEFINES += VERSION_US_1_0=1
endif
ifeq ($(NON_MATCHING),1)
DEFINES += NON_MATCHING=1
endif
# Whether to hide commands or not
VERBOSE ?= 0
ifeq ($(VERBOSE),0)
V := @
endif
# Whether to colorize build messages
COLOR ?= 1
############################ Setup ###########################
# Don't do setup checks if cleaning.
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),clean_lib)
ifneq ($(MAKECMDGOALS),clean_src)
ifneq ($(MAKECMDGOALS),reset)
################ Check if a baserom exists ################
numberOfFilesInBaseromsDirectory := $(words $(wildcard baseroms/*))
ifeq ($(shell test $(numberOfFilesInBaseromsDirectory) -lt 1; echo $$?),0)
$(error Make sure you have a DKR rom in the /baseroms/ directory)
endif
########## Make tools ##########
DUMMY != make -s -C tools >&2 || echo FAIL
ifeq ($(DUMMY),FAIL)
$(error Failed to build tools)
endif
PRINT = printf
ifeq ($(COLOR),1)
NO_COL := \033[0m
RED := \033[0;31m
GREEN := \033[0;32m
BLUE := \033[0;34m
YELLOW := \033[0;33m
BLINK := \033[33;5m
endif
# Common build print status function
define print
@$(PRINT) "$(GREEN)$(1) $(YELLOW)$(2)$(GREEN) -> $(BLUE)$(3)$(NO_COL)\n"
endef
########## Recomp ##########
RECOMP_PROJECT := ./tools/ido-static-recomp/
DUMMY != ls $(RECOMP_PROJECT)ido >/dev/null || echo FAIL
ifeq ($(DUMMY),FAIL)
$(error Missing submodule ido-static-recomp. Please run 'git submodule update --init')
endif
# List of IDO tools required for the repo.
# NOTE: If you are adding a tool here, make sure to update the Makefile in `/tools/ido-static-recomp/`!
RECOMP_TOOLS := cc cfe uopt ugen as1 ujoin uld usplit umerge
RECOMP_DIR := $(RECOMP_PROJECT)build5.3/out/
RECOMP_TOOLS_PATHS = $(addprefix $(RECOMP_DIR),$(RECOMP_TOOLS))
# Checks if all the recomp tools exist.
$(foreach p,$(RECOMP_TOOLS_PATHS),$(if $(wildcard $(p)),,$(info $(p) does not exist!) $(eval runRecomp:=yes)))
# If any of the tools do not exist, then recomp needs to run to build them.
ifeq ($(runRecomp),yes)
DUMMY != cd $(RECOMP_PROJECT) && python3 build.py ido/5.3 -O2 && cd ../../ >&2 || echo FAIL
endif
######## Extract Assets & Microcode ########
DUMMY != python3 ./tools/python/check_if_need_to_extract.py $(VERSION) >&2 || echo FAIL
##### Generate linker file #####
DUMMY != ./generate_ld.sh $(VERSION) >&2 || echo FAIL
ifeq ($(DUMMY),FAIL)
$(error Failed to generate the linker file)
endif
################################
endif
endif
endif
endif
################ Target Executable and Sources ###############
# BUILD_DIR is location where all build artifacts are placed
# TODO: Support other versions of DKR
BUILD_DIR = build/$(VERSION)
##################### Compiler Options #######################
# Check if a binutils package is installed on the system.
ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
CROSS := mips-linux-gnu-
else ifeq ($(shell type mips64-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
CROSS := mips64-linux-gnu-
else ifeq ($(shell type mips64-elf-ld >/dev/null 2>/dev/null; echo $$?), 0)
CROSS := mips64-elf-
else
# No binutil packages were found, so we have to download the source & build it.
ifeq ($(wildcard ./tools/binutils/.*),)
DUMMY != ./tools/get-binutils.sh >&2 || echo FAIL
endif
CROSS := ./tools/binutils/mips64-elf-
endif
AS = $(CROSS)as
CC := $(RECOMP_DIR)cc
CPP := cpp -P -Wno-trigraphs
LD = $(CROSS)ld
OBJDUMP = $(CROSS)objdump
# Pad to 12MB if matching, otherwise build to a necessary minimum of 1.04KB
ifeq ($(NON_MATCHING),0)
OBJCOPY = $(CROSS)objcopy --pad-to=0xC00000 --gap-fill=0xFF
else
OBJCOPY = $(CROSS)objcopy --pad-to=0x101000 --gap-fill=0xFF
endif
MIPSISET := -mips1
OPT_FLAGS := -O2
INCLUDE_DIRS := include $(BUILD_DIR) $(BUILD_DIR)/include src include/libc .
C_DEFINES := $(foreach d,$(DEFINES),-D$(d))
DEF_INC_CFLAGS := $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(C_DEFINES)
ASFLAGS = -mtune=vr4300 -march=vr4300 -mabi=32 $(foreach d,$(DEFINES),--defsym $(d))
INCLUDE_CFLAGS := -I include -I $(BUILD_DIR) -I src -I . -I include/libc
CFLAGS = -c -Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -Xfullwarn -signed $(OPT_FLAGS) $(MIPSISET) $(INCLUDE_CFLAGS) $(DEF_INC_CFLAGS)
LDFLAGS = undefined_syms.txt -T $(LD_SCRIPT) -Map $(BUILD_DIR)/dkr.map
####################### Other Tools #########################
# N64 tools
TOOLS_DIR = ./tools
EMULATOR = mupen64plus
EMU_FLAGS = --noosd
LOADER = loader64
LOADER_FLAGS = -vwf
FixPath = $(subst /,,$1)
N64CRC = $(TOOLS_DIR)/n64crc
FIXCHECKSUMS = python3 $(TOOLS_DIR)/python/calc_func_checksums.py $(VERSION)
TEXBUILDER = $(TOOLS_DIR)/dkr_texbuilder
COMPRESS = $(TOOLS_DIR)/dkr_decompressor -c
LIB_DIRS := lib/
ASM_DIRS := asm/ asm/boot/ asm/assets/ lib/asm/ lib/asm/non_decompilable
SRC_DIRS := $(sort $(dir $(wildcard src/* src/**/*))) $(sort $(dir $(wildcard lib/src/* lib/src/**/* lib/src/**/**/*)))
GLOBAL_ASM_C_FILES != grep -rl 'GLOBAL_ASM(' $(SRC_DIRS)
GLOBAL_ASM_O_FILES = $(foreach file,$(GLOBAL_ASM_C_FILES),$(BUILD_DIR)/$(file:.c=.o))
S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)*.s))
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)*.c))
# Object files
O_FILES := $(foreach file,$(S_FILES),$(BUILD_DIR)/$(file:.s=.o)) \
$(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o))
# Automatic dependency files
DEP_FILES := $(O_FILES:.o=.d) $(BUILD_DIR)/$(LD_SCRIPT).d
# Check code syntax with host compiler
CC_CHECK := gcc
ifeq ($(shell getconf LONG_BIT), 64)
# Ensure that gcc treats the code as 32-bit
CC_CHECK_CFLAGS += -m32
endif
CC_CHECK_CFLAGS := -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) $(DEF_INC_CFLAGS) -std=gnu90 -Wall -Wextra -Wno-format-security -Wno-main -DNON_MATCHING -DAVOID_UB -D_LANGUAGE_C
####################### ASSETS #########################
# TODO: Clean this up if possible
# All the asset subfolders to create in the build folder.
ASSETS_DIRS := audio bin fonts ids levels levels/headers levels/models levels/names levels/objectMaps misc objects objects/animations objects/headers objects/models particles particles/behaviors particles/particles sprites text text/game text/menu textures textures/2d textures/3d tt_ghosts unknown_0 ucode
ASSETS_DIR = assets/$(VERSION)
UCODE_DIR = ucode/$(VERSION)
ASSETS_COPY = cp
AUDIO_IN_DIR = $(ASSETS_DIR)/audio
AUDIO_OUT_DIR = $(BUILD_DIR)/audio
ALL_ASSETS_BUILT += $(patsubst $(AUDIO_IN_DIR)/%.bin,$(AUDIO_OUT_DIR)/%.bin,$(wildcard $(AUDIO_IN_DIR)/*.bin))
BIN_IN_DIR = $(ASSETS_DIR)/bin
BIN_OUT_DIR = $(BUILD_DIR)/bin
ALL_ASSETS_BUILT += $(patsubst $(BIN_IN_DIR)/%.bin,$(BIN_OUT_DIR)/%.bin,$(wildcard $(BIN_IN_DIR)/*.bin))
FONTS_IN_DIR = $(ASSETS_DIR)/fonts
FONTS_OUT_DIR = $(BUILD_DIR)/fonts
ALL_ASSETS_BUILT += $(patsubst $(FONTS_IN_DIR)/%.bin,$(FONTS_OUT_DIR)/%.bin,$(wildcard $(FONTS_IN_DIR)/*.bin))
IDS_IN_DIR = $(ASSETS_DIR)/ids
IDS_OUT_DIR = $(BUILD_DIR)/ids
ALL_ASSETS_BUILT += $(patsubst $(IDS_IN_DIR)/%.bin,$(IDS_OUT_DIR)/%.bin,$(wildcard $(IDS_IN_DIR)/*.bin))
LEVELS_IN_DIR = $(ASSETS_DIR)/levels
LEVELS_OUT_DIR = $(BUILD_DIR)/levels
LEVEL_HEADERS_IN_DIR = $(LEVELS_IN_DIR)/headers
LEVEL_HEADERS_OUT_DIR = $(LEVELS_OUT_DIR)/headers
LEVEL_MODELS_IN_DIR = $(LEVELS_IN_DIR)/models
LEVEL_MODELS_OUT_DIR = $(LEVELS_OUT_DIR)/models
LEVEL_NAMES_IN_DIR = $(LEVELS_IN_DIR)/names
LEVEL_NAMES_OUT_DIR = $(LEVELS_OUT_DIR)/names
LEVEL_OBJMAPS_IN_DIR = $(LEVELS_IN_DIR)/objectMaps
LEVEL_OBJMAPS_OUT_DIR = $(LEVELS_OUT_DIR)/objectMaps
ALL_ASSETS_BUILT += $(patsubst $(LEVEL_HEADERS_IN_DIR)/%.bin,$(LEVEL_HEADERS_OUT_DIR)/%.bin,$(wildcard $(LEVEL_HEADERS_IN_DIR)/*.bin))
ALL_ASSETS_BUILT += $(patsubst $(LEVEL_MODELS_IN_DIR)/%.cbin,$(LEVEL_MODELS_OUT_DIR)/%.bin,$(wildcard $(LEVEL_MODELS_IN_DIR)/*.cbin))
ALL_ASSETS_BUILT += $(patsubst $(LEVEL_NAMES_IN_DIR)/%.bin,$(LEVEL_NAMES_OUT_DIR)/%.bin,$(wildcard $(LEVEL_NAMES_IN_DIR)/*.bin))
ALL_ASSETS_BUILT += $(patsubst $(LEVEL_OBJMAPS_IN_DIR)/%.cbin,$(LEVEL_OBJMAPS_OUT_DIR)/%.bin,$(wildcard $(LEVEL_OBJMAPS_IN_DIR)/*.cbin))
MISC_IN_DIR = $(ASSETS_DIR)/misc
MISC_OUT_DIR = $(BUILD_DIR)/misc
ALL_ASSETS_BUILT += $(patsubst $(MISC_IN_DIR)/%.bin,$(MISC_OUT_DIR)/%.bin,$(wildcard $(MISC_IN_DIR)/*.bin))
OBJECTS_IN_DIR = $(ASSETS_DIR)/objects
OBJECTS_OUT_DIR = $(BUILD_DIR)/objects
OBJECT_ANIMS_IN_DIR = $(OBJECTS_IN_DIR)/animations
OBJECT_ANIMS_OUT_DIR = $(OBJECTS_OUT_DIR)/animations
OBJECT_HEADERS_IN_DIR = $(OBJECTS_IN_DIR)/headers
OBJECT_HEADERS_OUT_DIR = $(OBJECTS_OUT_DIR)/headers
OBJECT_MODELS_IN_DIR = $(OBJECTS_IN_DIR)/models
OBJECT_MODELS_OUT_DIR = $(OBJECTS_OUT_DIR)/models
ALL_ASSETS_BUILT += $(patsubst $(OBJECTS_IN_DIR)/%.bin,$(OBJECTS_OUT_DIR)/%.bin,$(wildcard $(OBJECTS_IN_DIR)/*.bin))
ALL_ASSETS_BUILT += $(patsubst $(OBJECT_ANIMS_IN_DIR)/%.cbin,$(OBJECT_ANIMS_OUT_DIR)/%.bin,$(wildcard $(OBJECT_ANIMS_IN_DIR)/*.cbin))
ALL_ASSETS_BUILT += $(patsubst $(OBJECT_HEADERS_IN_DIR)/%.bin,$(OBJECT_HEADERS_OUT_DIR)/%.bin,$(wildcard $(OBJECT_HEADERS_IN_DIR)/*.bin))
ALL_ASSETS_BUILT += $(patsubst $(OBJECT_MODELS_IN_DIR)/%.cbin,$(OBJECT_MODELS_OUT_DIR)/%.bin,$(wildcard $(OBJECT_MODELS_IN_DIR)/*.cbin))
PARTICLES_IN_DIR = $(ASSETS_DIR)/particles
PARTICLES_OUT_DIR = $(BUILD_DIR)/particles
PART_BEHAVIORS_IN_DIR = $(PARTICLES_IN_DIR)/behaviors
PART_BEHAVIORS_OUT_DIR = $(PARTICLES_OUT_DIR)/behaviors
PART_PARTICLES_IN_DIR = $(PARTICLES_IN_DIR)/particles
PART_PARTICLES_OUT_DIR = $(PARTICLES_OUT_DIR)/particles
ALL_ASSETS_BUILT += $(patsubst $(PART_BEHAVIORS_IN_DIR)/%.bin,$(PART_BEHAVIORS_OUT_DIR)/%.bin,$(wildcard $(PART_BEHAVIORS_IN_DIR)/*.bin))
ALL_ASSETS_BUILT += $(patsubst $(PART_PARTICLES_IN_DIR)/%.bin,$(PART_PARTICLES_OUT_DIR)/%.bin,$(wildcard $(PART_PARTICLES_IN_DIR)/*.bin))
SPRITES_IN_DIR = $(ASSETS_DIR)/sprites
SPRITES_OUT_DIR = $(BUILD_DIR)/sprites
ALL_ASSETS_BUILT += $(patsubst $(SPRITES_IN_DIR)/%.bin,$(SPRITES_OUT_DIR)/%.bin,$(wildcard $(SPRITES_IN_DIR)/*.bin))
TEXT_IN_DIR = $(ASSETS_DIR)/text
TEXT_OUT_DIR = $(BUILD_DIR)/text
TEXT_GAME_IN_DIR = $(TEXT_IN_DIR)/game
TEXT_GAME_OUT_DIR = $(TEXT_OUT_DIR)/game
TEXT_MENU_IN_DIR = $(TEXT_IN_DIR)/menu
TEXT_MENU_OUT_DIR = $(TEXT_OUT_DIR)/menu
ALL_ASSETS_BUILT += $(patsubst $(TEXT_GAME_IN_DIR)/%.bin,$(TEXT_GAME_OUT_DIR)/%.bin,$(wildcard $(TEXT_GAME_IN_DIR)/*.bin))
ALL_ASSETS_BUILT += $(patsubst $(TEXT_MENU_IN_DIR)/%.bin,$(TEXT_MENU_OUT_DIR)/%.bin,$(wildcard $(TEXT_MENU_IN_DIR)/*.bin))
TEXTURES_IN_DIR = $(ASSETS_DIR)/textures
TEXTURES_OUT_DIR = $(BUILD_DIR)/textures
TEXTURES_2D_IN_DIR = $(TEXTURES_IN_DIR)/2d
TEXTURES_2D_OUT_DIR = $(TEXTURES_OUT_DIR)/2d
TEXTURES_3D_IN_DIR = $(TEXTURES_IN_DIR)/3d
TEXTURES_3D_OUT_DIR = $(TEXTURES_OUT_DIR)/3d
ALL_ASSETS_BUILT += $(patsubst $(TEXTURES_2D_IN_DIR)/%.png,$(TEXTURES_2D_OUT_DIR)/%.bin,$(wildcard $(TEXTURES_2D_IN_DIR)/*.png))
ALL_ASSETS_BUILT += $(patsubst $(TEXTURES_3D_IN_DIR)/%.png,$(TEXTURES_3D_OUT_DIR)/%.bin,$(wildcard $(TEXTURES_3D_IN_DIR)/*.png))
TT_GHOSTS_IN_DIR = $(ASSETS_DIR)/tt_ghosts
TT_GHOSTS_OUT_DIR = $(BUILD_DIR)/tt_ghosts
ALL_ASSETS_BUILT += $(patsubst $(TT_GHOSTS_IN_DIR)/%.bin,$(TT_GHOSTS_OUT_DIR)/%.bin,$(wildcard $(TT_GHOSTS_IN_DIR)/*.bin))
UNKNOWN_0_IN_DIR = $(ASSETS_DIR)/unknown_0
UNKNOWN_0_OUT_DIR = $(BUILD_DIR)/unknown_0
ALL_ASSETS_BUILT += $(patsubst $(UNKNOWN_0_IN_DIR)/%.bin,$(UNKNOWN_0_OUT_DIR)/%.bin,$(wildcard $(UNKNOWN_0_IN_DIR)/*.bin))
UCODE_IN_DIR = $(UCODE_DIR)
UCODE_OUT_DIR = $(BUILD_DIR)/ucode
UCODE = $(wildcard $(UCODE_IN_DIR)/*.bin)
ALL_ASSETS_BUILT += $(patsubst $(UCODE_IN_DIR)/%.bin,$(UCODE_OUT_DIR)/%.bin,$(UCODE))
#ALL_ASSETS_BUILT := $(ANIMATIONS_BUILT) $(AUDIO_BUILT) $(BILLBOARDS_BUILT) $(BINS_BUILT) $(CHEATS_BUILT) $(FONTS_BUILT) $(LEVELS_BUILT) $(OBJECTS_BUILT) $(TEXTURES_BUILT) $(PARTICLES_BUILT) $(TEXT_BUILT) $(TT_GHOSTS_BUILT) $(UCODE_BUILT) $(LUT_BUILT)
####################### LIBULTRA #########################
$(BUILD_DIR)/lib/%.o: OPT_FLAGS := -O2
$(BUILD_DIR)/lib/src/al/%.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/os/%.o: OPT_FLAGS := -O1
$(BUILD_DIR)/lib/src/os/osViMgr.o: OPT_FLAGS := -O2
$(BUILD_DIR)/lib/src/os/osCreatePiManager.o: OPT_FLAGS := -O2
$(BUILD_DIR)/lib/src/os/osMotor.o: OPT_FLAGS := -O2
$(BUILD_DIR)/lib/src/libc/xprintf.o : OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/al/unknown_0C9C90.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0
#$(BUILD_DIR)/lib/src/libc/llcvt.o: OPT_FLAGS :=
#$(BUILD_DIR)/lib/src/libc/llcvt.o: MIPSISET := -mips3 32
$(BUILD_DIR)/lib/%.o: MIPSISET := -mips2
$(BUILD_DIR)/lib/src/mips1/%.o: MIPSISET := -mips1
$(BUILD_DIR)/lib/src/os/osMotor.o: MIPSISET := -mips1
# asm-processor currently does not support -O3, so this is my workaround.
$(BUILD_DIR)/lib/src/al/global_asm/%.o: OPT_FLAGS := -O2
######################## Targets #############################
default: all
TARGET = dkr
LD_SCRIPT = $(TARGET).ld
all: $(BUILD_DIR)/$(TARGET).z64
reset:
ifneq ($(wildcard ./build/.*),)
rm -r build
endif
ifneq ($(wildcard ./assets/.*),)
rm -r assets
endif
ifneq ($(wildcard ./ucode/.*),)
rm -r ucode
endif
@echo "Done."
clean:
ifneq ($(wildcard ./build/.*),)
rm -r build
else
@echo "/build/ directory has already been deleted."
endif
clean_lib:
ifneq ($(wildcard $(BUILD_DIR)/lib/.*),)
rm -r $(BUILD_DIR)/lib/src/*/*.o
else
@echo "build lib directory has already been deleted."
endif
clean_src: clean_lib
ifneq ($(wildcard $(BUILD_DIR)/src/.*),)
rm -r $(BUILD_DIR)/src/*.o
else
@echo "/build/lib directory has already been deleted."
endif
$(BUILD_DIR):
@$(PRINT) "$(GREEN)Making Build Directory: $(BLUE)$@ $(NO_COL)\n"
$(V)mkdir -p $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(LIB_DIRS) $(ASM_DIRS) $(SRC_DIRS) $(ASSETS_DIRS))
# Helps fix an issue with parallel jobs.
$(ALL_ASSETS_BUILT): | $(BUILD_DIR)
# This is here to prevent make from deleting all the asset files after the build completes/fails.
dont_remove_asset_files: $(ALL_ASSETS_BUILT)
######## Asset Targets ########
# All assets should output a .bin file
$(AUDIO_OUT_DIR)/%.bin: $(AUDIO_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(BIN_OUT_DIR)/%.bin: $(BIN_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(FONTS_OUT_DIR)/%.bin: $(FONTS_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(IDS_OUT_DIR)/%.bin: $(IDS_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(LEVEL_HEADERS_OUT_DIR)/%.bin: $(LEVEL_HEADERS_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(LEVEL_MODELS_OUT_DIR)/%.bin: $(LEVEL_MODELS_IN_DIR)/%.cbin
$(call print,Compressing:,$<,$@)
$(V)$(COMPRESS) $^ $@
$(LEVEL_NAMES_OUT_DIR)/%.bin: $(LEVEL_NAMES_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(LEVEL_OBJMAPS_OUT_DIR)/%.bin: $(LEVEL_OBJMAPS_IN_DIR)/%.cbin
$(call print,Compressing:,$<,$@)
$(V)$(COMPRESS) $^ $@
$(MISC_OUT_DIR)/%.bin: $(MISC_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(OBJECTS_OUT_DIR)/%.bin: $(OBJECTS_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(OBJECT_ANIMS_OUT_DIR)/%.bin: $(OBJECT_ANIMS_IN_DIR)/%.cbin
$(call print,Compressing:,$<,$@)
$(V)$(COMPRESS) $^ $@
$(OBJECT_HEADERS_OUT_DIR)/%.bin: $(OBJECT_HEADERS_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(OBJECT_MODELS_OUT_DIR)/%.bin: $(OBJECT_MODELS_IN_DIR)/%.cbin
$(call print,Compressing:,$<,$@)
$(V)$(COMPRESS) $^ $@
$(PART_BEHAVIORS_OUT_DIR)/%.bin: $(PART_BEHAVIORS_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(PART_PARTICLES_OUT_DIR)/%.bin: $(PART_PARTICLES_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(SPRITES_OUT_DIR)/%.bin: $(SPRITES_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(TEXT_GAME_OUT_DIR)/%.bin: $(TEXT_GAME_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(TEXT_MENU_OUT_DIR)/%.bin: $(TEXT_MENU_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(TEXTURES_2D_OUT_DIR)/%.bin: $(TEXTURES_2D_IN_DIR)/%.png
$(call print,Building Texture:,$<,$@)
$(V)$(TEXBUILDER) $^ $@
$(TEXTURES_3D_OUT_DIR)/%.bin: $(TEXTURES_3D_IN_DIR)/%.png
$(call print,Building Texture:,$<,$@)
$(V)$(TEXBUILDER) $^ $@
$(TEXT_MENU_OUT_DIR)/%.bin: $(TEXT_MENU_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(TT_GHOSTS_OUT_DIR)/%.bin: $(TT_GHOSTS_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(UNKNOWN_0_OUT_DIR)/%.bin: $(UNKNOWN_0_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
$(UCODE_OUT_DIR)/%.bin: $(UCODE_IN_DIR)/%.bin
$(call print,Copying:,$<,$@)
$(V)$(ASSETS_COPY) $^ $@
###############################
$(BUILD_DIR)/%.o: %.s | $(ALL_ASSETS_BUILT)
$(call print,Assembling:,$<,$@)
$(V)$(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $<
$(BUILD_DIR)/%.o: %.c | $(ALL_ASSETS_BUILT)
$(call print,Compiling:,$<,$@)
@$(CC_CHECK) $(CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
$(V)$(CC) -c $(CFLAGS) -o $@ $<
$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c | $(ALL_ASSETS_BUILT)
$(call print,Compiling:,$<,$@)
@$(CC_CHECK) $(CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
$(V)$(CC) -c $(CFLAGS) -o $@ $<
$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) | $(ALL_ASSETS_BUILT)
$(call print,Preprocessing linker script:,$<,$@)
$(V)$(CPP) $(VERSION_CFLAGS) -DBUILD_DIR=$(BUILD_DIR) -MMD -MP -MT $@ -MF [email protected] -o $@ $<
$(BUILD_DIR)/$(TARGET).elf: $(O_FILES) $(BUILD_DIR)/$(LD_SCRIPT) | $(ALL_ASSETS_BUILT)
@$(PRINT) "$(GREEN)Linking ELF file: $(BLUE)$@ $(NO_COL)\n"
$(V)$(LD) $(LDFLAGS) -o $@ $(O_FILES) $(LIBS)
$(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf | $(ALL_ASSETS_BUILT)
$(call print,Making .bin:,$<,$@)
$(V)$(OBJCOPY) $< $@ -O binary
$(BUILD_DIR)/$(TARGET).z64: $(BUILD_DIR)/$(TARGET).bin | $(ALL_ASSETS_BUILT)
$(call print,Making final z64 ROM:,$<,$@)
$(V)cp $< $@
$(V)$(FIXCHECKSUMS)
$(V)$(N64CRC) $@
ifeq ($(NON_MATCHING),0)
@(sha1sum -c --quiet sha1/dkr.$(VERSION).sha1 \
&& $(PRINT) "$(BLUE)$@$(NO_COL)\
: $(GREEN)OK$(NO_COL)\n")
@$(PRINT) "$(YELLOW) __\n .\`_ _\`.\n| | \`| | |\n| |_|._| |\n \`. __ .\'$(NO_COL)\n\n"
else
@$(PRINT) "$(GREEN)Build Complete!$(NO_COL)\n"
endif
$(BUILD_DIR)/$(TARGET).hex: $(BUILD_DIR)/$(TARGET).z64
xxd $< > $@
$(BUILD_DIR)/$(TARGET).objdump: $(BUILD_DIR)/$(TARGET).elf
$(OBJDUMP) -D $< > $@
$(GLOBAL_ASM_O_FILES): CC := $(PYTHON) tools/asm_processor/build.py $(CC) -- $(AS) $(ASFLAGS) --
test: $(BUILD_DIR)/$(TARGET).z64
$(EMULATOR) $(EMU_FLAGS) $<
load: $(BUILD_DIR)/$(TARGET).z64
$(LOADER) $(LOADER_FLAGS) $<
.PHONY: all clean default diff test
# Remove built-in rules, to improve performance
MAKEFLAGS += --no-builtin-rules
-include $(DEP_FILES)