# Makefile.in,v 1.17 1995/09/01 19:56:50 duane Exp
# Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal.  All Rights Reserved.


prefix = @prefix@
INSTALL_BINDIR	= $(prefix)/bin
INSTALL_LIBDIR	= $(prefix)/lib
INSTALL_MANDIR 	= $(prefix)/man

CC		= @CC@
INSTALL		= @INSTALL@
INSTALL_BIN 	= @INSTALL_PROGRAM@
INSTALL_FILE 	= @INSTALL_DATA@
RANLIB		= @RANLIB@

# The binaries will be made in ../bin/. and the agrep library is assumed to
# be in ../lib . You normally don't have to change them.
# NOTE: INDEXDIR can be a relative or absolute path name.
BINDIR		= ../bin
AGREPDIR	= ../agrep
INDEXDIR	= ../index
TEMPLATEDIR	= ../../../../../src/common
LIBAGREPDIR	= ../lib
LIBTEMPLATEDIR	= $(TEMPLATEDIR)/lib
LIBAGREP	= agrep
LIBTEMPLATE	= template
LIBUTIL		= util

STRUCTURED_QUERIES = 1
CFLAGS	      	= -DISO_CHAR_SET $(DEBUG_TOP) -I$(TEMPLATEDIR)/include -I$(AGREPDIR) -w

PROG		= glimpseindex
NOTSPROG	= nots$(PROG)
CASTPROG	= buildcast
NOTSCASTPROG	= nots$(CASTPROG)

TEST	      =	test
OBJS	      =	region.o dir.o io.o build_in.o filetype.o simpletest.o \
		getword.o memlook.o partition.o	


all:	HarvestSall

HarvestSall:		$(PROG)

$(PROG):	glimpse.o $(OBJS) $(LIBAGREPDIR)/lib$(LIBAGREP).a $(LIBTEMPLATEDIR)/lib$(LIBTEMPLATE).a $(LIBTEMPLATEDIR)/lib$(LIBUTIL).a
	$(CC) $(CFLAGS) -L$(LIBAGREPDIR) -L$(LIBTEMPLATEDIR) -o $(PROG) glimpse.o $(OBJS) -l$(LIBAGREP) -l$(LIBTEMPLATE) -l$(LIBUTIL)
	$(INSTALL_BIN) $(PROG) $(BINDIR)/.

clean:
	-rm -f $(OBJS) glimpse.o buildcast.o core a.out $(PROG) $(CASTPROG)

realclean:	clean
	-rm -f Makefile

Sall:		$(CASTPROG) $(PROG)

NOTSall:	$(NOTSCASTPROG) $(NOTSPROG)

#$(TEST):	test.o $(LIBTEMPLATEDIR)/lib$(LIBTEMPLATE).a $(LIBTEMPLATEDIR)/lib$(LIBUTIL).a
#	$(CC) $(CFLAGS) -L$(LIBTEMPLATEDIR) -o $@ test.c -l$(LIBTEMPLATE) -l$(LIBUTIL)

$(CASTPROG):	buildcast.o $(OBJS) $(LIBAGREPDIR)/lib$(LIBAGREP).a $(LIBTEMPLATEDIR)/lib$(LIBTEMPLATE).a $(LIBTEMPLATEDIR)/lib$(LIBUTIL).a
	$(CC) $(CFLAGS) -L$(LIBAGREPDIR) -L$(LIBTEMPLATEDIR) -o $(CASTPROG) buildcast.o $(OBJS) -l$(LIBAGREP) -l$(LIBTEMPLATE) -l$(LIBUTIL)
	cp $(CASTPROG) $(BINDIR)/.

$(NOTSCASTPROG):	buildcast.o $(OBJS) $(LIBAGREPDIR)/lib$(LIBAGREP).a
	$(CC) $(CFLAGS) -L$(LIBAGREPDIR) -o $(CASTPROG) buildcast.o $(OBJS) -l$(LIBAGREP)
	cp $(CASTPROG) $(BINDIR)/.

$(NOTSPROG):	glimpse.o $(OBJS) $(LIBAGREPDIR)/lib$(LIBAGREP).a
	$(CC) $(CFLAGS) -L$(LIBAGREPDIR) -o $(PROG) glimpse.o $(OBJS) -l$(LIBAGREP)
	cp $(PROG) $(BINDIR)/.

$(LIBTEMPLATEDIR)/lib$(LIBTEMPLATE).a:
	cd $(TEMPLATEDIR) ; $(MAKE)

$(LIBTEMPLATEDIR)/lib$(LIBUTIL).a:
	cd $(TEMPLATEDIR) ; $(MAKE)

$(LIBAGREPDIR)/lib$(LIBAGREP).a:
	cd $(AGREPDIR) ; $(MAKE)

region.o: region.c region.h
	$(CC) -c -DSTRUCTURED_QUERIES=$(STRUCTURED_QUERIES) $(CFLAGS) region.c

getword.o: getword.c
	$(CC) -c $(CFLAGS) getword.c

dir.o: dir.c
	$(CC) -c $(CFLAGS) dir.c

partition.o: partition.c
	 $(CC) -c $(CFLAGS) partition.c

glimpse.o: glimpse.c
	 $(CC) -c $(CFLAGS) -DBUILDCAST=0 glimpse.c

buildcast.o: glimpse.c
	 $(CC) -c $(CFLAGS) -DBUILDCAST=1 -o buildcast.o glimpse.c

io.o: io.c
	 $(CC) -c $(CFLAGS) io.c

build_in.o: build_in.c
	 $(CC) -c $(CFLAGS) build_in.c

filetype.o: filetype.c
	 $(CC) -c $(CFLAGS) filetype.c

simpletest.o: simpletest.c
	 $(CC) -c $(CFLAGS) simpletest.c

memlook.o: memlook.c
	 $(CC) -c $(CFLAGS) memlook.c


$(OBJS): glimpse.h region.h

glimpse.o: glimpse.h region.h

buildcast.o: glimpse.h region.h

