INCDIR = .

include ../CONFIG

DEFINES =	-DDEBUGFILE=\"${DEBUGFILE}\" \
		-DLOGFILE=\"${LOGFILE}\" \
		-DCONFIGFILE=\"${CONFIGFILE}\" \
		-DLOCKDIR=\"${LOCKDIR}\" \
		-DPUBDIR=\"${PUBDIR}\" \
		-DMAILLOG=${MAILLOG} \
		-DNEWSLOG=${NEWSLOG} \
		-DCICOLOG=${CICOLOG} \
		${OPTS}

OBJS = lutil.o xutil.o ulock.o rfcdate.o sequencer.o ftnmsg.o \
		crc.o parsedate.o gettime.o execute.o execsh.o \
		rdconfig.o ftn.o packet.o pktname.o bwrite.o \
		bread.o getheader.o scanout.o matchaka.o atoul.o \
		nodelock.o trap.o rfcaddr.o expipe.o callstat.o \
		${NEEDED}
SRCS = lutil.c xutil.c ulock.c rfcdate.c sequencer.c ftnmsg.c crc.c \
		strcasestr.c strncasecmp.c strcasecmp.c \
		rename.c mkdir.c parsedate.y gettime.c \
		rdconfig.c ftn.c packet.c pktname.c bwrite.c \
		bread.c getheader.c scanout.c matchaka.c usleep.c \
		execute.c execsh.c signal.c regexpr.c atoul.c \
		nodelock.c trap.c rfcaddr.c expipe.c callstat.c \
		dirent.c
HDRS = lutil.h xutil.h ulock.h libinn.h macros.h configdata.h clibrary.h \
		config.h ftn.h bwrite.h bread.h getheader.h getopt.h \
		scanout.h trap.h rfcaddr.h ftnmsg.h rfcmsg.h callstat.h \
		version.h directory.h
OTHER = Makefile README parsedate.3

#############################################################################

.c.o:
	${CC} ${CFLAGS} ${INCLUDES} ${DEFINES} -c $<

all:		utlib.a

parsedate.c:	parsedate.y
	@echo expect 6 shift/reduce conflicts
	${YACC} parsedate.y
	mv y.tab.c parsedate.c
	@echo expect 4 warnings compiling parsedate.c

utlib.a:	${OBJS}
	ar r $@ $?
	${RANLIB} $@

clean:
	rm -f utlib.a *.o getdate.c parsedate.c testscan testconf testtrap \
	testrfcaddr core filelist Makefile.bak

install:	all

tar:		utlib.tar.z

utlib.tar.z:	${SRCS} ${HDRS} ${OTHER}
	${TAR} cf - ${SRCS} ${HDRS} ${OTHER} \
	| gzip >$@

filelist:	Makefile
	BASE=`pwd`; \
	BASE=`basename $${BASE}`; \
	(for f in ${SRCS} ${HDRS} ${OTHER} ;do echo ifmail/$${BASE}/$$f; done) \
	>filelist

testconf:	rdconfig.c config.h utlib.a
	cc -g -Wall -DTESTING rdconfig.c utlib.a -o $@

tryconf: testconf
	./testconf ../misc/config

testscan:	scanout.c scanout.h utlib.a
	cc -g -Wall -DTESTING scanout.c utlib.a -o $@

tryscan: testscan
	./testscan ../misc/config

testtrap:	trap.c
	cc -g -Wall -DNEED_TRAP -DTESTING trap.c utlib.a -o $@

trytrap:	testtrap
	./testtrap

testrfcaddr:	rfcaddr.c rfcaddr.h
	cc -g -Wall -DTESTING rfcaddr.c utlib.a -o $@

tryrfcaddr:	testrfcaddr
	./testrfcaddr

depend:
	@rm -f Makefile.bak; \
	mv Makefile Makefile.bak; \
	sed -e '/^# DO NOT DELETE/,$$d' Makefile.bak >Makefile; \
	${ECHO} '# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT' \
		>>Makefile; \
	${ECHO} '# Dependencies generated by make depend' >>Makefile; \
	for f in ${SRCS}; \
	do \
		${ECHO} "Dependencies for $$f:\c"; \
		${ECHO} "`basename $$f .c`.o:\c" >>Makefile; \
		for h in `sed -n -e \
			's/^#[ 	]*include[ 	]*"\([^"]*\)".*/\1/p' $$f`; \
		do \
			${ECHO} " $$h\c"; \
			${ECHO} " $$h\c" >>Makefile; \
		done; \
		${ECHO} " done."; \
		${ECHO} "" >>Makefile; \
	done; \
	${ECHO} '# End of generated dependencies' >>Makefile

# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT
# Dependencies generated by make depend
lutil.o:
xutil.o: xutil.h lutil.h
ulock.o: lutil.h
rfcdate.o:
sequencer.o: lutil.h config.h
ftnmsg.o: lutil.h bwrite.h ftn.h ftnmsg.h
crc.o:
strcasestr.o:
strncasecmp.o:
strcasecmp.o:
rename.o:
mkdir.o:
parsedate.y.o: configdata.h libinn.h macros.h
gettime.o: configdata.h clibrary.h libinn.h
rdconfig.o: xutil.h lutil.h ftn.h config.h
ftn.o: lutil.h xutil.h ftn.h rfcaddr.h config.h
packet.o: xutil.h lutil.h ftn.h config.h bwrite.h
pktname.o: directory.h lutil.h xutil.h ftn.h config.h
bwrite.o: bwrite.h config.h
bread.o: bread.h config.h
getheader.o: lutil.h ftn.h bread.h config.h
scanout.o: directory.h xutil.h config.h ftn.h scanout.h lutil.h
matchaka.o: ftn.h lutil.h config.h
usleep.o:
execute.o: lutil.h
execsh.o: lutil.h
signal.o:
regexpr.o:
atoul.o:
nodelock.o: xutil.h lutil.h ftn.h
trap.o: lutil.h trap.h lutil.h
rfcaddr.o: xutil.h rfcaddr.h
expipe.o: lutil.h
callstat.o: lutil.h ftn.h callstat.h
dirent.o: directory.h
# End of generated dependencies
