LIBS = regexp/libregexp.a ../lib/libdsk.a ../lib/libusp.a ../lib/libcom_err.a
SYSLIBS = -lkrb -ldes

INCLUDES = -I../include -I../../source/include -I./regexp
CFLAGS = -g -O ${INCLUDES}
LFLAGS = -uhv ${INCLUDES}

SOURCES= dsgrep.c regerror.c
OBJECTS= dsgrep.o regerror.o

MFLAGS1= $(MFLAGS) CC=$(CC)

.c.o:
	-rm -f $*.o
	${CC} $(CFLAGS) -c $*.c

all: libregexp dsgrep

libregexp:
	cd regexp	; make $(MFLAGS1) all

dsgrep:	$(OBJECTS) $(LIBS)
	-rm -f dsgrep
	$(CC) $(CFLAGS) -o dsgrep $(OBJECTS) $(LIBS) $(SYSLIBS)

saber:
	#setopt load_flags $(CFLAGS)
	#load $(SOURCES) $(LIBS) $(SYSLIBS)

tags: TAGS

TAGS: $(SOURCES)
	-etags $(SRCS)

lint:	$(SOURCES) ../libds/llib-lds.ln ../lib/llib-lcom_err.ln
	lint $(SOURCES) ../lib/llib-lcom_err.ln ../lib/llib-lds.ln |\
	grep -v " unused in function " |\
	grep -v " set but not used in function " |\
	grep -v "possible pointer alignment "

install: all

clean:
	cd regexp	; make $(MFLAGS1) clean
	rm -f *.o *~ \#* *.bak
	rm -f dsgrep TAGS

dist:	$(SOURCES) Makefile
	cd regexp	; make $(MFLAGS1) clean
	-mkdir ../../dist/source/dsgrep
	cp -p $(SOURCES) ../../dist/source/dsgrep/
	cp -p Makefile ../../dist/source/dsgrep/
	chmod 644 ../../dist/source/dsgrep/Makefile
			
# 'make depend' code
depend: ${SOURCES}
	cd regexp	; make $(MFLAGS1) depend
	${CC} -M ${CFLAGS} ${SOURCES} > makedep
	echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	rm -f Makefile.bak
	cp Makefile Makefile.bak
	ed - Makefile < eddep
	rm -f eddep makedep

undepend:
	cd regexp	; make $(MFLAGS1) undepend
	rm -f Makefile.bak
	cp Makefile Makefile.bak
	echo '/^# DO NOT DELETE THIS LINE/+1,$$c' >eddep
	echo '#' >>eddep
	echo '.' >>eddep
	echo 'w' >>eddep
	ed - Makefile < eddep
	rm -f eddep makedep
#
# the last constant line in the makefile should be...
# DO NOT DELETE THIS LINE
