unifont-6.3.20131020.tar.gz
[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 #
16 # assembly date of this version
17 #
18 MAJORVERSION = 6.3
19 DATE = 20131020
20 VERSION = $(MAJORVERSION).$(DATE)
21 #
22 # Path to local unifont-bin utilities.  If your system doesn't
23 # use GNU's version of "make", use the first BINDIR definition.
24 # If using GNU's "make", use the second BINDIR definition.
25 #
26 # BINDIR = ../bin
27 BINDIR = $(CURDIR)/../bin
28 #
29 # The top-level directory for installing fonts on the system,
30 # and the installation directories for PCF and TrueType fonts.
31 #
32 FONTDEST = $(DESTDIR)/usr/share/fonts
33 PCFDEST = $(FONTDEST)/X11/misc
34 TTFDEST = $(FONTDEST)/truetype/unifont
35 #
36 # destination directory for compiled fonts
37 #
38 COMPILED_DIR = compiled
39 #
40 # destination directory for .bmp representation of font
41 #
42 BMPDIR = $(COMPILED_DIR)/bmp
43 #
44 # Directory with original unifont-$(VERSION).hex files
45 #
46 HEXDIR = hexsrc
47 #
48 # These are the files for building GNU Unifont with the Qianqian Fang's
49 # Wen Quan Yi CJK ideographs.  This version provides complete coverage
50 # of the Unicode Basic Multilingual Plane.
51 #
52 # If you want don't want to inlcude blank glyphs in unassigned code points,
53 # uncomment the UNASSIGNED definition or override from the make command line.
54 #
55 # Likewise, uncomment the PUA definiation if you want to use Private
56 # Use Area glyphs.
57 #
58 UNASSIGNED = $(HEXDIR)/unassigned.hex
59 # UNASSIGNED =
60
61 #
62 # Non-printing glyphs.  There are only about 100 of these, and many end
63 # users do want to print representations of these glyphs, so they are
64 # included as an optional assignment.
65 #
66 # NONPRINTING = $(HEXDIR)/nonprinting.hex
67 NONPRINTING =
68
69 #
70 # Private Use Area glyphs.  Uncomment to include four-digit hexadecimal glyphs
71 # or override from the make command line.
72 #
73 # PUA = $(HEXDIR)/pua.hex
74 PUA = 
75
76 # The remaining .hex files will be constant unless a customized font
77 # is being built.
78 UNIFONTBASE = $(HEXDIR)/unifont-base.hex
79 CJK         = $(HEXDIR)/wqy.hex
80 HANGUL      = $(HEXDIR)/hangul-syllables.hex
81 SPACES      = $(HEXDIR)/spaces.hex
82
83 UNIFILES = $(UNIFONTBASE) $(CJK) $(HANGUL) $(SPACES) $(UNASSIGNED) \
84            $(NONPRINTING) $(PUA)
85
86 #
87 # Location of  TTF source directory, where TTF font is built.
88 #
89 TTFSRC = ttfsrc
90
91
92 all: pcf bmp ttf bigpic coverage
93         cp -a index.html $(COMPILED_DIR)/index.html
94
95 #
96 # Build the aggregate .hex font files
97 #
98 hex: distclean
99         if [ ! -d $(COMPILED_DIR) ] ; then \
100            mkdir -p $(COMPILED_DIR) ; \
101         fi
102         sort $(UNIFILES) >$(COMPILED_DIR)/unifont-$(VERSION).hex
103         (cd $(HEXDIR) ; sort *.hex) >$(COMPILED_DIR)/unifontall-$(VERSION).hex
104
105 #
106 # Build a BDF font file from the final .hex file.
107 #
108 bdf: hex
109         $(BINDIR)/hex2bdf <$(COMPILED_DIR)/unifont-$(VERSION).hex \
110                    >$(COMPILED_DIR)/unifont-$(VERSION).bdf
111         gzip -f -9 <$(COMPILED_DIR)/unifont-$(VERSION).bdf \
112                    >$(COMPILED_DIR)/unifont-$(VERSION).bdf.gz
113
114 #
115 # Build a PCF font file from the final .hex file.
116 #
117 pcf: bdf
118         bdftopcf <$(COMPILED_DIR)/unifont-$(VERSION).bdf \
119                         >$(COMPILED_DIR)/unifont-$(VERSION).pcf
120         gzip -f -9 $(COMPILED_DIR)/unifont-$(VERSION).pcf
121
122 #
123 # Print coverage of scripts in Basic Multilingual Plane in .txt file.
124 #
125 # Note: can't use this older version unless unassigned.hex is merged
126 # with the rest of the built unifont-$(VERSION).hex final file.
127 #
128 # coverage: $(COMPILED_DIR)/unifont-$(VERSION).hex $(BINDIR)/unicoverage
129 #       $(BINDIR)/unicoverage < $(COMPILED_DIR)/unifont-$(VERSION).hex \
130 #                   > $(COMPILED_DIR)/coverage.txt
131 #
132 # Use this version because "unassigned.hex" isn't part of the final
133 # .hex font by default now:
134 #
135 coverage:
136         sort $(HEXDIR)/*.hex | \
137                 $(BINDIR)/unicoverage > $(COMPILED_DIR)/coverage.txt
138
139 #
140 # Print HTML page coverage in Basic Multilingual Plane in .txt file.
141 #
142 pagecount: $(COMPILED_DIR)/unifont-$(VERSION).hex $(BINDIR)/unipagecount
143         $(BINDIR)/unipagecount -l < $(COMPILED_DIR)/unifont-$(VERSION).hex \
144                         > $(COMPILED_DIR)/pagecount.html
145
146 #
147 # Create the .bmp (Windows Bitmap) graphics versions of the glyphs.
148 #
149 bmp: hex $(BINDIR)/unihex2bmp
150         if [ ! -d $(BMPDIR) ] ; then \
151            mkdir -p $(BMPDIR) ; \
152         fi
153         for i in 0 1 2 3 4 5 6 7 8 9 A B C D E F; do \
154            for j in 0 1 2 3 4 5 6 7 8 9 A B C D E F; do \
155               $(BINDIR)/unihex2bmp -p$$i$$j \
156                  -i$(COMPILED_DIR)/unifontall-$(VERSION).hex \
157                  -o$(BMPDIR)/uni$$i$$j.bmp ; \
158            done ; \
159         done ; \
160         echo "Done creating $(BMPDIR)"
161
162 #
163 # Build one bitmap of the entire Unifont as a 4096 x 16 grid.
164 #
165 bigpic: $(COMPILED_DIR)/unifontall-$(VERSION).hex
166         $(BINDIR)/unigencircles ttfsrc/combining.txt hexsrc/nonprinting.hex \
167            < $(COMPILED_DIR)/unifontall-$(VERSION).hex | \
168         $(BINDIR)/unifontpic -d120 > $(COMPILED_DIR)/unifont-$(VERSION).bmp
169
170 #
171 # Note that $(TTFSRC) must exist, because it contains some source files
172 # Perform a "make && make clean" because ALL of the files would consume
173 # over 200 Megabytes if left around.  The .sfd file is about 100 Megabytes,
174 # and it is created from merging "[0-F].sfd", which take up another 100 MB.
175 #
176
177 ttf:
178         cp $(COMPILED_DIR)/unifont-$(VERSION).hex $(TTFSRC)/unifont.hex
179         cd $(TTFSRC) ; make && make clean
180         mv $(TTFSRC)/unifont.sfd $(COMPILED_DIR)/unifont.sfd 
181         mv $(TTFSRC)/unifont.ttf $(COMPILED_DIR)/unifont-$(VERSION).ttf 
182         gzip -f -9 $(COMPILED_DIR)/unifont.sfd 
183
184 #
185 # Copy the newly created files from $(COMPILED_DIR) to the precompiled/
186 # directory.  This has to be called manually, because the precompiled/
187 # directory usually remains untouched.
188 #
189 precompiled:
190         install -m0644 -p $(COMPILED_DIR)/unifont-$(VERSION).hex \
191                           $(COMPILED_DIR)/unifontall-$(VERSION).hex \
192                           $(COMPILED_DIR)/unifont-$(VERSION).bdf.gz \
193                           $(COMPILED_DIR)/unifont-$(VERSION).pcf.gz \
194                           $(COMPILED_DIR)/unifont-$(VERSION).ttf \
195                           $(COMPILED_DIR)/coverage.txt \
196                           $(COMPILED_DIR)/unifont-$(VERSION).bmp \
197            precompiled
198
199 #
200 # This is set up for Debian.  Solaris places fonts in
201 # "/usr/share/fonts/TrueType".  Other unices use other directories.
202 # The original font format was BDF, but Debian doesn't use that and
203 # xfs should only need TrueType, so the BDF font isn't installed.
204 #
205 # The TrueType font is about 16 Megabytes.  To avoid duplication,
206 # the fonts are installed as symbolic links back to the original package.
207 # Alternatively, the fonts can be copied to the destination directory
208 # with "install -m0644" or moved there (but "mv" is a destructive
209 # one-time operation).
210 #
211 # After installing the new fonts, register them with X Window System using:
212 #
213 #      xset fp rehash
214 #
215 install:
216         if [ x$(CURDIR) = x ] ; \
217         then \
218            echo "Fatal Error: CURDIR not defined -- define in Makefile." ; \
219            exit 1 ; \
220         fi
221         install -m0755 -d $(PCFDEST)
222         install -m0755 -d $(TTFDEST)
223         if [ ! -d $(COMPILED_DIR) ] ; then \
224            install -m0644 -p $(CURDIR)/precompiled/unifont-$(VERSION).pcf.gz $(PCFDEST)/unifont.pcf.gz ; \
225            install -m0644 -p $(CURDIR)/precompiled/unifont-$(VERSION).ttf    $(TTFDEST)/unifont.ttf ; \
226         else \
227            install -m0644 -p $(CURDIR)/$(COMPILED_DIR)/unifont-$(VERSION).pcf.gz $(PCFDEST)/unifont.pcf.gz ; \
228            install -m0644 -p $(CURDIR)/$(COMPILED_DIR)/unifont-$(VERSION).ttf    $(TTFDEST)/unifont.ttf ; \
229         fi
230
231 clean:
232         \rm -rf $(COMPILED_DIR)/bmp
233         \rm -f $(COMPILED_DIR)/unifont-$(VERSION).hex
234         \rm -f $(COMPILED_DIR)/unifont-$(VERSION).bdf
235         \rm -f $(COMPILED_DIR)/unifont-$(VERSION).bdf.gz
236
237 #
238 # Note that distclean leaves precompiled/ alone.  This is intentional.
239 # The .DS files are created under Mac OS X.
240 #
241 distclean:
242         \rm -rf $(COMPILED_DIR)
243         $(MAKE) -C ttfsrc distclean
244         \rm -rf .DS* ._.DS*
245
246 .PHONY: all hex bdf pcf coverage pagecount bmp bigpic ttf precompiled install clean distclean