# 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

TCOMP	      = cast
TCOMPDIR      = ../compress
TCOMPSRC      = $(srcdir)/../compress
TEMPLATESRC   = $(srcdir)/../libtemplate

CFLAGS = -O -DDOTCOMPRESSED=0 -I$(TEMPLATESRC)/include
ALL_CFLAGS    = $(CFLAGS) $(DEFS)

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

PROG	      = agrep
NOTCPROG      = notc$(PROG)

# You can change the target to use the "dummyfilter" so that agrep does not
# use the cast library by changing:
#	all: $(PROG)
# to:
#	all: $(NOTCPROG)
# Both create libagrep.a which can be linked with user a program.
# You must also define -DDOTCOMPRESSED above to be 0 instead of 1.

all: $(NOTCPROG)

LIB	      = lib$(PROG).a
HDRS	      =	agrep.h checkfile.h re.h defs.h
TCOMPLIBOBJ   = \
		$(TCOMPDIR)/hash.o \
		$(TCOMPDIR)/string.o \
		$(TCOMPDIR)/misc.o \
		$(TCOMPDIR)/quick.o \
		$(TCOMPDIR)/cast.o \
		$(TCOMPDIR)/uncast.o \
		$(TCOMPDIR)/tsimpletest.o \
		$(TCOMPDIR)/tbuild.o\
		$(TCOMPDIR)/tmemlook.o
OBJS	      =	\
		follow.o	\
		asearch.o	\
		asearch1.o	\
		agrep.o		\
		bitap.o		\
		checkfile.o	\
		compat.o	\
		maskgen.o	\
		parse.o		\
		checksg.o	\
		preprocess.o	\
		delim.o		\
		asplit.o	\
		recursive.o	\
		sgrep.o		\
		newmgrep.o	\
		utilities.o

$(PROG):	$(OBJS) main.o $(TCOMPDIR)/lib$(TCOMP).a
		$(CC) -L$(TCOMPDIR) $(CFLAGS) -o $@ $(OBJS) main.o -l$(TCOMP)
		$(AR) rcv $(LIB) $(OBJS)
		$(RANLIB) $(LIB)

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

$(NOTCPROG):	$(OBJS) dummyfilters.o main.o
		$(CC) $(CFLAGS) -o $(PROG) $(OBJS) dummyfilters.o main.o
		$(AR) rcv $(LIB) $(OBJS) dummyfilters.o
		$(RANLIB) $(LIB)

clean:
		-rm -f $(LIB) $(OBJS) dummyfilters.o main.o core a.out $(PROG)

compat.o:	agrep.h defs.h config.h
asearch.o:	agrep.h defs.h config.h
asearch1.o:	agrep.h defs.h config.h
bitap.o:	agrep.h defs.h config.h
checkfile.o:	agrep.h checkfile.h defs.h config.h
follow.o:	re.h agrep.h defs.h config.h
main.o:		agrep.h checkfile.h defs.h config.h
agrep.o:	agrep.h checkfile.h defs.h config.h
newmgrep.o:	agrep.h defs.h config.h
maskgen.o:	agrep.h defs.h config.h
next.o:		agrep.h defs.h config.h
parse.o:	re.h agrep.h defs.h config.h
preprocess.o:	agrep.h defs.h config.h
checksg.o:	agrep.h checkfile.h defs.h config.h
delim.o:	agrep.h defs.h config.h
asplit.o:	agrep.h defs.h config.h
sgrep.o:	agrep.h defs.h config.h
abm.o:		agrep.h defs.h config.h
utilities.o:	re.h agrep.h defs.h config.h
dummyfilters.o:	dummyfilters.c
