OBJ1 = chinese.o vga.o drawtext.o output.o input.o error.o \
       ptyopen.o  scroll.o HBF_api.o loadfont.o main.o portable.o
OBJ2 = cnprint220.o
FONT = /usr/local/chinese/kcchin16.f00 /usr/local/chinese/kctext16.f00
SFLAGS = #-DVGA_16BIT
CFLAGS = #-DDEBUG_LOG_INPUT


.c.o:
	gcc -c -g ${CFLAGS} -DUSE_BY_CHDAM -O2 $*.c

.S.o:
	gcc -c ${SFLAGS} -o $*.o $*.S

.s.o:
	gcc -c -o $*.o $*.s

all :${OBJ1} mkmulti chdam libchinese.a ttyserver \
	libchinesedriver.a ccc dayi.tbl testspeed \
	displayfont cnprint

displayfont : displayfont.c
	gcc -o displayfont displayfont.c vga.o drawtext.o scroll.o

cnprint : cnprint220.o chexist.o
	gcc -O2 -o cnprint cnprint220.o chexist.o

testspeed : testspeed.c
	gcc -o testspeed testspeed.c

ccc : ccc.c
	gcc -o ccc ccc.c

ttyserver : ttyserver.c ptyopen.o version.o
	gcc -g -o ttyserver ttyserver.c ptyopen.o version.o

clean :
	rm -f *.o *.a

mkmulti : mkmulti.c
	gcc -g -o mkmulti mkmulti.c

libchinesedriver.a : ${OBJ1} 
	rm -f libchinesedriver.a
	ar r libchinesedriver.a ${OBJ1} 
	ranlib libchinesedriver.a

libchinese.a : ${OBJ3}
	rm -f libchinese.a
	ar r libchinese.a ${OBJ3}
	ranlib libchinese.a

chdam : ${OBJ1} 
	gcc -dynamic -o chdam ${OBJ1} -L./


install: all
	install -m 644 libchinese.a /usr/lib
	install -m 644 libchinesedriver.a /usr/lib
	install -m 644 hanfont /usr/local/chinese
	install -m 644 chinese.h /usr/include
	install -m 644 vga.h /usr/include
	install -m 644 dayi.tbl /usr/local/chinese
	install -o root -m 700 ttyserver /usr/bin
	install -o root -m 700 chdam /usr/bin
	install -m 755 ccc /usr/bin
	install -m 644 multitab /etc
	install -m 644 phone.def /usr/local/chinese
	install -m 644 kcfont /usr/local/chinese
	install -m 644 termcap /etc/termcapG
	install -m 644 hbffont /usr/local/chinese
	install -m 755 sethbffont /etc
	install -m 755 cnprint /usr/bin
	install -m 755 cnprint.cmd /usr/local/chinese
	rm -f /dev/cin
	mknod /dev/cin p
	chmod 666 /dev/cin
	chmod +x setfont24
	setfont24
	echo "If the font you set right now doesn't correct,you can"
	echo "reinstall by type setfont24 in command line"

	
uninstall :
	rm -f /usr/lib/libchinese.a
	rm -f /usr/lib/libchinesedriver.a
	rm -f /usr/local/chinese/hanfont
	rm -f /usr/include/chinese.h
	rm -f /usr/inlcude/vga.h
	rm -f /usr/local/chinese/dayi.tbl
	rm -f /usr/bin/ttyserver
	rm -f /usr/bin/chdam
	rm -f /usr/bin/ccc
	rm -f /etc/multitab
	rm -f /etc/termcapG
	rm -f /usr/local/chinese/kcfont
	rm -f /usr/local/chinese/phone.def
	rm -f /usr/local/chinese/hbffont
	rm -f /etc/sethbffont

pack :
	tar cvf chdrv05.tar chinese.c vga.c chinese.h vga.h drawtext.S \
	        termcap Makefile \
		hanfont README input.c output.c dayi.def main.c ttyserver.c \
		ptyopen.c mkmulti.c vgadef.h chmsg.h error.c ccc.c scroll.S \
		TODO INSTALL fullsize.h PROBLEM testspeed.c color.h phone.def \
		phone.h version.c multitab kcfont displayfont.c \
		README.0.3pl2 hbffont sethbffont loadfont.c HBF-SUPPORT \
		MANUAL.DOC HBF_api.c HBF_api.h cnprint220.c cnprint.cmd \
		NEWS chdrv.FAQ portable.c portable.h PORTABLE.DOC tit2def.perl \
		tit2phone.perl	
	gzip chdrv05.tar

dayi.tbl : dayi.def mkmulti
	mkmulti dayi.def dayi.tbl




