-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
233 lines (186 loc) · 6.31 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
#
# kartvid configuration
#
BUILDOS=$(shell uname -s)
CC = gcc
CFLAGS = -Wall -O2 -fno-omit-frame-pointer
ifeq ($(BUILDOS),Darwin)
LIBPNG_CPPFLAGS = -I/usr/X11/include
LIBPNG_LDFLAGS = -L/usr/X11/lib -lpng
else
LIBPNG_CPPFLAGS = -I/opt/local/include
LIBPNG_LDFLAGS = -L/opt/local/lib -R/opt/local/lib -lpng16
endif
ifeq ($(BUILDOS),SunOS)
LDFLAGS += -lm
endif
FFMPEG_CPPFLAGS = -I/usr/local/include
FFMPEG_CPPFLAGS += -Wno-deprecated-declarations
FFMPEG_LDFLAGS = -L/usr/local/lib -R/usr/local/lib
FFMPEG_LDFLAGS += -lavformat -lavcodec -lavutil -lswscale
KARTVID = out/kartvid
KART = js/kart.js
CSCOPE_DIRS += src
CLEAN_FILES += $(KARTVID)
CLEAN_FILES += out/kartvid.o out/img.o out/kv.o out/video.o
#
# mask configuration
#
CHARS = mario luigi peach toad yoshi wario dk bowser
ITEMS = banana banana_bunch blank blue dud ghost green3 green \
lightning mushroom mushroom2 mushroom3 red red3 star super_mushroom \
box_frame
# Some of the tracks were manually generated from the char_* sources.
# The rest are automatically built here.
GENTRACKS = banshee bowser dk luigi rainbow toad wario yoshi
MASKS_GENERATED = \
$(CHARS:%=assets/masks/char_%_2.png) \
$(CHARS:%=assets/masks/char_%_2zout.png) \
$(CHARS:%=assets/masks/char_%_3.png) \
$(CHARS:%=assets/masks/char_%_3zout.png) \
$(CHARS:%=assets/masks/char_%_4.png) \
$(CHARS:%=assets/masks/char_%_4zout.png) \
$(ITEMS:%=assets/masks/item_%_2.png) \
$(ITEMS:%=assets/masks/item_%_3.png) \
$(ITEMS:%=assets/masks/item_%_4.png) \
assets/masks/pos1_square2.png \
assets/masks/pos1_square3.png \
assets/masks/pos1_square4.png \
assets/masks/pos2_square2.png \
assets/masks/pos2_square3.png \
assets/masks/pos2_square4.png \
assets/masks/pos3_square2.png \
assets/masks/pos3_square3.png \
assets/masks/pos3_square4.png \
assets/masks/pos4_square2.png \
assets/masks/pos4_square3.png \
assets/masks/pos4_square4.png \
assets/masks/pos1_square2_final.png \
assets/masks/pos1_square3_final.png \
assets/masks/pos1_square4_final.png \
assets/masks/pos2_square2_final.png \
assets/masks/pos2_square3_final.png \
assets/masks/pos2_square4_final.png \
assets/masks/pos3_square2_final.png \
assets/masks/pos3_square3_final.png \
assets/masks/pos3_square4_final.png \
$(GENTRACKS:%=assets/masks/track_%.png) \
$(GENTRACKS:%=assets/masks/track_%_zout.png)
CLEAN_FILES += $(MASKS_GENERATED)
#
# Node configuration
#
NPM = npm
NODE_MODULES = node_modules
JSL_CONF_NODE = tools/jsl.node.conf
JSL_CONF_WEB = tools/jsl.web.conf
JSL_FILES_NODE := $(shell find js test -name '*.js') \
tools/vsplit tools/json_normalize
JSL_FILES_WEB := $(shell find docs/resources/js -name '*.js')
JSSTYLE_FILES := $(JSL_FILES_NODE) $(JSL_FILES_WEB)
CSCOPE_DIRS += js docs
#
# "all" builds kartvid, then each of the masks
#
all: $(KARTVID) $(MASKS_GENERATED) $(NODE_MODULES)
.PHONY: masks
masks: $(MASKS_GENERATED)
clean-kartvid:
-rm -f $(KARTVID) out/*.o
clean-masks:
-rm -f $(MASKS_GENERATED)
out:
mkdir $@
#
# kartvid targets
#
out/%.o: src/%.c | out
$(CC) -c -o $@ $(CFLAGS) $(CPPFLAGS) $(LIBPNG_CPPFLAGS) \
$(FFMPEG_CPPFLAGS) $^
$(KARTVID): out/kartvid.o out/img.o out/kv.o out/video.o | out
$(CC) -o $@ $(LDFLAGS) $(LIBPNG_LDFLAGS) $(FFMPEG_LDFLAGS) $^
#
# mask targets
#
#
#
# Masks for characters and items in squares 2, 3, and 4 are generated from the
# mask for square 1 using known offsets. See assets/masks/offsets.txt.
#
KVCHAR1TO2 = $(KARTVID) translatexy $^ $@ 323 0
KVCHAR1TO3 = $(KARTVID) translatexy $^ $@ 0 240
KVCHAR1TO4 = $(KARTVID) translatexy $^ $@ 323 240
KVITEM1TO2 = $(KARTVID) translatexy $^ $@ 495 0
KVITEM1TO3 = $(KARTVID) translatexy $^ $@ 0 230
KVITEM1TO4 = $(KARTVID) translatexy $^ $@ 495 230
assets/masks/char_%_2.png: assets/masks/char_%_1.png
$(KVCHAR1TO2)
assets/masks/char_%_2zout.png: assets/masks/char_%_1zout.png
$(KVCHAR1TO2)
assets/masks/char_%_3.png: assets/masks/char_%_1.png
$(KVCHAR1TO3)
assets/masks/char_%_3zout.png: assets/masks/char_%_1zout.png
$(KVCHAR1TO3)
assets/masks/char_%_4.png: assets/masks/char_%_1.png
$(KVCHAR1TO4)
assets/masks/char_%_4zout.png: assets/masks/char_%_1zout.png
$(KVCHAR1TO4)
assets/masks/item_%_2.png: assets/masks/item_%_1.png
$(KVITEM1TO2)
assets/masks/item_%_3.png: assets/masks/item_%_1.png
$(KVITEM1TO3)
assets/masks/item_%_4.png: assets/masks/item_%_1.png
$(KVITEM1TO4)
assets/masks/track_%.png: assets/mask_sources/track_%.png
$(KARTVID) and $^ assets/masks/gen_track.png $@
assets/masks/track_%_zout.png: assets/mask_sources/track_%_zoomout.png
$(KARTVID) and $^ assets/masks/gen_track_zout.png $@
#
# Masks for final position numbers in each square are also generated from square
# 1, but with different offsets.
#
KVFPOS1TO2 = $(KARTVID) translatexy $^ $@ 460 0
KVFPOS1TO3 = $(KARTVID) translatexy $^ $@ 0 220
KVFPOS1TO4 = $(KARTVID) translatexy $^ $@ 460 220
assets/masks/pos%_square2_final.png: assets/masks/pos%_square1_final.png
$(KVFPOS1TO2)
assets/masks/pos%_square3_final.png: assets/masks/pos%_square1_final.png
$(KVFPOS1TO3)
assets/masks/pos%_square4_final.png: assets/masks/pos%_square1_final.png
$(KVFPOS1TO4)
#
# Finally, the regular position numbers work similarly.
#
KVPOS1TO2 = $(KARTVID) translatexy $^ $@ 494 0
KVPOS1TO3 = $(KARTVID) translatexy $^ $@ 0 220
KVPOS1TO4 = $(KARTVID) translatexy $^ $@ 494 220
assets/masks/pos%_square2.png: assets/masks/pos%_square1.png
$(KVPOS1TO2)
assets/masks/pos%_square3.png: assets/masks/pos%_square1.png
$(KVPOS1TO3)
assets/masks/pos%_square4.png: assets/masks/pos%_square1.png
$(KVPOS1TO4)
include ./Makefile.targ
#
# Node-related targets
#
$(NODE_MODULES): package.json
$(NPM) install
#
# Testing targets
#
TEST_ROOT = $(error TEST_ROOT must be defined in Makefile.conf)
TEST_OUTROOT = test-outputs
TEST_VIDEOS = $(wildcard $(TEST_ROOT)/*.mov)
TEST_VIDEOS_REL = $(subst $(TEST_ROOT)/,,$(TEST_VIDEOS))
TEST_OUTPUTS = $(TEST_VIDEOS_REL:%.mov=$(TEST_OUTROOT)/%.json)
TEXT_OUTPUTS = $(TEST_OUTPUTS:%.json=%.txt)
include Makefile.conf
.PHONY: test
test: $(TEST_OUTPUTS) $(TEXT_OUTPUTS)
clean-test:
-rm -f $(TEST_OUTPUTS) $(TEXT_OUTPUTS)
$(TEST_OUTPUTS): $(TEST_OUTROOT)/%.json: $(TEST_ROOT)/%.mov all
$(KARTVID) video -j $< > $@ 2>$(TEST_OUTROOT)/$*.err
$(TEXT_OUTPUTS): $(TEST_OUTROOT)/%.txt: $(TEST_OUTROOT)/%.json
$(KART) < $< > $@