| 1 |
SRCDIR := $(abspath $(lastword $(MAKEFILE_LIST))/../..) |
| 2 |
FONTDIR := ../build/fonts |
| 3 |
BIN := $(SRCDIR)/build/venv/bin |
| 4 |
VENV := ../build/venv/bin/activate |
| 5 |
Q = $(if $(filter 1,$(V) $(VERBOSE)),,@) # make V=1 for verbose mode |
| 6 |
export PATH := $(BIN):$(PATH) |
| 7 |
|
| 8 |
HTTP_SERVER_BIND_ADDR ?= 127.0.0.1 |
| 9 |
|
| 10 |
default: |
| 11 |
@echo "Please specify a target: build, serve, dist" >&2 |
| 12 |
|
| 13 |
build: .ruby-bundle |
| 14 |
rm -rf _site |
| 15 |
bundle exec jekyll build |
| 16 |
|
| 17 |
build-tmp: .ruby-bundle |
| 18 |
rm -rf _site-tmp |
| 19 |
bundle exec jekyll build --disable-disk-cache -b /tmp/inter-v4-website -d _site-tmp |
| 20 |
|
| 21 |
serve: .ruby-bundle |
| 22 |
$(Q)( sleep 3 && \ |
| 23 |
rm -f _site/lab/fonts && \ |
| 24 |
ln -s ../../../build/fonts _site/lab/fonts ) & |
| 25 |
@# |
| 26 |
@# need to delete generated content so that jekyll, being a little dumb, |
| 27 |
@# can manage to copy the font files into there again. |
| 28 |
@# Why not a symlink you ask? Jekyll traverses it and copies the content. |
| 29 |
@# In the past we tried to work around this by periodically removing the |
| 30 |
@# copied font files and re-creating the symlink, but it was a frail process. |
| 31 |
@# For live testing with fonts, you'll instead want to use docs/lab/serve.py |
| 32 |
$(Q)rm -rf _site |
| 33 |
$(Q)bundle exec jekyll serve -b '' --watch \ |
| 34 |
--config _config.yml,_config-dev.yml \ |
| 35 |
--host $(HTTP_SERVER_BIND_ADDR) --port 3002 \ |
| 36 |
--livereload --livereload-port 30002 |
| 37 |
|
| 38 |
serve-pub: |
| 39 |
exec $(MAKE) HTTP_SERVER_BIND_ADDR=0.0.0.0 serve |
| 40 |
|
| 41 |
optimize-images: |
| 42 |
$(Q)for f in $$(find . -type f -name \*.png); do \ |
| 43 |
echo optipng "$$f"; \ |
| 44 |
optipng -quiet "$$f" & \ |
| 45 |
done ; \ |
| 46 |
wait |
| 47 |
|
| 48 |
.ruby-bundle: Gemfile Gemfile.lock |
| 49 |
@if ! (command -v bundle >/dev/null && command -v jekyll >/dev/null); then \ |
| 50 |
echo "Please install Ruby bundle and jekyll: gem install bundler jekyll" >&2; \ |
| 51 |
exit 1; \ |
| 52 |
fi |
| 53 |
bundle update |
| 54 |
bundle install |
| 55 |
touch .ruby-bundle |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
dist: info lab/index.html |
| 60 |
info: fonts _data/fontinfo.json lab/glyphinfo.json |
| 61 |
fonts: font-files/Inter-Regular.woff2 |
| 62 |
|
| 63 |
FONTS_SRC := \ |
| 64 |
$(FONTDIR)/static/Inter-Black.woff2 \ |
| 65 |
$(FONTDIR)/static/Inter-BlackItalic.woff2 \ |
| 66 |
$(FONTDIR)/static/Inter-Bold.woff2 \ |
| 67 |
$(FONTDIR)/static/Inter-BoldItalic.woff2 \ |
| 68 |
$(FONTDIR)/static/Inter-ExtraBold.woff2 \ |
| 69 |
$(FONTDIR)/static/Inter-ExtraBoldItalic.woff2 \ |
| 70 |
$(FONTDIR)/static/Inter-ExtraLight.woff2 \ |
| 71 |
$(FONTDIR)/static/Inter-ExtraLightItalic.woff2 \ |
| 72 |
$(FONTDIR)/static/Inter-Italic.woff2 \ |
| 73 |
$(FONTDIR)/static/Inter-Light.woff2 \ |
| 74 |
$(FONTDIR)/static/Inter-LightItalic.woff2 \ |
| 75 |
$(FONTDIR)/static/Inter-Medium.woff2 \ |
| 76 |
$(FONTDIR)/static/Inter-MediumItalic.woff2 \ |
| 77 |
$(FONTDIR)/static/Inter-Regular.woff2 \ |
| 78 |
$(FONTDIR)/static/Inter-SemiBold.woff2 \ |
| 79 |
$(FONTDIR)/static/Inter-SemiBoldItalic.woff2 \ |
| 80 |
$(FONTDIR)/static/Inter-Thin.woff2 \ |
| 81 |
$(FONTDIR)/static/Inter-ThinItalic.woff2 \ |
| 82 |
$(FONTDIR)/static/InterDisplay-Black.woff2 \ |
| 83 |
$(FONTDIR)/static/InterDisplay-BlackItalic.woff2 \ |
| 84 |
$(FONTDIR)/static/InterDisplay-Bold.woff2 \ |
| 85 |
$(FONTDIR)/static/InterDisplay-BoldItalic.woff2 \ |
| 86 |
$(FONTDIR)/static/InterDisplay-ExtraBold.woff2 \ |
| 87 |
$(FONTDIR)/static/InterDisplay-ExtraBoldItalic.woff2 \ |
| 88 |
$(FONTDIR)/static/InterDisplay-ExtraLight.woff2 \ |
| 89 |
$(FONTDIR)/static/InterDisplay-ExtraLightItalic.woff2 \ |
| 90 |
$(FONTDIR)/static/InterDisplay-Italic.woff2 \ |
| 91 |
$(FONTDIR)/static/InterDisplay-Light.woff2 \ |
| 92 |
$(FONTDIR)/static/InterDisplay-LightItalic.woff2 \ |
| 93 |
$(FONTDIR)/static/InterDisplay-Medium.woff2 \ |
| 94 |
$(FONTDIR)/static/InterDisplay-MediumItalic.woff2 \ |
| 95 |
$(FONTDIR)/static/InterDisplay-Regular.woff2 \ |
| 96 |
$(FONTDIR)/static/InterDisplay-SemiBold.woff2 \ |
| 97 |
$(FONTDIR)/static/InterDisplay-SemiBoldItalic.woff2 \ |
| 98 |
$(FONTDIR)/static/InterDisplay-Thin.woff2 \ |
| 99 |
$(FONTDIR)/static/InterDisplay-ThinItalic.woff2 \ |
| 100 |
$(FONTDIR)/var/InterVariable.woff2 \ |
| 101 |
$(FONTDIR)/var/InterVariable-Italic.woff2 \ |
| 102 |
$(FONTDIR)/var/InterVariable.ttf |
| 103 |
|
| 104 |
font-files/Inter-Regular.woff2: $(FONTS_SRC) |
| 105 |
rm -rf font-files/Inter* |
| 106 |
mkdir -p font-files |
| 107 |
cp -a $^ font-files/ |
| 108 |
$(Q)touch $@ |
| 109 |
|
| 110 |
$(FONTS_SRC): |
| 111 |
@echo "Missing fonts in $(FONTDIR)" >&2 |
| 112 |
@echo "Did you forget to 'make web' in the repository root?" >&2 |
| 113 |
@exit 1 |
| 114 |
|
| 115 |
lab/index.html: ../version.txt ../misc/tools/patch-version.py |
| 116 |
. $(VENV); python ../misc/tools/patch-version.py $@ |
| 117 |
|
| 118 |
_data/fontinfo.json: ../misc/tools/fontinfo.py |
| 119 |
_data/fontinfo.json: font-files/Inter-Regular.woff2 |
| 120 |
. $(VENV); python ../misc/tools/fontinfo.py -pretty $< > $@ |
| 121 |
|
| 122 |
lab/glyphinfo.json: ../misc/tools/gen-glyphinfo.py ../misc/UnicodeData.txt |
| 123 |
lab/glyphinfo.json: ../build/ufo/Inter-Regular.ufo |
| 124 |
. $(VENV); python ../misc/tools/gen-glyphinfo.py -ucd ../misc/UnicodeData.txt $< > $@ |
| 125 |
../build/ufo/Inter-Regular.ufo: $(wildcard ../build/ufo/Inter-Regular.ufo/*.plist) |
| 126 |
touch $@ |
| 127 |
|
| 128 |
.PHONY: default build build-tmp serve serve-pub dist info fonts |