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
|
null :=
SPACE := $(null) $(null)
FFMPEG ?= ffmpeg
FFMPEG += -v warning -y
OPUSENC ?= opusenc
ZOPFLIPNG ?= zopflipng
DEFLOPT ?= wine DeflOpt
DEFLUFF ?= defluff
PNGQUANT ?= pngquant
CWEBP ?= cwebp
CWEBP += -short -alpha_cleanup
WEBPMUX ?= webpmux
CONVERT ?= convert
APNGASM ?= apngasm
UGLIFYJS ?= uglifyjs
DUMP ?= www/dump
all: video audio images js
# === VIDEO ===
VIDEO := $(wildcard $(DUMP)/video/*.mkv)
MP4 := $(patsubst %.mkv,%.mp4,$(VIDEO))
WEBM := $(patsubst %.mkv,%.webm,$(VIDEO))
OGV := $(patsubst %.mkv,%.ogv,$(VIDEO))
CVIDEO := $(MP4) $(WEBM) $(OGV)
video: $(CVIDEO)
%.mp4: %.mkv
$(FFMPEG) -i $< -c:v libx264 -preset slower -tune animation -c:a libfdk_aac $@
%.webm: %.mkv
$(FFMPEG) -i $< -strict -2 -c:v libvpx-vp9 -crf 8 -b:v 1M -c:a copy $@
%.ogv: %.mkv
$(FFMPEG) -i $< -c:v libtheora -qscale:v 10 -c:a copy $@
# === AUDIO ===
AUDIO := $(shell find $(DUMP)/bgm $(DUMP)/sfx -name '*.ogg')
OPUS := $(patsubst %.ogg,%.opus,$(AUDIO))
M4A := $(patsubst %.ogg,%.m4a,$(AUDIO))
CAUDIO := $(OPUS) $(M4A)
audio: $(CAUDIO)
%.wav: %.ogg
$(FFMPEG) -i $< -c:a pcm_s16le $@
%.opus: %.wav
$(FFMPEG) -i $< -c:a libopus -b:a 64k $@
%.m4a: %.wav
$(FFMPEG) -i $< -c:a libfdk_aac -vbr 1 $@
# === IMAGES ===
PNG := $(shell find $(DUMP) -name '*.png')
JPG := $(shell find $(DUMP) -name '*.jpg')
WEBP := $(patsubst %.png,%.webp,$(PNG)) \
$(patsubst %.jpg,%.webp,$(JPG))
CTC_ANIM_SRC := $(DUMP)/ui/ctc_strip.png
CTC_ANIM_TMP := $(DUMP)/ui/ctc_strip-0.png $(DUMP)/ui/ctc_strip-1.png $(DUMP)/ui/ctc_strip-2.png $(DUMP)/ui/ctc_strip-3.png $(DUMP)/ui/ctc_strip-4.png $(DUMP)/ui/ctc_strip-5.png $(DUMP)/ui/ctc_strip-6.png $(DUMP)/ui/ctc_strip-7.png $(DUMP)/ui/ctc_strip-8.png $(DUMP)/ui/ctc_strip-9.png $(DUMP)/ui/ctc_strip-10.png $(DUMP)/ui/ctc_strip-11.png $(DUMP)/ui/ctc_strip-12.png $(DUMP)/ui/ctc_strip-13.png $(DUMP)/ui/ctc_strip-14.png $(DUMP)/ui/ctc_strip-15.png $(DUMP)/ui/ctc_strip-16.png $(DUMP)/ui/ctc_strip-17.png $(DUMP)/ui/ctc_strip-18.png $(DUMP)/ui/ctc_strip-19.png $(DUMP)/ui/ctc_strip-20.png $(DUMP)/ui/ctc_strip-21.png $(DUMP)/ui/ctc_strip-22.png $(DUMP)/ui/ctc_strip-23.png $(DUMP)/ui/ctc_strip-24.png $(DUMP)/ui/ctc_strip-25.png $(DUMP)/ui/ctc_strip-26.png $(DUMP)/ui/ctc_strip-27.png $(DUMP)/ui/ctc_strip-28.png $(DUMP)/ui/ctc_strip-29.png $(DUMP)/ui/ctc_strip-30.png $(DUMP)/ui/ctc_strip-31.png $(DUMP)/ui/ctc_strip-32.png $(DUMP)/ui/ctc_strip-33.png $(DUMP)/ui/ctc_strip-34.png $(DUMP)/ui/ctc_strip-35.png $(DUMP)/ui/ctc_strip-36.png $(DUMP)/ui/ctc_strip-37.png $(DUMP)/ui/ctc_strip-38.png $(DUMP)/ui/ctc_strip-39.png $(DUMP)/ui/ctc_strip-40.png $(DUMP)/ui/ctc_strip-41.png $(DUMP)/ui/ctc_strip-42.png $(DUMP)/ui/ctc_strip-43.png $(DUMP)/ui/ctc_strip-44.png $(DUMP)/ui/ctc_strip-45.png $(DUMP)/ui/ctc_strip-46.png $(DUMP)/ui/ctc_strip-47.png $(DUMP)/ui/ctc_strip-48.png $(DUMP)/ui/ctc_strip-49.png $(DUMP)/ui/ctc_strip-50.png $(DUMP)/ui/ctc_strip-51.png $(DUMP)/ui/ctc_strip-52.png $(DUMP)/ui/ctc_strip-53.png $(DUMP)/ui/ctc_strip-54.png $(DUMP)/ui/ctc_strip-55.png $(DUMP)/ui/ctc_strip-56.png $(DUMP)/ui/ctc_strip-57.png $(DUMP)/ui/ctc_strip-58.png $(DUMP)/ui/ctc_strip-59.png $(DUMP)/ui/ctc_strip-60.png $(DUMP)/ui/ctc_strip-61.png $(DUMP)/ui/ctc_strip-62.png $(DUMP)/ui/ctc_strip-63.png
CTC_ANIM_TMP_WEBP := $(patsubst %.png,%.webp,$(CTC_ANIM_TMP))
CTC_ANIM := $(DUMP)/ui/ctc_anim.png $(DUMP)/ui/ctc_anim.webp
images: $(WEBP) $(CTC_ANIM) www/favicon.ico
%.webp: %.png
$(PNGQUANT) --force --speed 1 --ext .png $<
$(ZOPFLIPNG) -m -y $< $<
$(DEFLOPT) $<
$(DEFLUFF) < $< > $<.tmp
mv -f $<.tmp $<
$(CWEBP) -q 99 -m 6 $< -o $@
%.webp: %.jpg
$(CWEBP) -q 90 -m 6 $< -o $@
www/favicon.ico: $(DUMP)/ui/icon.png
$(CONVERT) $< -resize 256x256 -transparent white $@
$(DUMP)/ui/bt-cf-unchecked.webp $(DUMP)/ui/bt-cf-checked.webp: %.webp: %.png
$(CONVERT) -trim $< $<
$(PNGQUANT) --force --speed 1 --ext .png $<
$(ZOPFLIPNG) -m -y $< $<
$(DEFLOPT) $<
$(DEFLUFF) < $< > TMP$<
$(CWEBP) -q 99 -m 6 $< -o $@
$(DUMP)/ui/ctc_strip-0.png: $(CTC_ANIM_SRC)
$(CONVERT) $< -crop 16x16 $(patsubst %.png,%*.png,$<)
$(PNGQUANT) --force --speed 1 --ext .png $<
$(DUMP)/ui/ctc_strip-%.png: $(CTC_ANIM_SRC) $(DUMP)/ui/ctc_strip-0.png
@touch $@
$(DUMP)/ui/ctc_anim.png: $(CTC_ANIM_TMP)
$(APNGASM) $@ $^ 3 100
$(DUMP)/ui/ctc_anim.webp: $(CTC_ANIM_TMP_WEBP)
$(WEBPMUX) -frame $(subst $(SPACE), +30 -frame ,$^) +30 -loop 0 -o $@
# === JS ===
JS := www/js/html5ks.js www/js/menu.js www/js/api.js www/js/play.js www/js/images.js www/js/characters.js www/js/imachine.js www/js/i18n.js
js: www/js/all.min.js
www/js/all.min.js: $(JS)
$(UGLIFYJS) $^ -o $@ -p 2 -m -c
# === MISC ===
clean:
$(RM) $(CVIDEO) $(CAUDIO) $(WEBP) www/favicon.ico
jshint: $(JS)
jshint $^
watch:
while inotifywait -r -e modify,delete,move --exclude="^\./\.git" --exclude="\.swp$$" .; do \
${MAKE}; \
done
.PHONY: video audio images js jshint clean watch
.SUFFIXES:
|