# @(#) $Header: Makefile,v 1.35 92/02/02 21:12:11 leres Exp $ (LBL)
#
# Makefile for the dexpire package
#
# If you're using System V, add -lBSD to LIBS and -DSYSV to DEFINES
#
# If you're using a Sequent, add -lseq to LIBS.
#
# To use the C News date parser, add ../cnews/libcnews.a to NEWSLIBS
# and -DCNEWS to DEFINES.
#
# To use the B News date parser, figure out what to add to NEWSLIBS, what
# code to add to runexp.c (and then tell leres@ee.lbl.gov how to do it).
#
# Note that it's ok to support both BNEWS and CNEWS. (INN is always
# supported since it stores dates numerically).
#

DSRCS= dexpire.c version.c file.c disk.c util.c hash.c blocktest.c
DOBJS= dexpire.o version.o file.o disk.o util.o
HSRCS= histtrim.c
RSRCS= runexp.c
HOBJS= histtrim.o hash.o util.o
ROBJS= runexp.o util.o
HDRS= dexpire.h file.h disk.h util.h hash.h patchlevel.h
MANS= dexpire.8 histtrim.8 runexp.8
MISC= README Makefile dexplist dodexpire.cnews dodexpire.inn \
    dohisttrim.cnews dohisttrim.inn
NEWSLIBS= 
DEFINES= -DSYSV -DFUNET -DFUNET_DEBUG
LIBS= 
SHAR= shar -v -c -p X
CFLAGS= -O ${DEFINES}
#CC= gcc -W -g -fstrength-reduce -finline-functions -fpcc-struct-return
CC= cc
ALL= dexpire histtrim runexp
NEWSBIN= /usr/lib/news/bin

all: ${ALL}

dexpire: ${DOBJS}
	${CC} ${CFLAGS} ${DOBJS} -o dexpire ${LIBS}

histtrim: ${HOBJS}
	${CC} ${CFLAGS} ${HOBJS} -o histtrim ${LIBS}

runexp: ${ROBJS}
	${CC} ${CFLAGS} ${ROBJS} -o runexp ${LIBS} ${NEWSLIBS}

dexpire.o: dexpire.c ${HDRS}
file.o: file.c ${HDRS}
disk.o: disk.c ${HDRS}
util.o: util.c ${HDRS}
histtrim.o: histtrim.c ${HDRS}
runexp.o: runexp.c ${HDRS}

blocktest: blocktest.c
	${CC} ${CFLAGS} blocktest.c -o blocktest
	./blocktest

tags:
	ctags -wt ${DSRCS} ${HSRCS} ${RSRCS} ${HDRS}

install: ${ALL}
	install dexpire ${NEWSBIN}
	install histtrim ${NEWSBIN}
	install runexp ${NEWSBIN}

dexpire.lpr: dexpire.8
	nroff -man dexpire.8 | ul -tdumb | \
	    egrep -v '^  *Last change:| MAINTENANCE COMMANDS ' | \
	    cat -s > dexpire.lpr

install-man:
	install dexpire.8 /usr/man/man8
	install histtrim.8 /usr/man/man8
	install runexp.8 /usr/man/man8

lint:
	lint -bhxn ${DSRCS} | \
	    egrep -v ', but (never used or|not) defined$$'

test: dexpire
	/bin/time ./dexpire -vn -f 30m

tar:
	tar cf - ${MISC} ${MANS} ${DSRCS} ${HSRCS} ${RSRCS} ${HDRS} | \
	    compress > dexpire.tar.Z

shar:
	${SHAR} ${MISC} ${MANS} ${DSRCS} ${HSRCS} ${RSRCS} ${HDRS} > \
	    dexpire.shar

clean:
	rm -f ${ALL} blocktest *.o dexpire.tar dexpire.shar a.out dexpire.lpr
