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

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

EXTRA_DEFINES = @EXTRA_DEFINES@
EXTRA_LIBS    = @EXTRA_LIBS@
FONTS = @MAKEALL@
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 | compress > ../$@.Z; fi
taipei24k.pcf:
	if [ ! -f ../$@ ]; then cat taipei24k.bdf | bdftopcf | compress > ../$@.Z; fi
et15.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et15 | bdftopcf | compress > ../$@.Z; fi
et24k.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et24k | bdftopcf | compress > ../$@.Z; fi
et24m.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et24m | bdftopcf | compress > ../$@.Z; fi
et24l.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et24l | bdftopcf | compress > ../$@.Z; fi
et24s.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et24s | bdftopcf | compress > ../$@.Z; fi
et24r.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et24r | bdftopcf | compress > ../$@.Z; fi
et24b.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) et24b | bdftopcf | compress > ../$@.Z; fi
vga8x15.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) vga8x15 | bdftopcf | compress > ../$@.Z; fi
vga12x24.pcf: $(PROGS)
	if [ ! -f ../$@ ]; then ./$(PROGS) $(PATH_XCIN_ETEN) vga12x24 | bdftopcf | compress > ../$@.Z; fi

install: all @INSTALLALL@

install.fonts:
	for f in `ls ../*.pcf`; do cat $$f | compress > $$f.Z; rm $$f; done
	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
