# Generated automatically from Makefile.in by configure.
prefix	= /usr
prgdir	= /lib/Chinput
imdir	= /lib/Chinput/im
CFLAGS	= -g -O2
# FIX
CFLAGS	= -g -Wall -I../../../include -I.
PROG	= TL_hzinput.so
TL_OBJS	= xl_hzinput.o TL_hzinput.o  xl_phrase.o xl_sysphrase.o xl_mfile.o

all: dlib
dlib: $(PROG)

xl_mfile.o : xl_mfile.c xl_mfile.h
	gcc $(CFLAGS) -c xl_mfile.c -o xl_mfile.o
TL_hzinput.o : TL_hzinput.c
	gcc $(CFLAGS) -DUNICON_LIB=\"$(prefix)$(imdir)\" -c TL_hzinput.c -o TL_hzinput.o
xl_hzinput.o : xl_hzinput.c
	gcc $(CFLAGS) -c xl_hzinput.c -o xl_hzinput.o
xl_phrase.o : xl_phrase.c
	gcc $(CFLAGS) -c xl_phrase.c -o xl_phrase.o
xl_sysphrase.o : xl_sysphrase.c
	gcc $(CFLAGS) -c xl_sysphrase.c -o xl_sysphrase.o
$(PROG): $(TL_OBJS)
	gcc $(TL_OBJS) -shared -o $(PROG)

# .tab build tools
cin2tab : cin2tab.c $(TL_OBJS)
	gcc -c $(CFLAGS) cin2tab.c -o cin2tab.o
	gcc $(TL_OBJS) cin2tab.o -o cin2tab

addphrase : addphrase.c $(TL_OBJS)
	gcc -c $(CFLAGS) addphrase.c -o addphrase.o
	gcc $(TL_OBJS) addphrase.o -o addphrase

levelphrase : levelphrase.c
	gcc -g $(CFLAGS) levelphrase.c -o levelphrase

tl_sysphrase.gb.bin : levelphrase addphrase
	@echo "==== Compiling GB System Phrase Table, please wait ==="
	./levelphrase sort.char.count  sort.word.count
	./addphrase -c sort.char.count -o tl_sysphrase.gb.bin 
	./addphrase -w sort.word.count -o tl_sysphrase.gb.bin

gb/CCDOSPY.tab : cin2tab tl_sysphrase.gb.bin
	@echo "==== Compiling CCDOSPY table, please wait ==="
	./cin2tab -c gb/CCDOSPY -o tl_sysphrase.gb.bin

gb/WuBi.tab : cin2tab tl_sysphrase.gb.bin
	@echo "==== Compiling WuBi table, please wait ==="
	./cin2tab -c gb/WuBi -o tl_sysphrase.gb.bin

gbk/gbkpy_mb.tab : cin2tab
	@echo "==== Compiling gbkpy_mb table, please wait ==="
	./cin2tab -c gbk/gbkpy_mb -o tl_sysphrase.gb.bin

# GB Support
gbdata: gb/CCDOSPY.tab gb/WuBi.tab gbk/gbkpy_mb.tab

xcin-25/cj.tab : cin2tab
	@echo "==== Compiling cj table, please wait ==="
	./cin2tab -c xcin-25/cj -o tl_sysphrase.big5.bin

xcin-25/simplex.tab : cin2tab
	@echo "==== Compiling simplex table, please wait ==="
	./cin2tab -c xcin-25/simplex -o tl_sysphrase.big5.bin

xcin-25/pinyin.tab : cin2tab
	@echo "==== Compiling pinyin table, please wait ==="
	./cin2tab -c xcin-25/pinyin -o tl_sysphrase.big5.bin

# Big5 Support
big5data: xcin-25/cj.tab xcin-25/simplex.tab xcin-25/pinyin.tab

big5hkscs/cj-hkscs.tab : cin2tab
	@echo "==== Compiling cj-hkscs table, please wait ==="
	./cin2tab -c big5hkscs/cj-hkscs -o tl_sysphrase.big5hkscs.bin

big5hkscs/sx-hkscs.tab : cin2tab
	@echo "==== Compiling sx-hkscs table, please wait ==="
	./cin2tab -c big5hkscs/sx-hkscs -o tl_sysphrase.big5hkscs.bin

# Big5hkscs Support
big5hkscsdata: big5hkscs/cj-hkscs.tab big5hkscs/sx-hkscs.tab

data: gbdata big5data big5hkscsdata

tester: tester.c $(TL_OBJS) $(PROG)
	gcc -o tester tester.c -I. -I../../../include -ldl $(TL_OBJS)

install:
	mkdir -p $(prefix)$(imdir)
	cp -f *.so $(prefix)$(imdir)

data-install:
	mkdir -p $(prefix)$(imdir)/{gb,gbk,big5,big5hkscs}
	cp -f tl_sysphrase.*.bin $(prefix)$(imdir)
	cp -f gbk/*.tab $(prefix)$(imdir)/gbk
	cp -f gb/*.tab $(prefix)$(imdir)/gb
	cp -f xcin-25/*.tab $(prefix)$(imdir)/big5
	cp -f big5hkscs/*.tab $(prefix)$(imdir)/big5hkscs

clean:
	rm -f *.o core a.out *.bak cin2tab *.so
	rm -f cin2tab addphrase levelphrase

data-clean:
	rm -f gb/*.tab
	rm -f xcin-25/*.tab
	rm -f big5hkscs/*.tab
	rm -f gbk/*.tab
	rm -f tl*.bin

distclean:clean
	rm -f gb/*.tab
	rm -f xcin-25/*.tab
	rm -f big5hkscs/*.tab
	rm -f gbk/*.tab
	rm -f *.bin
	rm -f Makefile
	rm -f config.h

