1# common targets: 2# <no target>, build, ttf-dir: create dedicated dir with TTF files 3# ttf: create export dir with TTF files, track changes 4# 4web: dtto for TTF, WOFF, SVG, and EOT 5 6FONTFORGE = fontforge 7PYTHON = python3 8FONTLINT = fontlint 9 10# TTF->EOT converters in fallback order 11# the first one is canonical choice used in the release process 12MKEOT = mkeot 13# URLs to be used for root string within EOT file; 14# defaults to "libre roots" that allow usage on any common web page 15MKEOT_URLS = http:// https:// file:// 16TTF2EOT = ttf2eot 17ifneq ($(strip $(shell which $(MKEOT) 2>/dev/null)),) 18 make_eot = $(MKEOT) $(1) $(MKEOT_URLS) > $(2) 19else 20 ifneq ($(strip $(shell which $(TTF2EOT) 2>/dev/null)),) 21 make_eot = $(TTF2EOT) $(1) > $(2) 22 else 23 make_eot = $(error No tool for TTF->EOT conversion: $(MKEOT), $(TTF2EOT)) 24 endif 25endif 26 27EXPORTSCRIPT = scripts/fontexport.pe 28FONTTOOLSCRIPT = scripts/setisFixedPitch-fonttools.py 29SCRIPTS = $(EXPORTSCRIPT) scripts/sfd2ttf.pe scripts/ttf2sfd.pe 30MISCFILES = AUTHORS ChangeLog LICENSE README.md TODO 31SRCDIR = src 32EXPORTDIR = export 33CHECK_PREFIX = check 34 35VER = 2.1.1 36NAME = Liberation 37VARIANTS = \ 38 Mono-Regular Mono-Bold Mono-Italic Mono-BoldItalic \ 39 Sans-Regular Sans-Bold Sans-Italic Sans-BoldItalic \ 40 Serif-Regular Serif-Bold Serif-Italic Serif-BoldItalic 41 42DISTPREFIX := liberation-fonts-$(VER) 43DISTPREFIX_TTF := liberation-fonts-ttf-$(VER) 44SFDFILES := $(addprefix $(SRCDIR)/$(NAME), $(VARIANTS:=.sfd)) 45TTFFILES := $(addprefix $(EXPORTDIR)/$(NAME), $(VARIANTS:=.ttf)) 46 47# keeping backward compatibility for "build" 48all build: ttf-dir 49 50$(EXPORTDIR): 51 mkdir -p $@ 52 53# TrueType/OpenType Font, general usage 54# - ttf cares about source file changes, using shared EXPORTDIR 55# - ttf-dir should be a bit more efficient, creating dedicated dir for TTF 56FORMATS = ttf 57ttf-dir:: $(SFDFILES) 58 $(FONTFORGE) -script $(EXPORTSCRIPT) -ttf $^ 59 $(PYTHON) $(FONTTOOLSCRIPT) src/LiberationMono-*.ttf 60 mv src/LiberationMono-Regular-fixed.ttf src/LiberationMono-Regular.ttf 61 mv src/LiberationMono-Italic-fixed.ttf src/LiberationMono-Italic.ttf 62 mv src/LiberationMono-Bold-fixed.ttf src/LiberationMono-Bold.ttf 63 mv src/LiberationMono-BoldItalic-fixed.ttf src/LiberationMono-BoldItalic.ttf 64 mkdir -p $(DISTPREFIX_TTF) 65 mv $(addsuffix .ttf,$(basename $^)) $(DISTPREFIX_TTF) 66 67# web sites usage 68# Web Open Font Format (WOFF); for all modern browsers (W3C recommendation) 69FORMATS += woff 70# SVG Font; only for WebKit and Presto based browsers (Firefox "avoids" it) 71FORMATS += svg 72# Embedded OpenType (EOT); MSIE only [extra recipe, FontForge can't create EOT] 73FORMATS += eot 74eot:: $(addprefix $(EXPORTDIR)/$(NAME), $(VARIANTS:=.eot)) 75 @echo 76$(EXPORTDIR)/%.eot: $(EXPORTDIR)/%.ttf | $(EXPORTDIR) 77 $(call make_eot,$<,$@) 784web: ttf woff svg eot 79 80# XXX: declare other formats here if needed (TeX, etc.) 81 82# default for formats without extra recipes defined above (e.g., not "eot"): 83# summary per-format target + single file export for these declared formats 84define FORMAT_template = 85$(1):: $$(addprefix $$(EXPORTDIR)/$$(NAME), $$(VARIANTS:=.$(1))) 86 @echo 87$$(EXPORTDIR)/%.$(1):: $$(SRCDIR)/%.sfd | $$(EXPORTDIR) 88 $$(FONTFORGE) -script $$(EXPORTSCRIPT) -$$(lastword $$(subst ., ,$$@)) $$< 2>/dev/null 89 mv $$(SRCDIR)/$$(notdir $$@) $$(EXPORTDIR) 90endef 91$(foreach format,$(FORMATS),$(eval $(call FORMAT_template,$(format)))) 92 93dist: clean-dist dist-sfd dist-ttf 94dist-src: dist-sfd 95 96dist-sfd:: $(SFDFILES) 97 tempdir=$$(mktemp -d) \ 98 && mkdir -p $${tempdir}/$(DISTPREFIX)/{src,scripts} \ 99 && cp Makefile $(MISCFILES) $${tempdir}/$(DISTPREFIX) \ 100 && cp $(SFDFILES) $${tempdir}/$(DISTPREFIX)/src \ 101 && cp $(SCRIPTS) $(FONTTOOLSCRIPT) $${tempdir}/$(DISTPREFIX)/scripts \ 102 && tar Cczvhf $${tempdir} $(DISTPREFIX).tar.gz $(DISTPREFIX) \ 103 || echo 'Problem encountered ($@)'; rm -rf -- $${tempdir} 104dist-ttf: ttf 105 $(PYTHON) $(FONTTOOLSCRIPT) export/LiberationMono-*.ttf 106 mv export/LiberationMono-Regular-fixed.ttf export/LiberationMono-Regular.ttf 107 mv export/LiberationMono-Italic-fixed.ttf export/LiberationMono-Italic.ttf 108 mv export/LiberationMono-Bold-fixed.ttf export/LiberationMono-Bold.ttf 109 mv export/LiberationMono-BoldItalic-fixed.ttf export/LiberationMono-BoldItalic.ttf 110 tempdir=$$(mktemp -d) \ 111 && mkdir -p $${tempdir}/$(DISTPREFIX_TTF) \ 112 && cp $(MISCFILES) $(TTFFILES) $${tempdir}/$(DISTPREFIX_TTF) \ 113 && tar Cczvhf $${tempdir} $(DISTPREFIX_TTF).tar.gz $(DISTPREFIX_TTF) \ 114 || echo 'Problem encountered ($@)'; rm -rf -- $${tempdir} 115# substitute tar line with this if needed: 116# && zip -j $(DISTPREFIX_TTF).zip $(MISCFILES) $(TTFFILES) \ 117 118check: 119 log="$(CHECK_PREFIX)_$$(git describe --dirty --always 2>/dev/null||date +%Y%m%d)" \ 120 && for sfd in $(SFDFILES); do \ 121 $(FONTLINT) $${sfd} 2>/dev/null | tee -a $${log}; echo; \ 122 done 123 124clean: clean-dist 125 rm -rf -- $(DISTPREFIX)* $(DISTPREFIX_TTF)* 126 rm -rf -- $(EXPORTDIR) 127 rm -f -- $(CHECK_PREFIX)_* 128clean-dist: 129 rm -f -- *.tar.gz *.zip 130 131.PHONY: all build ttf-dir ttf dist dist-src dist-sfd dist-ttf 4web $(FORMATS) check clean clean-dist 132