# Makefile for IFmail Internet/FidoNet gateway
# Copyright (c) 1993 by Eugene G. Crosser

# Debug messages turned on by -x key are written here
# If you remove it from defines, debugging will go to stderr
DEBUGFILE   = "/tmp/ifdebug"

# Procession log. Usually gets several lines for each invocation.
# Also look for error diagnostics here
LOGFILE	    = "/usr/local/lib/fnet/iflog"

# Main configuration file. This default may be overwritten by -I key.
CONFIGFILE  = "/usr/local/lib/fnet/config"

BINDIR=/usr/local/lib/fnet
OWNER=fnet

SHELL = /bin/sh
ECHO = echo -e
CC = gcc
#CFLAGS = -g -Wall
CFLAGS = -O6 -Wall
LDFLAGS =

LIBS = -ldbm

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

INCDIR = ../lib
INCLUDES = -I${INCDIR}

DEFINES = -DDEBUGFILE=\"${DEBUGFILE}\" -DLOGFILE=\"${LOGFILE}\" \
		-DCONFIGFILE=\"${CONFIGFILE}\"

UTLIB = ../lib/utlib.a
LIBTAR = ../lib/utlib.tar.Z
OBJMAIL = ifmail.o ftn.o rfcmsg.o config.o packet.o message.o mkftnhdr.o \
		ifdbm.o bwrite.o pktname.o sequencer.o batchrd.o areas.o
OBJTOSS = iftoss.o config.o areas.o ftn.o bread.o getheader.o \
		getmessage.o mkrfcmsg.o rfcmsg.o batchrd.o sequencer.o \
		ifdbm.o falists.o
SRCS = ifmail.c ftn.c rfcmsg.c config.c packet.c message.c mkftnhdr.c \
		ifdbm.c bwrite.c pktname.c sequencer.c batchrd.c areas.c \
		iftoss.c bread.c getheader.c getmessage.c mkrfcmsg.c \
		falists.c
HDRS = ftn.h rfcmsg.h ftnmsg.h config.h bwrite.h areas.h Version \
		mkrfcmsg.h falists.h getheader.h bread.h
OTHER = README TODO Makefile config test newsin pkt sys batchparms \
		ftnpaths routers transports ldbm a2dbm reldate Areas
ALL = ifmail iftoss

.c.o:
	DATE=`cat reldate` ;\
	${CC} -c ${CFLAGS} ${INCLUDES} ${DEFINES} -DDATE=\""$$DATE"\" $<

all:	${ALL}

install: all
	install -o${OWNER} -m0711 iftoss ${BINDIR}/iftoss
	install -o${OWNER} -m4711 ifmail ${BINDIR}/ifmail
	ln -f ${BINDIR}/ifmail ${BINDIR}/ifnews

tryt:	iftoss
	iftoss -Iconfig -x8 <pkt

tryn:	ifmail
	ifmail -Iconfig -n -x8 f103.n5020 <newsin

trym:	ifmail
	ifmail -Iconfig -rf6.n5020.z2.fidonet.org -x8 \
		Pete.Kvitek@f5.n5020.z2.fidonet.org <test

clean:
	rm -f *.o

ifmail:	${OBJMAIL}
	cd ../lib; make all
	${CC} ${LDFLAGS} ${OBJMAIL} ${UTLIB} -o ifmail ${LIBS}
	ln -f ifmail ifnews

iftoss:	${OBJTOSS}
	cd ../lib; make all
	${CC} ${LDFLAGS} ${OBJTOSS} ${UTLIB} -o iftoss ${LIBS}

tar:	ifmail.tar.Z

ifmail.tar.Z: ${SRCS} ${HDRS} ${OTHER}
	tar cf - ${SRCS} ${HDRS} ${OTHER} | \
	compress > ifmail.tar.Z

config:
	test -f config

reldate:	${SRCS} ${HDRS}
	 ls -lt ${SRCS} ${HDRS}|sed -n -e '1p'|awk '{print $$6,$$7,$$8}' >reldate

depend:
	@mv -f 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"; \
			if [ -r $$h ]; \
			then \
				${ECHO} " $$h\c" >>Makefile; \
			else \
				${ECHO} " ${INCDIR}/$$h\c" >>Makefile; \
			fi; \
		done; \
		${ECHO} " done."; \
		${ECHO} "" >>Makefile; \
	done; \
	${ECHO} '# End of generated dependencies' >>Makefile

# temporary - to speed up while I work with iftoss
ifmail.o:	reldate
iftoss.o:	reldate

# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT
# Dependencies generated by make depend
ifmail.o: ../lib/lutil.h ../lib/xutil.h ftn.h rfcmsg.h ftnmsg.h areas.h config.h Version
ftn.o: ../lib/lutil.h ../lib/xutil.h ftn.h
rfcmsg.o: ../lib/xutil.h ../lib/lutil.h rfcmsg.h
config.o: ../lib/xutil.h ../lib/lutil.h ftn.h areas.h config.h
packet.o: ../lib/lutil.h ftn.h config.h bwrite.h
message.o: ../lib/xutil.h ../lib/lutil.h ftn.h ftnmsg.h rfcmsg.h config.h bwrite.h
mkftnhdr.o: ../lib/xutil.h ../lib/lutil.h ftn.h ftnmsg.h rfcmsg.h config.h
ifdbm.o: ../lib/lutil.h config.h
bwrite.o: bwrite.h config.h
pktname.o: ../lib/lutil.h ../lib/xutil.h ftn.h config.h
sequencer.o: ../lib/lutil.h config.h
batchrd.o: ../lib/lutil.h
areas.o: ../lib/lutil.h ../lib/xutil.h areas.h config.h
iftoss.o: ../lib/lutil.h config.h Version ftn.h getheader.h
bread.o: bread.h config.h
getheader.o: ../lib/lutil.h ftn.h bread.h config.h
getmessage.o: ../lib/xutil.h ../lib/lutil.h bread.h ftn.h rfcmsg.h mkrfcmsg.h config.h
mkrfcmsg.o: ../lib/lutil.h ../lib/xutil.h mkrfcmsg.h rfcmsg.h areas.h falists.h config.h
falists.o: ../lib/xutil.h ../lib/lutil.h ftn.h falists.h
# End of generated dependencies
