-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
86 lines (69 loc) · 2.93 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
ROOTDIR = $(N64_INST)
GCCN64PREFIX = $(ROOTDIR)/bin/mips64-elf-
CHKSUM64PATH = $(ROOTDIR)/bin/chksum64
MKDFSPATH = $(ROOTDIR)/bin/mkdfs
MKSPRITE = $(ROOTDIR)/bin/mksprite
N64TOOL = $(ROOTDIR)/bin/n64tool
LINK_FLAGS = -L$(ROOTDIR)/lib -L$(ROOTDIR)/mips64-elf/lib -ldragon -lmikmod -lc -lm -ldragonsys -Tn64.ld
PROG_NAME = Flood-64
CFLAGS = -std=gnu99 -march=vr4300 -mtune=vr4300 -O2 -Wall -Werror -I$(ROOTDIR)/mips64-elf/include -Iinclude -I/usr/local/include/
ASFLAGS = -mtune=vr4300 -march=vr4300
CC = $(GCCN64PREFIX)gcc
AS = $(GCCN64PREFIX)as
LD = $(GCCN64PREFIX)ld
OBJCOPY = $(GCCN64PREFIX)objcopy
all: build
build: ## Create rom.
@docker --version &> /dev/null
@if [ $$? -ne 0 ]; then echo "Building rom..." && make $(PROG_NAME).z64; fi
@if [ $$? -eq 0 ]; then echo "Building rom inside docker environment..." && make docker; fi
docker: setup
@docker run --user $(shell id -u):$(shell id -g) -v ${CURDIR}:/game build make $(PROG_NAME).z64
rebuild: clean build ## Erase temp files and create the rom.
# gfx #
PNGS := $(wildcard resources/gfx/*/*.png) $(wildcard resources/gfx/*/*/*.png)
SPRITES := $(subst .png,.sprite,$(subst resources/,filesystem/,$(PNGS)))
filesystem/gfx/sprites/%.sprite: resources/gfx/sprites/%.png
@mkdir -p `echo $@ | xargs dirname`
$(MKSPRITE) 16 1 1 $< $@
filesystem/gfx/maps/%.sprite: resources/gfx/maps/%.png
@mkdir -p `echo $@ | xargs dirname`
$(MKSPRITE) 16 1 1 $< $@
# sfx #
MODS := $(wildcard resources/sfx/bgms/*.mod)
BGMS := $(subst resources/,filesystem/,$(MODS))
filesystem/sfx/bgms/%.mod: resources/sfx/bgms/%.mod
@mkdir -p `echo $@ | xargs dirname`
cp $< $@
# code #
SRCS := $(wildcard src/*.c)
OBJS := $(SRCS:.c=.o)
$(PROG_NAME).elf : $(OBJS)
$(LD) -o $@ $^ $(LINK_FLAGS)
$(PROG_NAME).bin : $(PROG_NAME).elf
$(OBJCOPY) -O binary $< $@
# dfs #
$(PROG_NAME).dfs: $(SPRITES) $(BGMS)
@mkdir -p ./filesystem/
@echo `git rev-parse HEAD` > ./filesystem/hash
$(MKDFSPATH) $@ ./filesystem/
# rom
$(PROG_NAME).z64: $(PROG_NAME).bin $(PROG_NAME).dfs
@rm -f $@
$(N64TOOL) -l 8M -t "$(PROG_NAME)" -h $(ROOTDIR)/mips64-elf/lib/header -o $(PROG_NAME).z64 $(PROG_NAME).bin -s 1M $(PROG_NAME).dfs
$(CHKSUM64PATH) $@
setup: ## Create dev environment (docker image).
@docker build -q -t build - < Dockerfile > /dev/null
resetup: ## Force recreate the dev environment (docker image).
@echo "Rebuilding dev environment in docker..."
@docker build -q -t build --no-cache - < Dockerfile > /dev/null
cen64: ## Start rom in CEN64 emulator.
@echo "Starting cen64..."
$(CEN64_DIR)/cen64 -multithread -controller num=1,pak=rumble $(CEN64_DIR)/pifdata.bin $(PROG_NAME).z64
flashair: ## Flash rom to EverDrive using a flashair SD card.
curl -X POST -F 'file=@$(PROG_NAME).z64' http://flashair/upload.cgi
clean: ## Cleanup temp files.
@echo "Cleaning up temp files..."
rm -rf *.z64 *.elf src/*.o *.bin *.dfs filesystem/
help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/:.*##/:/'