main/Makefile
Doug Felt 43a7990b6a Change Makefile to be smarter about dependencies.
This reverts some changes in commit b257b6647d that were causing build
issues.  Those changes quoted the path to pngquant in order to deal
with spaces in the path, but as a side effect that prevented
build-dependency analysis (gnu 3.81 on ubuntu) from recognizing that
the .png files didn't need to be built, and so rebuilt them every
time, which takes several minutes.  Apparently make doesn't like
quotes-- strings passed to the shell are fine, but things make itself
processes (like names of targets) are treated literally.

Since the path to pngquant is (now, anyway) a local subpath of the
current directory that has no spaces, it should be ok to use the
subpath and not bother to quote.

Another change replaces two dependencies on flag-symlinks with a
dependency on PNG128_FLAGS, for the same reason: after flag-symlinks
executed it was not recognized as being up to date and so the rules
with these dependencies always executed.
2015-10-14 17:18:29 -07:00

107 lines
3.3 KiB
Makefile

# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
EMOJI = NotoColorEmoji
font: $(EMOJI).ttf
CFLAGS = -std=c99 -Wall -Wextra `pkg-config --cflags --libs cairo`
LDFLAGS = `pkg-config --libs cairo`
PNGQUANTDIR := third_party/pngquant
PNGQUANT := $(PNGQUANTDIR)/pngquant
PNGQUANTFLAGS = --speed 1 --skip-if-larger --ext '.png' --force
$(PNGQUANT):
$(MAKE) -C $(PNGQUANTDIR)
waveflag: waveflag.c
$(CC) $< -o $@ $(CFLAGS) $(LDFLAGS)
LIMITED_FLAGS = CN DE ES FR GB IT JP KR RU US
FLAGS = AD AE AF AG AI AL AM AO AR AS AT AU AW AX AZ \
BA BB BD BE BF BG BH BI BJ BM BN BO BR BS BT BW BY BZ \
CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ \
DE DJ DK DM DO DZ \
EC EE EG ER ES ET EU \
FI FJ FM FO FR \
GA GB GD GE GG GH GI GL GM GN GQ GR GT GU GW GY \
HK HN HR HT HU \
ID IE IL IM IN IO IQ IR IS IT \
JE JM JO JP \
KE KG KH KI KM KN KP KR KW KY KZ \
LA LB LC LI LK LR LS LT LU LV LY \
MA MC MD ME MG MH MK ML MM MN MO MP MR MS MT MU MV MW MX MY MZ \
NA NE NF NG NI NL NO NP NR NU NZ \
OM \
PA PE PF PG PH PK PL PN PR PS PT PW PY \
QA \
RO RS RU RW \
SA SB SC SD SE SG SI SK SL SM SN SO SR SS ST SV SX SY SZ \
TC TD TG TH TJ TK TL TM TN TO TR TT TV TW TZ \
UA UG US UY UZ \
VA VC VE VG VI VN VU \
WS \
YE \
ZA ZM ZW
FLAGS_SRC_DIR = third_party/region-flags/png
FLAGS_DIR = ./flags
GLYPH_NAMES := $(shell ./flag_glyph_name.py $(FLAGS))
WAVED_FLAGS := $(foreach flag,$(FLAGS),$(FLAGS_DIR)/$(flag).png)
PNG128_FLAGS := $(foreach glyph_name,$(GLYPH_NAMES),$(addprefix ./png/128/emoji_$(glyph_name),.png))
$(FLAGS_DIR)/%.png: $(FLAGS_SRC_DIR)/%.png ./waveflag $(PNGQUANT)
mkdir -p $(FLAGS_DIR)
./waveflag "$<" "$@"
optipng -quiet -o7 "$@"
$(PNGQUANT) $(PNGQUANTFLAGS) "$@"
flag-symlinks: $(WAVED_FLAGS)
$(subst ^, , \
$(join \
$(FLAGS:%=ln^-fs^../../flags/%.png^), \
$(GLYPH_NAMES:%=./png/128/emoji_%.png;) \
) \
)
$(PNG128_FLAGS): flag-symlinks
EMOJI_PNG128 = ./png/128/emoji_u
EMOJI_BUILDER = third_party/color_emoji/emoji_builder.py
ADD_GLYPHS = third_party/color_emoji/add_glyphs.py
PUA_ADDER = map_pua_emoji.py
VS_ADDER = add_vs_cmap.py
%.ttx: %.ttx.tmpl $(ADD_GLYPHS) $(UNI) $(PNG128_FLAGS)
python $(ADD_GLYPHS) "$<" "$@" "$(EMOJI_PNG128)"
%.ttf: %.ttx
@rm -f "$@"
ttx "$<"
$(EMOJI).ttf: $(EMOJI).tmpl.ttf $(EMOJI_BUILDER) $(PUA_ADDER) $(VS_ADDER) \
$(EMOJI_PNG128)*.png $(PNG128_FLAGS)
python $(EMOJI_BUILDER) -V $< "$@" $(EMOJI_PNG128)
python $(PUA_ADDER) "$@" "$@-with-pua"
$(VS_ADDER) --dstdir '.' -o "$@-with-pua-varsel" "$@-with-pua"
mv "$@-with-pua-varsel" "$@"
rm "$@-with-pua"
clean:
rm -f $(EMOJI).ttf $(EMOJI).tmpl.ttf $(EMOJI).tmpl.ttx
rm -f waveflag
rm -rf $(FLAGS_DIR)
rm -f `find -type l -name "*.png"`