f7e1fb052a881fcadcca869cdb52e0172a92b2fb
[unifont.git] / font / Makefile
1 #
2 # Makefile to build a version of GNU Unifont with the
3 # unifoundry.com GNU Unifont utilities.  This Makefile
4 # converts unifont-$(VERSION).hex and related files into a final
5 # GNU Unifont font file.
6 #
7 # This software is released under version 2.0 of the GNU Public License,
8 # or (at your option) a later version of the GPL.
9 #
10 # Paul Hardy, 7 July 2008
11 #
12 # commands will be interpreted with the Bourne Shell
13 #
14 SHELL = /bin/sh
15 INSTALL = install
16 FONTFORGE = fontforge
17 #
18 # assembly date of this version
19 #
20 MAJORVERSION = 6.3
21 DATE = 20131215
22 VERSION = $(MAJORVERSION).$(DATE)
23
24 COPYRIGHT = "Copyright (C) 2013 Roman Czyborra, Paul Hardy, et al.  \
25 Licensed under the GNU General Public License; either version 2, or \
26 (at your option) a later version, with the GNU Font Embedding Exception."
27
28 #
29 # Path to local unifont-bin utilities.  If your system doesn't
30 # use GNU's version of "make", use the first BINDIR definition.
31 # If using GNU's "make", use the second BINDIR definition.
32 #
33 # BINDIR = ../bin
34 BINDIR = $(CURDIR)/../bin
35 #
36 # The top-level directory for installing fonts on the system,
37 # and the installation directories for PCF and TrueType fonts.
38 #
39 FONTDEST = $(DESTDIR)/usr/share/fonts
40 PCFDEST = $(FONTDEST)/X11/misc
41 TTFDEST = $(FONTDEST)/truetype/unifont
42 #
43 # destination directory for compiled fonts
44 #
45 COMPILED_DIR = compiled
46 #
47 # destination directory for .bmp representation of font
48 #
49 BMPDIR = $(COMPILED_DIR)/bmp
50 #
51 # Directory with original unifont-$(VERSION).hex files
52 #
53 HEXDIR = hexsrc
54 #
55 # These are the files for building GNU Unifont with the Qianqian Fang's
56 # Wen Quan Yi CJK ideographs.  This version provides complete coverage
57 # of the Unicode Basic Multilingual Plane.
58 #
59 # If you want don't want to inlcude blank glyphs in unassigned code points,
60 # uncomment the UNASSIGNED definition or override from the make command line.
61 #
62 # Likewise, uncomment the PUA definiation if you want to use Private
63 # Use Area glyphs.
64 #
65 UNASSIGNED = $(HEXDIR)/unassigned.hex
66 # UNASSIGNED =
67
68 #
69 # Non-printing glyphs.  There are only about 100 of these, and many end
70 # users do want to print representations of these glyphs, so they are
71 # included as an optional assignment.
72 #
73 NONPRINTING = $(HEXDIR)/nonprinting.hex
74 # NONPRINTING =
75
76 #
77 # Private Use Area glyphs.  Uncomment to include four-digit hexadecimal glyphs
78 # or override from the make command line.
79 #
80 # PUA = $(HEXDIR)/pua.hex
81 PUA = 
82
83 # The remaining .hex files will be constant unless a customized font
84 # is being built.
85 UNIFONTBASE = $(HEXDIR)/unifont-base.hex
86 CJK         = $(HEXDIR)/wqy.hex
87 HANGUL      = $(HEXDIR)/hangul-syllables.hex
88 SPACES      = $(HEXDIR)/spaces.hex
89
90 UNIFILES = $(UNIFONTBASE) $(CJK) $(HANGUL) $(SPACES) $(UNASSIGNED) \
91            $(NONPRINTING) $(PUA)
92
93 #
94 # Location of the file containing a list of Unicode combining characters.
95 #
96 COMBINING = ttfsrc/combining.txt
97
98 VPATH = hexsrc ttfsrc
99
100 #
101 # Location of  TTF source directory, where TTF font is built.
102 #
103 TTFSRC = ttfsrc
104
105
106 all: compiled
107
108 compiled: $(UNIFILES) $(COMBINING)
109         make compiled-files
110
111 compiled-files: pcf bmp ttf bigpic coverage
112         install -p index.html $(COMPILED_DIR)/index.html
113
114 #
115 # Build the aggregate .hex font files
116 #
117 hex: distclean
118         if [ ! -d $(COMPILED_DIR) ] ; then \
119            mkdir -p $(COMPILED_DIR) ; \
120         fi
121         sort $(UNIFILES) >$(COMPILED_DIR)/unifont-$(VERSION).hex
122         (cd $(HEXDIR) ; sort *.hex) | \
123            $(BINDIR)/unigencircles ttfsrc/combining.txt hexsrc/nonprinting.hex \
124            > $(COMPILED_DIR)/unifont_sample-$(VERSION).hex
125
126 #
127 # Build a BDF font file from the final .hex file.
128 #
129 bdf: hex
130         # First make the default BDF font.  The font name will be "unifont".
131         $(BINDIR)/hex2bdf --version "$(VERSION)" --copyright $(COPYRIGHT) \
132            $(COMPILED_DIR)/unifont-$(VERSION).hex \
133            >$(COMPILED_DIR)/unifont-$(VERSION).bdf
134         gzip -f -9 <$(COMPILED_DIR)/unifont-$(VERSION).bdf \
135                    >$(COMPILED_DIR)/unifont-$(VERSION).bdf.gz
136         # Now make a version with combining circles.  The font name
137         # will be "unifont_sample" instead of "unifont" to distinguish
138         # it from the default font.
139         $(BINDIR)/hex2bdf --font "Unifont Sample" \
140            --version "$(VERSION)" --copyright $(COPYRIGHT) \
141              $(COMPILED_DIR)/unifont_sample-$(VERSION).hex \
142            > $(COMPILED_DIR)/unifont_sample-$(VERSION).bdf
143         gzip -f -9 <$(COMPILED_DIR)/unifont_sample-$(VERSION).bdf \
144                    >$(COMPILED_DIR)/unifont_sample-$(VERSION).bdf.gz
145
146 #
147 # Build a PCF font file from the final .hex file.
148 #
149 pcf: bdf
150         bdftopcf <$(COMPILED_DIR)/unifont-$(VERSION).bdf \
151                  >$(COMPILED_DIR)/unifont-$(VERSION).pcf
152         $(FONTFORGE) -lang=ff -c \
153            'Open($$1); \
154             SetFontNames("UnifontMedium", "GNU", "Unifont", "Medium", $(COPYRIGHT), "$(VERSION)"); \
155             Save($$1)' \
156            $(COMPILED_DIR)/unifont-$(VERSION).pcf
157         gzip -f -9 $(COMPILED_DIR)/unifont-$(VERSION).pcf
158         bdftopcf <$(COMPILED_DIR)/unifont_sample-$(VERSION).bdf \
159                  >$(COMPILED_DIR)/unifont_sample-$(VERSION).pcf
160         $(FONTFORGE) -lang=ff -c \
161            'Open($$1); \
162             SetFontNames("UnifontSampleMedium", "GNU", "Unifont Sample", "Medium", $(COPYRIGHT), "$(VERSION)"); \
163             Save($$1)' \
164            $(COMPILED_DIR)/unifont_sample-$(VERSION).pcf
165         gzip -f -9 $(COMPILED_DIR)/unifont_sample-$(VERSION).pcf
166
167 #
168 # Print coverage of scripts in Basic Multilingual Plane in .txt file.
169 #
170 # Note: can't use this older version unless unassigned.hex is merged
171 # with the rest of the built unifont-$(VERSION).hex final file.
172 #
173 # coverage: $(COMPILED_DIR)/unifont-$(VERSION).hex $(BINDIR)/unicoverage
174 #       $(BINDIR)/unicoverage < $(COMPILED_DIR)/unifont-$(VERSION).hex \
175 #                   > $(COMPILED_DIR)/coverage.txt
176 #
177 # Use this version because "unassigned.hex" isn't part of the final
178 # .hex font by default now:
179 #
180 coverage:
181         sort $(HEXDIR)/*.hex | \
182                 $(BINDIR)/unicoverage > $(COMPILED_DIR)/coverage.txt
183
184 #
185 # Print HTML page coverage in Basic Multilingual Plane in .txt file.
186 #
187 pagecount: $(COMPILED_DIR)/unifont-$(VERSION).hex $(BINDIR)/unipagecount
188         $(BINDIR)/unipagecount -l < $(COMPILED_DIR)/unifont-$(VERSION).hex \
189                         > $(COMPILED_DIR)/pagecount.html
190
191 #
192 # Create the .bmp (Windows Bitmap) graphics versions of the glyphs.
193 #
194 bmp: hex $(BINDIR)/unihex2bmp
195         if [ ! -d $(BMPDIR) ] ; then \
196            mkdir -p $(BMPDIR) ; \
197         fi
198         for i in 0 1 2 3 4 5 6 7 8 9 A B C D E F; do \
199            for j in 0 1 2 3 4 5 6 7 8 9 A B C D E F; do \
200               $(BINDIR)/unihex2bmp -p$$i$$j \
201                  -i$(COMPILED_DIR)/unifont_sample-$(VERSION).hex \
202                  -o$(BMPDIR)/uni$$i$$j.bmp ; \
203            done ; \
204         done ; \
205         echo "Done creating $(BMPDIR)"
206
207 #
208 # Build one bitmap of the entire Unifont as a 4096 x 16 grid.
209 #
210 bigpic: $(COMPILED_DIR)/unifont_sample-$(VERSION).hex
211         cat $(COMPILED_DIR)/unifont_sample-$(VERSION).hex | \
212            $(BINDIR)/unifontpic -d120 > $(COMPILED_DIR)/unifont-$(VERSION).bmp
213
214 #
215 # Note that $(TTFSRC) must exist, because it contains some source files
216 # Perform a "make && make clean" because ALL of the files would consume
217 # over 200 Megabytes if left around.  The .sfd file is about 100 Megabytes,
218 # and it is created from merging "[0-F].sfd", which take up another 100 MB.
219 #
220
221 ttf:
222         # First copy the ordinary version, to make a TrueType font.
223         install -p \
224                 $(COMPILED_DIR)/unifont-$(VERSION).hex \
225                 $(TTFSRC)/unifont.hex
226         # Second copy unifont_sample.bdf, to make an SBIT font.
227         install -p \
228                 $(COMPILED_DIR)/unifont_sample-$(VERSION).bdf \
229                 $(TTFSRC)/unifont_sample.bdf
230         cd $(TTFSRC) ; make && make clean
231         mv $(TTFSRC)/unifont.sfd $(COMPILED_DIR)/unifont.sfd 
232         mv $(TTFSRC)/unifont.ttf \
233                 $(COMPILED_DIR)/unifont-$(VERSION).ttf 
234         mv $(TTFSRC)/unifont_sample.ttf \
235                 $(COMPILED_DIR)/unifont_sample-$(VERSION).ttf 
236         gzip -f -9 $(COMPILED_DIR)/unifont.sfd 
237
238 #
239 # Copy the newly created files from $(COMPILED_DIR) to the precompiled/
240 # directory.  This has to be called manually, because the precompiled/
241 # directory usually remains untouched.
242 #
243 precompiled: all
244         \rm -rf precompiled
245         install -m0755 -d precompiled
246         install -m0644 -p $(COMPILED_DIR)/unifont-$(VERSION).hex \
247                           $(COMPILED_DIR)/unifont-$(VERSION).bdf.gz \
248                           $(COMPILED_DIR)/unifont-$(VERSION).pcf.gz \
249                           $(COMPILED_DIR)/unifont-$(VERSION).ttf \
250                           $(COMPILED_DIR)/unifont_sample-$(VERSION).hex \
251                           $(COMPILED_DIR)/unifont_sample-$(VERSION).bdf.gz \
252                           $(COMPILED_DIR)/unifont_sample-$(VERSION).pcf.gz \
253                           $(COMPILED_DIR)/unifont_sample-$(VERSION).ttf \
254                           $(COMPILED_DIR)/coverage.txt \
255                           $(COMPILED_DIR)/unifont-$(VERSION).bmp \
256            precompiled
257
258 #
259 # This is set up for Debian.  Solaris places fonts in
260 # "/usr/share/fonts/TrueType".  Other unices use other directories.
261 # The original font format was BDF, but Debian doesn't use that and
262 # xfs should only need TrueType, so the BDF font isn't installed.
263 #
264 # The TrueType font is about 16 Megabytes.  To avoid duplication,
265 # the fonts are installed as symbolic links back to the original package.
266 # Alternatively, the fonts can be copied to the destination directory
267 # with "install -m0644" or moved there (but "mv" is a destructive
268 # one-time operation).
269 #
270 # After installing the new fonts, register them with X Window System using:
271 #
272 #      xset fp rehash
273 #
274 install:
275         if [ x$(CURDIR) = x ] ; \
276         then \
277            echo "Fatal Error: CURDIR not defined -- define in Makefile." ; \
278            exit 1 ; \
279         fi
280         $(INSTALL) -m0755 -d $(PCFDEST)
281         $(INSTALL) -m0755 -d $(TTFDEST)
282         if [ ! -d $(COMPILED_DIR) ] ; then \
283            $(INSTALL) -m0644 -p $(CURDIR)/precompiled/unifont-$(VERSION).pcf.gz $(PCFDEST)/unifont.pcf.gz ; \
284            $(INSTALL) -m0644 -p $(CURDIR)/precompiled/unifont_sample-$(VERSION).pcf.gz $(PCFDEST)/unifont_sample.pcf.gz ; \
285            $(INSTALL) -m0644 -p $(CURDIR)/precompiled/unifont-$(VERSION).ttf    $(TTFDEST)/unifont.ttf ; \
286            $(INSTALL) -m0644 -p $(CURDIR)/precompiled/unifont_sample-$(VERSION).ttf    $(TTFDEST)/unifont_sample.ttf ; \
287         else \
288            $(INSTALL) -m0644 -p $(CURDIR)/$(COMPILED_DIR)/unifont-$(VERSION).pcf.gz $(PCFDEST)/unifont.pcf.gz ; \
289            $(INSTALL) -m0644 -p $(CURDIR)/$(COMPILED_DIR)/unifont_sample-$(VERSION).pcf.gz $(PCFDEST)/unifont_sample.pcf.gz ; \
290            $(INSTALL) -m0644 -p $(CURDIR)/$(COMPILED_DIR)/unifont-$(VERSION).ttf    $(TTFDEST)/unifont.ttf ; \
291            $(INSTALL) -m0644 -p $(CURDIR)/$(COMPILED_DIR)/unifont_sample-$(VERSION).ttf    $(TTFDEST)/unifont_sample.ttf ; \
292         fi
293
294 clean:
295         \rm -rf $(COMPILED_DIR)/bmp
296         \rm -f $(COMPILED_DIR)/unifont-$(VERSION).hex
297         \rm -f $(COMPILED_DIR)/unifont-$(VERSION).bdf
298         \rm -f $(COMPILED_DIR)/unifont-$(VERSION).bdf.gz
299         \rm -f *~
300
301 #
302 # Note that distclean leaves precompiled/ alone.  This is intentional.
303 # The .DS files are created under Mac OS X.
304 #
305 distclean:
306         \rm -rf $(COMPILED_DIR)
307         $(MAKE) -C ttfsrc distclean
308         \rm -f *~
309         \rm -rf .DS* ._.DS*
310
311 .PHONY: all hex bdf pcf coverage pagecount bmp bigpic ttf precompiled install clean distclean