#
#  Modified from xcin-2.1b/big5font/Makefile
#                 by Tung-Han Hsieh
#

include ../../config.status
include ../../install.status

EXTRA_DEFINES = 
EXTRA_LIBS    = 
FONTS = et2bdf 
PROGS = et2bdf

all:	$(FONTS)

$(PROGS): et2bdf.c
	$(CC) $(CFLAGS) -o $@ et2bdf.c

taipei.pcf: taipei15.pcf taipei24k.pcf

taipei15.pcf:
	if [ ! -f ../$@ ]; then cat taipei15.bdf | bdftopcf -o ../$@; fi
taipei24k.pcf:
	if [ ! -f ../$@ ]; then cat taipei24k.bdf | bdftopcf -o ../$@; fi
et15.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et15 | bdftopcf -o ../$@; fi
et24k.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et24k | bdftopcf -o ../$@; fi
et24m.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et24m | bdftopcf -o ../$@; fi
et24l.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et24l | bdftopcf -o ../$@; fi
et24s.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et24s | bdftopcf -o ../$@; fi
et24r.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et24r | bdftopcf -o ../$@; fi
et24b.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et24b | bdftopcf -o ../$@; fi
vga8x15.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) vga8x15 | bdftopcf -o ../$@; fi
vga12x24.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) vga12x24 | bdftopcf -o ../$@; fi

install: all  install.et2bdf

install.fonts:
	ff=`ls ../* | grep pcf`
	if [ ! -z "$ff" ]; then \
	    for f in $$ff; do cat $$f | compress > $$f.Z; rm $$f; done \
	fi
	if [ -f ../vga8x15.pcf.Z ] || [ -f ../vga12x24.pcf.Z ]; then\
	    if [ ! -d $(PATH_XCIN_EFONT) ]; then $(INSTALL_DIR) $(PATH_XCIN_EFONT); fi;\
	    for f in `ls ../vga*.pcf.Z`; do\
	        $(INSTALL_DATA) $$f $(PATH_XCIN_EFONT);\
		echo $(PATH_XCIN_EFONT)/`basename $$f` >> ../filelist;\
	    done;\
	    mkfontdir $(PATH_XCIN_EFONT);\
	fi
	if [ ! -d $(PATH_XCIN_CFONT) ]; then $(INSTALL_DIR) $(PATH_XCIN_CFONT); fi
	for f in `ls ../*.pcf.Z`; do\
	    $(INSTALL_DATA) $$f $(PATH_XCIN_CFONT);\
	    echo $(PATH_XCIN_CFONT)/`basename $$f` >> ../filelist;\
	done
	mkfontdir $(PATH_XCIN_CFONT)
	cat $(PATH_XCIN_CFONT)/fonts.dir | awk 'NR>1 {print}' | sed 's/\.pcf\.Z//' > ../fonts.alias

install.et2bdf:
	if [ ! -d $(PATH_XCIN_DIR) ]; then $(INSTALL_DIR) $(PATH_XCIN_DIR); fi
	$(INSTALL) $(PROGS) $(PATH_XCIN_DIR)
	echo $(PATH_XCIN_DIR)/$(PROGS) >> ../filelist

clean:
	rm -f *.o *~ *.bak $(PROGS) filelist

veryclean: clean
	rm -f Makefile ../et*.pcf* ../fonts.alias
