-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
115 lines (87 loc) · 3.09 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
# +---------+
# | Defines |
# *---------+
PROJECT = clockwork_creature
SRCDIR = src
BUILDIR = build
TOOLDIR = tools
TEXBUILDDIR = $(BUILDIR)/textures
TOOLBUILD = $(BUILDIR)/tools
ULTRAINCDIR = /usr/include/n64
NUSTDINCDIR = $(ULTRAINCDIR)/nustd
NUSYSINCDIR = $(ULTRAINCDIR)/nusys
ULTRALIBDIR = /usr/lib/n64
PRLIBDIR = $(ULTRALIBDIR)/PR
NUSYSLIBDIR = $(ULTRALIBDIR)/nusys
ULTRAGCCDIR = /usr/local/lib/gcc/mips64-elf/10.2.0
GCCINCDIR = $(ULTRAGCCDIR)/include
TEXDIR = $(SRCDIR)/assets/textures
# +-------------+
# | Executables |
# *-------------+
CC = mips-n64-gcc
LD = mips-n64-ld
MAKEROM = mild
MAKEMASK = makemask
N64GRAPHICS = $(TOOLDIR)/n64graphics_wrap.sh
BLOBINATOR = $(TOOLBUILD)/blobinator.tool
# +----------+
# | Binaries |
# *----------+
ROM = $(BUILDIR)/$(PROJECT).n64
BINARY = $(BUILDIR)/$(PROJECT).out
CODE = $(BUILDIR)/$(PROJECT).code.o
TEXTURES = $(BUILDIR)/$(PROJECT).textures.o
TEXTUREMAP = $(TEXBUILDDIR)/$(PROJECT).texmap
TEXTURELUT = $(TEXBUILDDIR)/texture_lut.c
# +-------------+
# | Directories |
# *-------------+
TEXDIRS = $(TEXDIR)/n64
INCDIRS = $(SRCDIR) $(SRCDIR)/core $(SRCDIR)/boos_bs $(SRCDIR)/assets/models $(NUSYSINCDIR) $(NUSTDINCDIR) $(ULTRAINCDIR) $(GCCINCDIR)
VPATH = $(SRCDIR) $(SRCDIR)/stages $(SRCDIR)/core $(SRCDIR)/boos_bs $(SRCDIR)/actors
# +--------------+
# | Source Files |
# *--------------+
CODEFILES = $(foreach dir,$(VPATH),$(wildcard $(dir)/*.c)) $(TEXTURELUT)
INCFILES = $(foreach dir,$(INCDIRS),$(wildcard $(dir)/*.h))
TEXFILES = $(foreach dir,$(TEXDIRS),$(wildcard $(dir)/*.png))
TOOLFILES = $(wildcard $(TOOLDIR)/*.cs)
# +---------------+
# | Final Objects |
# *---------------+
CODEOBJECTS = $(addprefix $(BUILDIR)/, $(CODEFILES:.c=.c.o)) $(NUSYSLIBDIR)/nusys.o
TEXOBJECTS = $(patsubst $(TEXDIR)/%.png, $(TEXBUILDDIR)/%.png.inc, $(TEXFILES))
TOOLOBJECTS = $(patsubst $(TOOLDIR)/%.cs, $(TOOLBUILD)/%.tool, $(TOOLFILES))
# +---------------+
# | CC & LD Flags |
# *---------------+
MCPU_FLAGS = -march=vr4300 -mtune=vr4300 -mfix4300 -mabi=32 -mno-abicalls
INC_FLAGS = $(foreach dir,$(INCDIRS),-I$(dir))
PLAT_FLAGS = -DNU_DEBUG -DNDEBUG -DF3DEX_GBI_2 -G 0
C_FLAGS = $(MCPU_FLAGS) $(INC_FLAGS) $(PLAT_FLAGS) -MD -mno-long-calls -Wall -Wno-unknown-pragmas -Wno-missing-braces -nostdlib
OPT_FLAGS = -g
LDFLAGS = -L$(NUSYSLIBDIR) -L$(ULTRALIBDIR) -L$(ULTRAGCCDIR) -lnusys_d -lultra_rom -lgcc -lnustd
# +-------+
# | Rules |
# *-------+
-include $(BUILDIR)/*.d
default: $(ROM)
$(ROM): $(TEXTURES) $(CODE)
$(MAKEROM) spec.cvt -I$(NUSYSINCDIR) -L$(PRLIBDIR) -r$(ROM) -e$(BINARY)
$(MAKEMASK) $(ROM)
$(CODE): $(CODEOBJECTS) Makefile
$(LD) -o $(CODE) -r $(CODEOBJECTS) $(LDFLAGS)
$(BUILDIR)/%.c.o: %.c
mkdir -p $(dir $@)
$(CC) $(C_FLAGS) $(OPT_FLAGS) -c $< -o $@
$(TEXTURES): $(TEXOBJECTS) $(TOOLOBJECTS) Makefile
$(BLOBINATOR) -i $(TEXBUILDDIR) -e .inc -t TEXTURES -o $(TEXTURES) -d $(TEXTUREMAP) -m $(TEXTURELUT)
$(TEXBUILDDIR)/%.rgba16.png.inc: $(TEXDIR)/%.rgba16.png
mkdir -p $(dir $@)
$(N64GRAPHICS) -i $@ -g $< -f rgba -s 16 -m $(TEXTUREMAP)
$(TOOLBUILD)/%.tool: $(TOOLDIR)/%.cs
mkdir -p $(dir $@)
mcs $< -out:$@
clean:
rm -rf $(BUILDIR)