# Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal.  All Rights Reserved.

# YOU DON'T HAVE TO CHANGE ANYTHING BELOW THIS LINE

srcdir = @srcdir@
VPATH  = @srcdir@
SHELL  = /bin/sh
CC     = @CC@
RANLIB = @RANLIB@
INSTALL		= @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA	= @INSTALL_DATA@
DEFS		= @DEFS@

prefix = @prefix@
exec_prefix = $(prefix)
binprefix =
manprefix =

bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
mandir = $(prefix)/man/man1
manext = 1

AGREPDIR	= ../agrep
AGREPSRC	= $(srcdir)/$(AGREPDIR)
INDEXDIR	= ../index
INDEXSRC	= $(srcdir)/$(INDEXDIR)
TEMPLATEDIR	= ../libtemplate
TEMPLATESRC	= $(srcdir)/$(TEMPLATEDIR)
TCOMP	      = cast
TCOMPDIR      = ../compress
TCOMPSRC      = $(srcdir)/../compress
LIBAGREP	= agrep
LIBTEMPLATE	= template
LIBUTIL		= util

CFLAGS = -O -DSTRUCTURED_QUERIES=1
ALL_CFLAGS    = $(CFLAGS) $(DEFS) -I$(AGREPSRC) -I$(TEMPLATESRC)/include

.c.o:
		$(CC) -c $(ALL_CFLAGS) $<

PROG		= glimpseindex
CASTPROG	= buildcast

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

all:		$(CASTPROG) $(PROG)

$(CASTPROG):	buildcast.o $(OBJS) $(AGREPDIR)/lib$(LIBAGREP).a $(TEMPLATEDIR)/$(LIBTEMPLATE)/lib$(LIBTEMPLATE).a $(TEMPLATEDIR)/$(LIBUTIL)/lib$(LIBUTIL).a $(TCOMPDIR)/lib$(TCOMP).a
	$(CC) $(CFLAGS) -L$(AGREPDIR) -L$(TEMPLATEDIR)/$(LIBTEMPLATE) -L$(TEMPLATEDIR)/$(LIBUTIL) -L$(TCOMPDIR) -o $(CASTPROG) buildcast.o $(OBJS) -l$(LIBAGREP) -l$(LIBTEMPLATE) -l$(LIBUTIL)

$(PROG):	glimpse.o $(OBJS) $(AGREPDIR)/lib$(LIBAGREP).a $(TEMPLATEDIR)/$(LIBTEMPLATE)/lib$(LIBTEMPLATE).a $(TEMPLATEDIR)/$(LIBUTIL)/lib$(LIBUTIL).a $(TCOMPDIR)/lib$(TCOMP).a
	$(CC) $(CFLAGS) -L$(AGREPDIR) -L$(TEMPLATEDIR)/$(LIBTEMPLATE) -L$(TEMPLATEDIR)/$(LIBUTIL) -L$(TCOMPDIR) -o $(PROG) glimpse.o $(OBJS) -l$(LIBAGREP) -l$(LIBTEMPLATE) -l$(LIBUTIL)

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

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

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

$(TCOMPDIR)/lib$(TCOMP).a:
	cd $(TCOMPDIR) ; $(MAKE)

region.o: region.c region.h

glimpse.o: glimpse.c glimpse.h region.h
	$(CC) -c $(ALL_CFLAGS) -DBUILDCAST=0 $(srcdir)/glimpse.c

buildcast.o: glimpse.c glimpse.h region.h
	$(CC) -c $(ALL_CFLAGS) -DBUILDCAST=1 -o buildcast.o $(srcdir)/glimpse.c

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

$(OBJS): glimpse.h region.h


