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