#
#  Makefile.in for xcin
#

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


EXTRA_DEFINES = -DLINUX -DXCIN_DIR=\"$(PATH_XCIN_DIR)\" -DDELETE_K=$(OPT_XCIN_DELETEK) -DOPT_XCIN_CFONT=\"$(OPT_XCIN_CFONT)\" -DOPT_XCIN_EFONT=\"$(OPT_XCIN_EFONT)\" -DAuto_First=$(Auto_First)
EXTRA_LIBS    = 


SRC1  =	xi.c pho.c inp.c intcode.c vocbox.c ser_dispatch.c phrase.c conv.c tsin.c 
SRC2  = cli_xcin.c
SRC3  = cin2tab.c def2tab.c
SRC4  = loadphrase.c ph_load.c
SRC5  = ph_r.c phs_out.c
SRC6  = kbmcv.c

OBJS1 = xi.o pho.o inp.o intcode.o vocbox.o ser_dispatch.o phrase.o conv.o tsin.o
OBJS2 = cli_xcin.o
OBJS3 = cin2tab.o conv.o
OBJS4 = loadphrase.o ph_load.o
OBJS5 = ph_r.o phs_out.o

INCS  = pho.h protocol.h state.h xi.h

PROGS = xcin cin2tab def2tab lphrase tsa2d tsd2a d1st phs_out kbmcv pin2tsin

Auto_First = 1
TSINTOOLS  = tsa2d tsd2a phs_out lphrase pin2tsin
TSINTABS   = tsin tsin.idx pho.sel1st sample.phs.out tsin_pin.map
KBMS	   = zo.kbm et.kbm et26.kbm hsu.kbm
INPUT0	   = pho.tab



all: xcin $(KBMS) $(INPUT0) tsintools tsintab cin2tab

.c.o:
	$(CC) -c -o $*.o $(CFLAGS) $(INC_PATH) $(DEFS) $(EXTRA_DEFINES) $<


xcin: $(OBJS1) $(OBJS2)
	$(CC) -o $@ $(OBJS1) $(OBJS2) $(LIB_PATH) $(LIBS) $(EXTRA_LIBS)

#
#  TSINTABS
#
tsintab: tsin pho.sel1st sample.phs.out tsin_pin.map

tsin: tsa2d tsin.src 
	if [ ! -f tsin ] || [ ! -f tsin.idx ]; then  ./tsa2d tsin.src; fi
pho.sel1st: d1st pho1st
	if [ ! -f pho.sel1st ]; then ./d1st; fi
sample.phs.out: phs_out sample.phs
	if [ ! -f sample.phs.out ]; then ./phs_out sample.phs; fi
tsin_pin.map: pin2tsin pin_pho
#	if [ ! -f tsin_pin.map ]; then ./pin2tsin pin_pho; fi
	./pin2tsin pin_pho

#
#  KMBS
#
kbmcv:  kbmcv.c
	$(CC) $(CFLAGS) kbmcv.c -o $@
zo.kbm: kbmcv zo.kbm.src
	if [ ! -f zo.kbm ]; then ./kbmcv zo; fi
et.kbm: kbmcv et.kbm.src
	if [ ! -f et.kbm ]; then ./kbmcv et; fi
et26.kbm: kbmcv et26.kbm.src
	if [ ! -f et26.kbm ]; then ./kbmcv et26; fi
hsu.kbm: kbmcv hsu.kbm.src
	if [ ! -f hsu.kbm ]; then ./kbmcv hsu; fi

#
#  INPUT0
#
$(INPUT0): def2tab phone.def
	if [ ! -f pho.tab ]; then ./def2tab; fi
def2tab: def2tab.c
	$(CC) $(CFLAGS) def2tab.c -o $@

#
#  Cin2Tab & Other .o make rules.
#
cin2tab: $(OBJS3)
	$(CC) -o $@ $(OBJS3) 

#
#  TsinTools
#
tsintools: $(TSINTOOLS)

lphrase: $(OBJS4) 
	$(CC) -o $@ $(OBJS4) $(LIB_PATH) $(LIBS) $(EXTRA_LIBS)
phs_out: $(OBJS5)
	$(CC) -o $@ $(OBJS5) $(LIB_PATH) $(LIBS) $(EXTRA_LIBS)
tsa2d:  tsa2d.c
	$(CC) $(CFLAGS) tsa2d.c -o $@
tsd2a:  tsd2a.c
	$(CC) $(CFLAGS) tsd2a.c -o $@
d1st:   d1st.c
	$(CC) $(CFLAGS) d1st.c -o $@
pin2tsin: pin2tsin.c
	$(CC) $(CFLAGS) pin2tsin.c -o $@

#
#  Cli_Xcin.o
#
cli_xcin.o: cli_xcin.c state.h protocol.h

conv.o: conv.c

inp.o: inp.c xi.h

intcode.o: intcode.c xi.h

pho.o: pho.c pho.h xi.h

phrase.o: phrase.c xi.h

ser_dispatch.o: ser_dispatch.c state.h protocol.h

tsin.o: tsin.c xi.h state.h pho.h

vocbox.o: vocbox.c xi.h

xi.o: xi.c xi.h state.h

cin2tab.o: cin2tab.c xi.h

loadphrase.o: loadphrase.c

ph_load.o: ph_load.c protocol.h

phs_r.o: ph_r.c protocol.h

phs_out.o: phs_out.c


install: install_xcin install_cin2tab install_tsintools

install_xcin: xcin $(KBMS) $(INPUT0) tsintab
	if [ ! -d $(PATH_XCIN_BIN) ]; then $(INSTALL_DIR) $(PATH_XCIN_BIN); fi
	$(INSTALL) xcin $(PATH_XCIN_BIN)
	echo $(PATH_XCIN_BIN)/xcin >> filelist

	if [ ! -d $(PATH_XCIN_DIR) ]; then $(INSTALL_DIR) $(PATH_XCIN_DIR); fi
	for f in $(TSINTABS) $(KBMS) $(INPUT0) voca.box; do\
            cp $$f $(PATH_XCIN_DIR); echo $(PATH_XCIN_DIR)/$$f >> filelist;\
        done

install_cli_xcin.o: cli_xcin.o
	if [ ! -d $(PATH_XCIN_DIR) ]; then $(INSTALL_DIR) $(PATH_XCIN_DIR); fi
	$(INSTALL_DATA) cli_xcin.o $(PATH_XCIN_DIR)
	echo $(PATH_XCIN_DIR)/cli_xcin.o >> filelist

install_cin2tab: cin2tab
	if [ ! -d $(PATH_XCIN_DIR) ]; then $(INSTALL_DIR) $(PATH_XCIN_DIR); fi
	$(INSTALL) cin2tab $(PATH_XCIN_DIR)
	echo $(PATH_XCIN_DIR)/cin2tab >> filelist

install_tsintools: tsintools
	if [ ! -d $(PATH_XCIN_DIR) ]; then $(INSTALL_DIR) $(PATH_XCIN_DIR); fi
	for f in $(TSINTOOLS); do\
            $(INSTALL) $$f $(PATH_XCIN_DIR); echo $(PATH_XCIN_DIR)/$$f >> filelist;\
	done

clean:
	rm -f *.o core filelist $(PROGS) $(TSINTABS) $(KBMS) $(INPUT0)

veryclean: clean
	rm -f Makefile

