#    Copyright (C) 2000,2001,2002 Anton Kirilov Zinoviev

#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.

#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    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

#    My e-mail is zinoviev@debian.org


SHELL = /bin/sh -e

FontsDir = fonts

all:
	echo "Make what?"
	exit 1

unpack:
	-rm -rf fonts
	mkdir fonts
	tar jxf oldslavic.tar.bz2 -C fonts
	touch unpack

afm: unpack
	set -e && \
	for i in $(FontsDir)/*.afm; do \
		sed	-e 's/\(^ *FontName  *NimbusRom\)No9/\1/' \
			-e 's/\(^ *FontName  *[^ -]*\)L-/\1CYR-/' \
		$$i | ../trafm >../afm/`basename $$i`; \
	done
	touch afm

raw1: unpack
	mkdir tmp
	set -e && \
	for i in $(FontsDir)/*.pfb; do \
		t1disasm $$i >tmp/`basename $$i .pfb`.raw1; \
	done
	touch raw1

raw2: raw1
	set -e && \
	for i in tmp/*.raw1; do \
		sed 	-e 's/^\(%!PS-AdobeFont[^ ]* *[^- ]*\)L-/\1CYR-/' \
			-e 's/^\( *\/FontName[^ ]* *[^- ]*\)L-/\1CYR-/' \
			-e 's/\(NimbusRom\)No9/\1/' \
		$$i >tmp/`basename $$i .raw1`.raw2; \
	done
	touch raw2

raw3: raw2 afm
	set -e && \
	for i in tmp/*.raw2; do \
		../trtype1 ../afm/`basename $$i .raw2`.afm \
			$$i >tmp/`basename $$i .raw2`.raw3; \
	done
	touch raw3

pfa: raw3
	set -e && \
	for i in tmp/*.raw3; do \
		t1asm -a $$i >../pfa/`basename $$i .raw3`.pfa; \
	done
	touch pfa

pfb: raw3
	set -e && \
	for i in tmp/*.raw3; do \
		t1asm $$i >../pfb/`basename $$i .raw3`.pfb; \
	done
	touch pfb

doc:
	cp fonts/README ../doc/README.OldSlavic
	touch doc

clean:
	-rm -f unpack afm raw1 raw2 raw3 pfa pfb doc
	-rm *~
	-rm -rf fonts tmp

.PHONY:	clean
