# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

ROOT    = ..
SHELL   = /bin/sh

#
# Standard conversion of pnms into pngs.
#
.SUFFIXES:
.SUFFIXES:	.pnm .png
.pnm.png:
	pnmtopng < $< > $@

#
# Main gif, intermediate label pnm images, and their zip file.
#
GIF	= labels.gif
PNM	= labels.pnm
PNMS	= \
	a.pnm b.pnm c.pnm d.pnm e.pnm f.pnm g.pnm h.pnm		\
	1.pnm 2.pnm 3.pnm 4.pnm 5.pnm 6.pnm 7.pnm 8.pnm		\
	dash.pnm eq.pnm hash.pnm plus.pnm x.pnm
GIF2	= labels2.gif
PNM2	= labels2.pnm
PNMS2	= \
	k.pnm q.pnm r.pnm b.pnm n.pnm 0.pnm
GIFZIP	= labels.zip

#
# Labels.
#
LABELS	= \
	a.png b.png c.png d.png e.png f.png g.png h.png		\
	1.png 2.png 3.png 4.png 5.png 6.png 7.png 8.png		\
	dash.png eq.png hash.png plus.png x.png
LABELS2	= \
	lk.png lq.png lr.png lb.png ln.png l0.png
ERR	= \
	err.png

#
# Demonstration string, to test proportional font look.
#
DEMO	= string.png

#
# Default make target.
#
default:	all

#
# Unpack gifs.
#
$(GIF) $(GIF2):	$(GIFZIP)
	unzip -qquL $(GIFZIP) $@
$(PNM):	$(GIF)
	giftopnm < $< > $@
$(PNM2):$(GIF2)
	giftopnm < $< > $@

#
# Crop and pad macro -- crops left and right, replaces one pixel of white,
# and converts to png.
#
CNP	= pnmcrop -left -right | pnmpad -white -l1 -r1 | pnmtopng

#
# Pick apart the labels gif into single character pieces.
#
1.png:	$(PNM)
	pnmcut -left   0 -right  22 < $< | $(CNP) >$@
2.png:	$(PNM)
	pnmcut -left  23 -right  41 < $< | $(CNP) >$@
3.png:	$(PNM)
	pnmcut -left  42 -right  57 < $< | $(CNP) >$@
4.png:	$(PNM)
	pnmcut -left  58 -right  75 < $< | $(CNP) >$@
5.png:	$(PNM)
	pnmcut -left  76 -right  92 < $< | $(CNP) >$@
6.png:	$(PNM)
	pnmcut -left  93 -right 110 < $< | $(CNP) >$@
7.png:	$(PNM)
	pnmcut -left 111 -right 127 < $< | $(CNP) >$@
8.png:	$(PNM)
	pnmcut -left 128 -right 144 < $< | $(CNP) >$@
a.png:	$(PNM)
	pnmcut -left 145 -right 160 < $< | $(CNP) >$@
b.png:	$(PNM)
	pnmcut -left 161 -right 178 < $< | $(CNP) >$@
c.png:	$(PNM)
	pnmcut -left 179 -right 194 < $< | $(CNP) >$@
d.png:	$(PNM)
	pnmcut -left 195 -right 212 < $< | $(CNP) >$@
e.png:	$(PNM)
	pnmcut -left 213 -right 228 < $< | $(CNP) >$@
f.png:	$(PNM)
	pnmcut -left 229 -right 240 < $< | $(CNP) >$@
g.png:	$(PNM)
	pnmcut -left 241 -right 258 < $< | $(CNP) >$@
h.png:	$(PNM)
	pnmcut -left 259 -right 277 < $< | $(CNP) >$@
#o.png:	$(PNM)
#	pnmcut -left 278 -right 297 < $< | $(CNP) >$@
x.png:	$(PNM)
	pnmcut -left 298 -right 317 < $< | $(CNP) >$@
plus.png:	$(PNM)
	pnmcut -left 318 -right 335 < $< | $(CNP) >$@
dash.png:	$(PNM)
	pnmcut -left 336 -right 350 < $< | $(CNP) >$@
eq.png:		$(PNM)
	pnmcut -left 351 -right 369 < $< | $(CNP) >$@
hash.png:	$(PNM)
	pnmcut -left 370 -right 399 < $< | $(CNP) >$@
lk.png:	$(PNM2)
	pnmcut -left 0   -right  27 < $< | $(CNP) >$@
lq.png:	$(PNM2)
	pnmcut -left  28 -right  52 < $< | $(CNP) >$@
lr.png:	$(PNM2)
	pnmcut -left  53 -right  72 < $< | $(CNP) >$@
lb.png:	$(PNM2)
	pnmcut -left  73 -right  93 < $< | $(CNP) >$@
ln.png:	$(PNM2)
	pnmcut -left  93 -right 115 < $< | $(CNP) >$@
l0.png:	$(PNM2)
	pnmcut -left 116 -right 139 < $< | $(CNP) >$@

#
# Build an "error" label by making an existing one all black.
#
$(ERR):	l0.png
	pngtopnm < $< | ppmchange -remainder '#000000' | pnmtopng >$@

#
# Build all labels.
#
$(LABELS) $(LABELS2):	Makefile $(GIFZIP) $(GIFZIP2)

#
# Build a demonstration string.
#
$(DEMO): $(LABELS) $(LABELS2)
	for i in a b c d e f g h 1 2 3 4 5 6 7 8 eq dash x plus hash	\
		lk lq lr lb ln l0; do					\
		pngtopnm $${i}.png >$${i}.pnm;				\
	done
	pnmcat -lr a.pnm b.pnm c.pnm d.pnm e.pnm f.pnm g.pnm h.pnm	\
		   1.pnm 2.pnm 3.pnm 4.pnm 5.pnm 6.pnm 7.pnm 8.pnm	\
		   eq.pnm dash.pnm x.pnm plus.pnm hash.pnm		\
		   lk.pnm lq.pnm lr.pnm lb.pnm ln.pnm l0.pnm		\
			| pnmtopng >$@

#
# Targets.
#
all:	$(LABELS) $(LABELS2) $(ERR) $(DEMO)

clean:
	rm -f *.gif *.png *.pnm
