##  $Revision: 1.12 $
SHELL	= /bin/sh
MAKE	= make
##  =()<P	= @<P>@>()=
P	= 

##  =()<CC	= @<CC>@>()=
CC	= cc
##  =()<DEFS	= @<DEFS>@>()=
DEFS	= -I../include
##  =()<CFLAGS	= @<CFLAGS>@>()=
CFLAGS	= $(DEFS) -g
##  =()<LDFLAGS	= @<LDFLAGS>@>()=
LDFLAGS	= -g
##  =()<LINTFLAGS	= @<LINTFLAGS>@>()=
LINTFLAGS	= -b -h -z $(DEFS)
##  =()<LINTFILTER	= @<LINTFILTER>@>()=
LINTFILTER	= | sed -n -f ../sedf.sun
##  =()<CTAGS		= @<CTAGS>@>()=
CTAGS		= ctags -t -w
##  =()<PROF	= @<PROF>@>()=
PROF	= -pg

##  =()<NEWSBIN	= @<_PATH_NEWSBIN>@>()=
NEWSBIN	= /usr/local/news/bin
## =()<OWNER	= -O @<NEWSUSER>@ -G @<NEWSGROUP>@>()=
OWNER	= -O news -G news

##  =()<LIBS	= @<LIBS>@>()=
LIBS	= 
LIBNEWS	= ../libinn.a
LINTLIB	= ../llib-linn.ln

SOURCES	=	convdate.c expire.c grephistory.c makeactive.c makehistory.c \
		newsrequeue.c prunehistory.c
ALL	=	convdate   expire   grephistory   makeactive   makehistory   \
		newsrequeue   prunehistory

all:		$(ALL)

install:	$(NEWSBIN)/convdate $(NEWSBIN)/expire $(NEWSBIN)/grephistory \
		$(NEWSBIN)/makeactive $(NEWSBIN)/makehistory \
		$(NEWSBIN)/newsrequeue $(NEWSBIN)/prunehistory

clobber clean:
	rm -f *.o $(ALL)
	rm -f expirep profiled
	rm -f all install lint

tags ctags:	$(SOURCES)
	$(CTAGS) $(SOURCES) ../lib/*.c ../include/*.h

convdate:	$(P) convdate.o $(LIBNEWS)
	$(CC) $(LDFLAGS) -o $@ convdate.o $(LIBNEWS) $(LIBS)

expire:		$(P) expire.o $(LIBNEWS)
	$(CC) $(LDFLAGS) -o $@ expire.o $(LIBNEWS) $(LIBS)

grephistory:	$(P) grephistory.o $(LIBNEWS)
	$(CC) $(LDFLAGS) -o $@ grephistory.o $(LIBNEWS) $(LIBS)

makeactive:	$(P) makeactive.o $(LIBNEWS)
	$(CC) $(LDFLAGS) -o $@ makeactive.o $(LIBNEWS) $(LIBS)

makehistory:	$(P) makehistory.o $(LIBNEWS)
	$(CC) $(LDFLAGS) -o $@ makehistory.o $(LIBNEWS) $(LIBS)

newsrequeue:	$(P) newsrequeue.o $(LIBNEWS)
	$(CC) $(LDFLAGS) -o $@ newsrequeue.o $(LIBNEWS) $(LIBS)

prunehistory:	$(P) prunehistory.o $(LIBNEWS)
	$(CC) $(LDFLAGS) -o $@ prunehistory.o $(LIBNEWS) $(LIBS)

lint:		$(ALL)
	@rm -f lint
	lint $(LINTFLAGS) convdate.c     $(LINTLIB) $(LINTFILTER)  >lint
	lint $(LINTFLAGS) expire.c       $(LINTLIB) $(LINTFILTER) >>lint
	lint $(LINTFLAGS) grephistory.c  $(LINTLIB) $(LINTFILTER) >>lint
	lint $(LINTFLAGS) makeactive.c   $(LINTLIB) $(LINTFILTER) >>lint
	lint $(LINTFLAGS) makehistory.c  $(LINTLIB) $(LINTFILTER) >>lint
	lint $(LINTFLAGS) newsrequeue.c  $(LINTLIB) $(LINTFILTER) >>lint
	lint $(LINTFLAGS) prunehistory.c $(LINTLIB) $(LINTFILTER) >>lint

../include/dbz.h:
	(cd ../lib ; $(MAKE) ../include/dbz.h)
$(LIBNEWS) $(LINTLIB):
	(cd ../lib ; $(MAKE) install)

##  Profiling.  The rules are a bit brute-force, but good enough.
profiled:	expirep
	date >$@

expirep:	expire.c
	rm -f expire.o
	$(MAKE) expire CFLAGS="$(CFLAGS) $(PROF)" LIBNEWS=../libinn_p.a
	mv expire expirep
	rm -f expire.o

##
.SUFFIXES: .c .src
.c.src:
	#load $(CFLAGS) $<

##  Low-level install actions.
$(NEWSBIN)/convdate:		convdate
	sh ../installit.sh $(OWNER) -m 0555 -b .OLD $? $@
$(NEWSBIN)/expire:		expire
	sh ../installit.sh $(OWNER) -m 0555 -b .OLD $? $@
$(NEWSBIN)/grephistory:		grephistory
	sh ../installit.sh $(OWNER) -m 0555 -b .OLD $? $@
$(NEWSBIN)/makeactive:		makeactive
	sh ../installit.sh $(OWNER) -m 0555 -b .OLD $? $@
$(NEWSBIN)/makehistory:		makehistory
	sh ../installit.sh $(OWNER) -m 0555 -b .OLD $? $@
$(NEWSBIN)/newsrequeue:		newsrequeue
	sh ../installit.sh $(OWNER) -m 0555 -b .OLD $? $@
$(NEWSBIN)/prunehistory:	prunehistory
	sh ../installit.sh $(OWNER) -m 0555 -b .OLD $? $@

##  Dependencies.  Default list, below, is probably good enough.
depend:		Makefile $(SOURCES)
	makedepend $(DEFS) $(SOURCES)

# DO NOT DELETE THIS LINE -- make depend depends on it.
convdate.o:	../include/clibrary.h
convdate.o:	../include/configdata.h
convdate.o:	../include/libinn.h
convdate.o:	../include/macros.h
expire.o:	../include/clibrary.h
expire.o:	../include/configdata.h
expire.o:	../include/dbz.h
expire.o:	../include/inndcomm.h
expire.o:	../include/libinn.h
expire.o:	../include/macros.h
expire.o:	../include/paths.h
expire.o:	../include/qio.h
grephistory.o:	../include/configdata.h
grephistory.o:	../include/paths.h
grephistory.o:	../include/macros.h
grephistory.o:	../include/libinn.h
grephistory.o:	../include/clibrary.h
grephistory.o:	../include/dbz.h
makeactive.o:	../include/clibrary.h
makeactive.o:	../include/configdata.h
makeactive.o:	../include/libinn.h
makeactive.o:	../include/macros.h
makeactive.o:	../include/mydir.h
makeactive.o:	../include/paths.h
makehistory.o:	../include/clibrary.h
makehistory.o:	../include/configdata.h
makehistory.o:	../include/dbz.h
makehistory.o:	../include/libinn.h
makehistory.o:	../include/macros.h
prunehistory.o:	../include/paths.h
makehistory.o:	../include/paths.h
makehistory.o:	../include/qio.h
newsrequeue.o:	../include/clibrary.h
newsrequeue.o:	../include/configdata.h
newsrequeue.o:	../include/dbz.h
newsrequeue.o:	../include/libinn.h
newsrequeue.o:	../include/macros.h
newsrequeue.o:	../include/paths.h
newsrequeue.o:	../include/qio.h
prunehistory.o:	../include/clibrary.h
prunehistory.o:	../include/configdata.h
prunehistory.o:	../include/dbz.h
prunehistory.o:	../include/libinn.h
prunehistory.o:	../include/macros.h
prunehistory.o:	../include/paths.h
