# Makefile for the ID3 tree system

#edited by Casey Smith on 9/9/03 to make compatible for Cygwin
#some modification checks are broken here, which means that it will
#always recompile everything, regardless of need

BIN	= ../../../bin
CFLAGOPTS =
CC	= gcc

TREE	= ../Include/TREE.h
SETS	= ../Include/sets.h
SYM	= ../Include/SYM.h
PB	= $(BIN)
PROGS   = tgen tclass tprint tprune thead tchar tweight tgamma tquest
FILES	= tgen.c tclass.c tprune.c tprint.c thead.c \
		tchar.c tweight.c tgamma.c tquest.c
OBJS	= tgen.o tclass.o tprune.o tprint.o thead.o \
		tchar.o tweight.o tgamma.o tquest.o
LIBES	= -L../Eglib -L../Treelib -L../Statlib -L../Lib  -L../Graph \
		-ljgph -ltree -ljgph -leg -lstat -leg -lutil -lm 
LOBJS	= ../Eglib/libeg.a ../Treelib/libtree.a \
		../Statlib/libstat.a ../Lib/libutil.a ../Graph/libjgph.a
LLNS	= ../Eglib/llib-leg.ln ../Treelib/llib-ltree.ln \
		../Statlib/llib-lstat.ln ../Lib/llib-lutil.ln \
		../Graph/llib-ljgph.ln
CFLAGS	= -w -I../Include $(CFLAGOPTS)
INCLUDES = BITARRAY.h DEFN.h SYM.h TREE.h mod.h BITSET.h Lib.h TABLE.h \
           class.h sets.h

install:	$(PB)/tgen $(PB)/tclass $(PB)/tprint $(PB)/tprune \
		$(PB)/tchar $(PB)/thead  $(PB)/tquest

$(PB)/tgen: tgen
	cp bin/tgen* $(PB)
	#strip  $(PB)/tgen

$(PB)/tclass: tclass
	cp bin/tclass* $(PB)
	#strip  $(PB)/tclass

$(PB)/tprint: tprint
	cp bin/tprint* $(PB)
	#strip  $(PB)/tprint

$(PB)/tquest: tquest
	cp bin/tquest* $(PB)
	#strip  $(PB)/tquest

$(PB)/tprune: tprune
	cp bin/tprune* $(PB)
	#strip  $(PB)/tprune

$(PB)/tchar: tchar
	cp bin/tchar* $(PB)
	#strip  $(PB)/tchar

$(PB)/thead: thead
	cp bin/thead* $(PB)
	#strip  $(PB)/thead

$(PROGS):	$(OBJS)  $(LOBJS)
	$(CC) $(CFLAGS) $@.o $(LIBES) -o bin/$@ 

OBJS	= tgen.o tclass.o tprune.o tprint.o thead.o \
		tchar.o tweight.o tgamma.o tquest.o

tgen.o:		$(TREE) $(SETS) $(SYM) 
	$(CC) $(CFLAGS) -c tgen.c

tclass.o:		$(TREE) $(SETS) $(SYM) 
	$(CC) $(CFLAGS) -c tclass.c

tprune.o:		$(TREE) $(SETS) $(SYM) 
	$(CC) $(CFLAGS) -c tprune.c

tprint.o:		$(TREE) $(SETS) $(SYM) 
	$(CC) $(CFLAGS) -c tprint.c

thead.o:		$(TREE) $(SETS) $(SYM) 
	$(CC) $(CFLAGS) -c thead.c

tchar.o:		$(TREE) $(SETS) $(SYM) 
	$(CC) $(CFLAGS) -c tchar.c

tweight.o:		$(TREE) $(SETS) $(SYM) 
	$(CC) $(CFLAGS) -c tweight.c

tgamma.o:		$(TREE) $(SETS) $(SYM) 
	$(CC) $(CFLAGS) -c tgamma.c

tquest.o:		$(TREE) $(SETS) $(SYM) 
	$(CC) $(CFLAGS) -c tquest.c

#$(OBJS):	$(TREE) $(SETS) $(SYM) 
#	$(CC) $(CFLAGS) -c $<

lib:
	cd ../Eglib ; make 
	cd ../Treelib ; make
	cd ../Statlib ; make
	cd ../Lib ; make

lint:
	lint -I../Include $(LLNS)  tgen.c
	lint -I../Include $(LLNS)  thead.c
	lint -I../Include $(LLNS)  tclass.c
	lint -I../Include $(LLNS)  tprune.c
	lint -I../Include $(LLNS)  tprint.c
	lint -I../Include $(LLNS)  tquest.c
	lint -I../Include $(LLNS)  tchar.c

clean:
	rm -f *.O *.o testout *.out errs errs2 bin/* core $(PROGS)  $(INCLUDES)
