include ../../Makefile.conf

TARGETS=iso-8859-1.my \
	iso-8859-2.my \
	iso-8859-3.my \
	iso-8859-4.my \
	iso-8859-5.my \
	iso-8859-6.my \
	iso-8859-7.my \
	iso-8859-8.my \
	iso-8859-9.my \
	iso-8859-13.my \
	iso-8859-15.my \
	iso-8859-16.my \
	viscii.my \
	tcvn.my \
	wingreek.my \
	cp-1252.my \
	cp-1251.my \
	cp-1250.my 

#
# shift-jis.my is not used in converters - it is only here for fonts.
#
EASTASIAN= jis-0201.my \
	jis-0208.my \
	shift-jis.my \
	jis-0212.my \
	big-5.my \
	gb-2312-l.my \
	gb-2312-r.my \
	ksc-5601-r.my \
	ksc-5601-l.my \
	ksx-1001.my\

#
# We have the source code in this distribution for these maps
#
MTARGETS=koi8-r.my koi8-c.my koi8-u.my tcvn.my viscii.my windows-1255.my \
    wingreek.my iso-646.my iso-8859e.my indic.my mik.my \
    rovas.my mirroring.my cp-1252.my

EASTASIAMAP=../../bin/MAPPINGS

#
# Make a bumap file...
# If you want my write '-convert my' here.
#
#MYTOPT=-type fontmap -nocomment -comment "" -convert bumap
MYTOPT=-type fontmap -nocomment  -convert bumap

ALL_TARGETS=$(MTARGETS) $(TARGETS)
ALL_NAMES=$(basename $(ALL_TARGETS))
#MYTOPT=

#MAPDIR=../../../MAPPINGS
#MAPDIR=/software/unicode/codetables
MAPDIR=.
#MAPDIR=../../..

#-------------------------------------------------------------------------------

.SUFFIXES: .umap .TXT

all: $(MTARGETS) MYTOOL

my: $(TARGETS)

eastasian: $(EASTASIAN)

TL=".----------------------------------------------------------------"

MYTOOL: 
	@echo $(TL)
	@echo "Most my-maps are in the distribution. If you have the MAPS from "
	@echo "The unicode Consortium  in ../../MAPPINS, you can re-make your "
	@echo "own by typing 'make eastasian' or 'make my'"
	@echo $(TL)

#
# BINARY UMAPS in 'my' format
#
koi8-r.my: koi8-r.txt
	$(MYTOOL) $(MYTOPT) -name koi8-r -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

koi8-c.my: koi8-c.txt
	$(MYTOOL) $(MYTOPT) -name koi8-c -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

koi8-u.my: koi8-u.txt
	$(MYTOOL) $(MYTOPT) -name koi8-u -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

viscii.my: viscii.txt
	$(MYTOOL) $(MYTOPT) -name viscii -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

#
# 8 bit long
#
rovas.my: ROVASIRAS.TXT
	$(MYTOOL) $(MYTOPT) -name rovas -uni:0,1 $< -runi:0,1 $< -8 -write $@ 

mirroring.my: mirroring.txt
	$(MYTOOL) $(MYTOPT) -name mirroring -uni:0,1 $< -runi:0,1 $< -write $@ 

tcvn.my: tcvn.txt
	$(MYTOOL) $(MYTOPT) -name tcvn -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

wingreek.my: wingreek.txt
	$(MYTOOL) $(MYTOPT) -name wingreek -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

windows-1255.my: windows-1255.txt
	$(MYTOOL) $(MYTOPT) -name windows-1255 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 


iso-646.my: ISO002.TXT
	$(MYTOOL) $(MYTOPT) -name iso-646 -uni:0,1 $< -runi:0,1 $< -8 -write $@ 

mik.my: MIK.TXT
	$(MYTOOL) $(MYTOPT) -name mik -uni:0,1 $< -runi:0,1 $< -8 -write $@ 

iso-8859e.my: 8859-9e.TXT
	$(MYTOOL) $(MYTOPT) -name iso-8859e -uni:0,1 $< -runi:0,1 $< -8 -write $@ 

indic.my: indic.txt
	$(MYTOOL) $(MYTOPT) -name indic -uni:0,1 $< -runi:0,1 $< -8 -write $@ 

iso-8859-1.my: $(MAPDIR)/8859-1.TXT
	$(MYTOOL) $(MYTOPT) -name iso-8859-1 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

iso-8859-2.my: $(MAPDIR)/8859-2.TXT
	$(MYTOOL) $(MYTOPT) -name iso-8859-2 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

iso-8859-3.my: $(MAPDIR)/8859-3.TXT
	$(MYTOOL) $(MYTOPT) -name iso-8859-3 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

iso-8859-4.my: $(MAPDIR)/8859-4.TXT
	$(MYTOOL) $(MYTOPT) -name iso-8859-4 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

iso-8859-5.my: $(MAPDIR)/8859-5.TXT
	$(MYTOOL) $(MYTOPT) -name iso-8859-5 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

iso-8859-6.my: $(MAPDIR)/8859-6.TXT
	$(MYTOOL) $(MYTOPT) -name iso-8859-6 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

iso-8859-7.my: $(MAPDIR)/8859-7.TXT
	$(MYTOOL) $(MYTOPT) -name iso-8859-7 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

iso-8859-8.my: $(MAPDIR)/8859-8.TXT
	$(MYTOOL) $(MYTOPT) -name iso-8859-8 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

iso-8859-9.my: $(MAPDIR)/8859-9.TXT
	$(MYTOOL) $(MYTOPT) -name iso-8859-9 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 

iso-8859-13.my: $(MAPDIR)/8859-13.TXT
	$(MYTOOL) $(MYTOPT) -name iso-8859-13 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 
iso-8859-15.my: $(MAPDIR)/8859-15.TXT
	$(MYTOOL) $(MYTOPT) -name iso-8859-15 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 
iso-8859-16.my: $(MAPDIR)/8859-16.TXT
	$(MYTOOL) $(MYTOPT) -name iso-8859-16 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 
cp-1252.my: cp-1252.txt
	$(MYTOOL) $(MYTOPT) -name cp-1252 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 
cp-1251.my: $(MAPDIR)/CP1251.TXT
	$(MYTOOL) $(MYTOPT) -name cp-1251 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 
cp-1250.my: $(MAPDIR)/CP1250.TXT
	$(MYTOOL) $(MYTOPT) -name cp-1250 -uni:0,1 $< -runi:0,1 $< -8  -write $@ 
jis-0201.my: $(EASTASIAMAP)/JIS0201.TXT
	$(MYTOOL) $(MYTOPT) -name jis-0201 -uni:0,1 $< -runi:0,1 $<  -write $@ 

jis-0208.my: $(EASTASIAMAP)/JIS0208.TXT
	$(MYTOOL) $(MYTOPT) -name jis-0208 -uni:1,2 $< -runi:1,2 $<  -write $@ 

shift-jis.my: $(EASTASIAMAP)/JIS0208.TXT
	$(MYTOOL) $(MYTOPT) -name shift-jis -uni:0,2 $< -runi:0,2 $<  -write $@ 
	
jis-0212.my: $(EASTASIAMAP)/JIS0212.TXT
	$(MYTOOL) $(MYTOPT) -name jis-0212 -uni:0,1 $< -runi:0,1 $<  -write $@ 

ksc-5601-r.my: $(EASTASIAMAP)/KSC5601.TXT
	$(MYTOOL) $(MYTOPT) -name ksc-5601-r -uni:0,1 $< -runi:0,1 $<  -write $@ 

ksc-5601-l.my: $(EASTASIAMAP)/KSC5601.TXT
	$(MYTOOL) $(MYTOPT) -name ksc-5601-l -low -uni:0,1 $< -runi:0,1 $<  -write $@ 
ksx-1001.my: $(EASTASIAMAP)/KSX1001.TXT
	$(MYTOOL) $(MYTOPT) -name ksx-1001 -uni:0,1 $< -runi:0,1 $<  -write $@ 

big-5.my: BIG5.TXT
	$(MYTOOL) $(MYTOPT) -name big-5 -uni:0,1 $< -runi:0,1 $<  -write $@ 

gb-2312-l.my: $(EASTASIAMAP)/GB2312.TXT
	$(MYTOOL) $(MYTOPT) -name gb-2312-l -uni:0,1 $< -runi:0,1 $<  -write $@ 

gb-2312-r.my: $(EASTASIAMAP)/GB2312.TXT
	$(MYTOOL) $(MYTOPT) -name gb-2312-r -high -uni:0,1 $< -runi:0,1 $<  -write $@ 

install:
	@if test ! -d $(prefix) ; then mkdir -p $(DESTDIR)/$(prefix); fi
	@if test ! -d $(datadir) ; then mkdir -p $(DESTDIR)/$(datadir);fi 
	@if test ! -d $(datadir)/yudit ; then mkdir -p $(DESTDIR)/$(datadir)/yudit;fi 
	@if test ! -d $(datadir)/yudit/data ;then mkdir -p $(DESTDIR)/$(datadir)/yudit/data;fi 
	@echo installing my files...
	@$(INSTALL_DATA) *.my $(DESTDIR)/$(datadir)/yudit/data

depend:

badcheck:
	@for map in $(ALL_NAMES); do \
		echo -n Checking $$i ..; \
		diff $$map.my ../../data/$$i.bumap; \
		echo ..Done; \
	done

clean:
	rm -f $(MTARGETS) core

veryclean:
	rm -f $(MTARGETS) *.my core

