# Makefile for MoA (Morphological Analyzer)
#
#
# create : 95.5.28 (Sat), bgjang@csone
# modify :
# 95.5.30 (Tue), bgjang@csone - add LEX stuff and related ones
# 95.6.1 (Thu), bgjang@csone - add MAK targets at last
# 95.6.19 (Mon), bgjang@csone - add irrtbl.c to SRCS
# 95.6.25 (Sun), bgjang@csone - del edgePool.c, add chart.c
# 95.7.31 (Mon), bgjang - 0.9.0 alpha
#
#

VERSION = 0.9.0

CC= cc
MV= mv
TAR= /usr/local/bin/tar
COMPRESS= /usr/local/bin/gzip
ZSUFFIX= gz
RM= /bin/rm

TGZSRC= *.c *.h env-moa README.HANGUL TODO s01* Makefile \
	bin chkcon codeconv datum dict* doc include lib log token tool-data manual_html

.KEEP_STATE:

# please specify the followings appropriately.
# -DNDEBUG : if you don't want to see 'assert' error.
# -DLEXDEBUG : if you want to the procedure of lex regular expression steps
#              you must modify something in 'lexconv' file, too.
# -DDEBUG : if you want to see all debug messages ... ;)
# -DDEBUGR : if you want to see only result edges.
# -DDEBUGU : if you want to see unknown word processing step.
# -DKTS : if you want to see results like KTS (normal output form)
# -DLOG_STATISTIC : if you want to logging the resource usage by MoA
#

C= -Qoption cpp -B
#D= -g -I./include -I./ -DLOG_STATISTIC -DDEBUG # -DDEBUGR # -DDEBUGU
D= -g -I./include -I./ -DKTS -DLOG_STATISTIC # -DDEBUG # -DDEBUGR # -DDEBUGU
CFLAGS= $(C) $(D)
LDFLAGS= -L/usr/lib -L./lib

LIBS = ./lib/libtoken.a ./lib/libkimmo.a ./lib/libdict.a
SRCS = chart.c MAchart.c MAerror.c MAmain.c MAdo.c \
	orderedSet.c intStack.c irrtbl.c cache.c misc.c
OBJS = chart.o MAchart.o MAerror.o MAmain.o MAdo.o \
	orderedSet.o intStack.o irrtbl.o cache.o misc.o

TSRCS = testOrdered.c
TOBJS = testOrdered.o

all : sub moa # testOrdered

moa : $(OBJS) $(LIBS)
	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -ltoken -lkimmo -ldict -ll -o $@

sub : FRC
	@(cd codeconv; make)
	@(cd dict; make)
	@(cd token; make)
	@(cd chkcon; make)
	@(cd tool-data; make)

#
# test drivers
#
# testEdgePool : testEdgePool.o edgePool.o
#	$(CC) $(CFLAGS) $(LDFLAGS) testEdgePool.o edgePool.o -o $@

testOrdered : testOrdered.o orderedSet.o
	$(CC) $(CFLAGS) $(LDFLAGS) testOrdered.o orderedSet.o -o $@
#
# misc.
#

clean :
	-$(RM) *.o core moa testOrdered Makefile.bak

depend :
	makedepend -- $(D) -- $(SRCS) $(TSRCS)

tgz : clean
	-@(cd bin; /bin/rm -f *)
	-@(cd lib; /bin/rm -f *)
	@(cd codeconv; make clean)
	@(cd dict; make clean)
	@(cd token; make clean)
	@(cd chkcon; make clean)
	@(cd tool-data; make clean)
	-@$(MV) MoA.$(VERSION).tar.$(ZSUFFIX) old
	@$(TAR) cvf MoA.$(VERSION).tar $(TGZSRC)
	@echo -n compressing MoA.$(VERSION).tar ... 
	@$(COMPRESS) MoA.$(VERSION).tar
	@echo done.

FRC :

#
# DO NOT DELETE THIS LINE -- make depend depends on it.

chart.o: /usr/include/stdio.h pos.h chart.h
MAchart.o: /usr/include/stdio.h ./include/token.h common.h pos.h chart.h
MAchart.o: MAchart.h MAerror.h
MAerror.o: /usr/include/stdio.h /usr/include/varargs.h MAerror.h
MAmain.o: /usr/include/stdio.h /usr/include/assert.h /usr/include/fcntl.h
MAmain.o: /usr/include/sys/fcntlcom.h /usr/include/sys/stdtypes.h
MAmain.o: /usr/include/wchar.h /usr/include/sys/stat.h
MAmain.o: /usr/include/sys/types.h /usr/include/sys/sysmacros.h
MAmain.o: ./include/MAdict.h version.h common.h pos.h MAchart.h MAerror.h
MAmain.o: /usr/include/stdlib.h /usr/include/limits.h
MAdo.o: /usr/include/stdio.h /usr/include/assert.h /usr/include/fcntl.h
MAdo.o: /usr/include/sys/fcntlcom.h /usr/include/sys/stdtypes.h
MAdo.o: /usr/include/wchar.h /usr/include/sys/stat.h /usr/include/sys/types.h
MAdo.o: /usr/include/sys/sysmacros.h ./include/MAdict.h common.h pos.h
MAdo.o: irrtbl.h ./include/token.h MAchart.h MAerror.h orderedSet.h
orderedSet.o: orderedSet.h
irrtbl.o: /usr/include/stdio.h irrtbl.h pos.h common.h MAchart.h MAerror.h
irrtbl.o: ./include/kimmocode.h
cache.o: /usr/include/stdio.h chart.h pos.h common.h version.h
misc.o: /usr/include/time.h /usr/include/sys/stdtypes.h /usr/include/wchar.h
misc.o: common.h /usr/include/stdio.h pos.h
testOrdered.o: orderedSet.h
