e625de0b07b6fa7595e9dabc29452c1122ae1222
[unifont.git] / Makefile
1 #
2 # unifoundry.com utilities for the GNU Unifont
3 #
4 # Typing "make && make install" will make and
5 # install the binary programs and man pages.
6 # To build only the font from scratch, use
7 # "cd font ; make"
8 #
9 SHELL = /bin/sh
10 INSTALL = install
11
12 DATE = 20131215
13 MAJORVERSION = 6.3
14 VERSION = $(MAJORVERSION).$(DATE)
15
16 #
17 # The settings below will install software, man pages, and documentation
18 # in /usr/local.  To install in a different location, modify USRDIR to
19 # your liking.
20 #
21 USRDIR = usr
22 # USRDIR = usr/local
23 PREFIX = $(DESTDIR)/$(USRDIR)
24 PKGDEST = $(PREFIX)/share/unifont
25
26 VPATH = lib font/hexsrc font/ttfsrc
27
28 HEXFILES = hangul-syllables.hex nonprinting.hex pua.hex spaces.hex \
29            unassigned.hex unifont-base.hex wqy.hex
30
31 COMBINING = font/ttfsrc/combining.txt
32
33 TEXTFILES = ChangeLog INSTALL NEWS README
34
35 #
36 # Whether to build the font or not (default is not).
37 # Set to non-null value to build font.
38 #
39 BUILDFONT=
40
41 #
42 # Whether to install man pages uncompressed (COMPRESS = 0) or
43 # compressed (COMPRESS != 0).
44 #
45 COMPRESS = 1
46
47 all: bindir libdir docdir buildfont
48         echo "Make is done."
49
50 bindir:
51         set -e ; $(MAKE) -C src
52
53 #
54 # Conditionally build the font, depending on the value of BUILDFONT.
55 # To build the font unconditionally, use the "fontdir" target below.
56 #
57 buildfont:
58         if [ x$(BUILDFONT) != x ] ; \
59         then \
60            set -e ; make -C font ; \
61         fi
62
63 #
64 # Not invoked automatically; the font files are taken from
65 # font/precompiled by default.
66 #
67 fontdir:
68         set -e ; $(MAKE) -C font
69
70 libdir: lib/wchardata.c
71
72 docdir:
73         set -e ; $(MAKE) -C doc
74
75 mandir:
76         set -e ; $(MAKE) -C man
77
78 precompiled:
79         set -e ; $(MAKE) precompiled -C font
80
81 #
82 # Create lib/wchardata.c.  If you want to also build the object file
83 # wchardata.o, uncomment the last line
84 #
85 lib/wchardata.c: $(HEXFILES) combining.txt
86         $(INSTALL) -m0755 -d lib
87         (cd font/hexsrc && sort $(HEXFILES) > ../../unifonttemp.hex)
88         bin/unigenwidth unifonttemp.hex $(COMBINING) > lib/wchardata.c
89         \rm -f unifonttemp.hex
90 #       (cd lib && $(CC) $(CFLAGS) -c wchardata.c && chmod 644 wchardata.o )
91
92 install: bindir libdir docdir
93         $(MAKE) -C src install PREFIX=$(PREFIX)
94         $(MAKE) -C man install PREFIX=$(PREFIX) COMPRESS=$(COMPRESS)
95         $(MAKE) -C font install PREFIX=$(PREFIX) DESTDIR=$(DESTDIR)
96         $(INSTALL) -m0755 -d $(PKGDEST)
97         $(INSTALL) -m0644 -p $(TEXTFILES) doc/unifont.txt doc/unifont.info $(PKGDEST)
98         for i in $(TEXTFILES) unifont.txt unifont.info ; do \
99            gzip -f -9 $(PKGDEST)/$$i ; \
100         done
101         $(INSTALL) -m0644 -p lib/wchardata.c $(PKGDEST)
102         $(INSTALL) -m0644 -p font/ttfsrc/combining.txt $(PKGDEST)
103         # If "make" wasn't run before, font/compiled won't exist.
104         if [ ! -d font/compiled ] ; then \
105            $(INSTALL) -m0644 -p font/precompiled/unifont-$(VERSION).hex   $(PKGDEST)/unifont.hex ; \
106            $(INSTALL) -m0644 -p font/precompiled/unifont-$(VERSION).bmp $(PKGDEST)/unifont.bmp ; \
107         else \
108            $(INSTALL) -m0644 -p font/compiled/unifont-$(VERSION).hex   $(PKGDEST)/unifont.hex ; \
109            $(INSTALL) -m0644 -p font/compiled/unifont-$(VERSION).bmp $(PKGDEST)/unifont.bmp ; \
110         fi
111
112 clean:
113         $(MAKE) -C src  clean
114         $(MAKE) -C doc  clean
115         $(MAKE) -C man  clean
116         $(MAKE) -C font clean
117         \rm -rf *~
118
119 #
120 # The .DS files are created under Mac OS X
121 #
122 distclean:
123         $(MAKE) -C src  distclean
124         $(MAKE) -C doc  distclean
125         $(MAKE) -C man  distclean
126         $(MAKE) -C font distclean
127         \rm -rf bin lib
128         \rm -f unifonttemp.hex
129         \rm -rf *~
130         \rm -rf .DS* ._.DS*
131
132 .PHONY: all bindir docdir mandir fontdir precompiled install clean distclean