# Makefile for ifcico FidoNet mailer
# Copyright (c) 1993, 1994 by Eugene G. Crosser

INCDIR = ../iflib

include ../CONFIG

# Include -DNOISEDEBUG to emulate noisy line. If defined, -jNNN option
# causes approximately every NNNth received character to be damaged.
#DEFINES = ${OPTS} -DNOISEDEBUG
DEFINES = -DCICOLOG=${CICOLOG} \
		-DMAILLOG=${MAILLOG} \
		${OPTS}

UTLIB = ../iflib/utlib.a
OBJCICO = version.o ifcico.o nodelist.o flagexp.o call.o callall.o answer.o \
		modemstr.o openport.o opentcp.o dial.o session.o \
		chat.o ttyio.o emsi.o ftsc.o yoohoo.o \
		filelist.o xmsend.o xmrecv.o sendbark.o recvbark.o \
		filetime.o m7recv.o m7send.o respfreq.o \
		rdoptions.o emsidat.o wazoo.o janus.o hydra.o \
		zmsend.o zmrecv.o zmmisc.o zmrle.o \
		tcp.o tcpproto.o \
		openfile.o ftscprod.o dietifna.o \
		nlindex.o openterm.o nldbz.o dbz.o
OBJINDEX = version.o ifindex.o nodebld.o nlindex.o nldbz.o dbz.o
OBJINFO = version.o ifinfo.o nodelist.o nlindex.o nldbz.o dbz.o
OBJPATCH = version.o nlpatch.o
OBJREQ = version.o ifreq.o #nodelist.o nlindex.o nldbz.o dbz.o
OBJROUTE = version.o ifroute.o mxlookup.o nodelist.o nlindex.o nldbz.o dbz.o
OBJSTAT = version.o ifstat.o
SRCS = lastmtime.c ifcico.c nodelist.c call.c callall.c answer.c \
		modemstr.c openport.c opentcp.c dial.c session.c \
		chat.c ttyio.c emsi.c ftsc.c yoohoo.c \
		filelist.c xmsend.c xmrecv.c sendbark.c recvbark.c \
		filetime.c m7recv.c m7send.c respfreq.c \
		rdoptions.c emsidat.c wazoo.c janus.c hydra.c \
		zmsend.c zmrecv.c zmmisc.c zmrle.c \
		tcp.c tcpproto.c \
		openfile.c dietifna.c openterm.c \
		nlindex.c nodebld.c ifindex.c ifroute.c mxlookup.c \
		nlpatch.c nldbz.c dbz.c ifstat.c ifinfo.c ifreq.c
HDRS = nodelist.h statetbl.h session.h ttyio.h emsi.h zmodem.h \
		ftscprod.h nlindex.h janus.h hydra.h fsm.h dbz.h nldbz.h \
		filetime.h openfile.h
OTHER = README README.mxlookup README.TELNET Makefile \
		flaglex.l flagexp.y \
		ftscprod.090 mkprod.awk \
		ifcico.8 ifindex.8 ifinfo.8 ifreq.8 ifroute.8 ifstat.8 nlpatch.8
ALL = ifcico ifindex ifinfo ifreq ifroute ifstat nlpatch

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

all:	${ALL}

ftscprod.c:	ftscprod.???
	${AWK} -F, -f mkprod.awk ftscprod.??? >ftscprod.c

flagexp.c:	flagexp.y
	${YACC} flagexp.y
	mv y.tab.c flagexp.c

flaglex.c:	flaglex.l
	${LEX} flaglex.l
	mv lex.yy.c flaglex.c

zmvars.h:	mkvars.c zmvars.def
	${CPP} mkvars.c >zmvars.h

zmvars.c:	mkvars.c zmvars.def
	${CPP} -DMAKE_C mkvars.c >zmvars.c

flagexp.o:	flaglex.c flagexp.c

flaglex.o:	flaglex.c flagexp.c

install: all
	${INSTALL} -o ${OWNER} -g ${GROUP} -m ${SMODE} ifcico ${BINDIR}/ifcico
	${INSTALL} -o ${OWNER} -g ${GROUP} -m ${SMODE} ifindex ${BINDIR}/ifindex
	${INSTALL} -o ${OWNER} -g ${GROUP} -m ${SMODE} ifinfo ${BINDIR}/ifinfo
	${INSTALL} -o ${OWNER} -g ${GROUP} -m ${SMODE} ifreq ${BINDIR}/ifreq
	${INSTALL} -o ${OWNER} -g ${GROUP} -m ${SMODE} ifroute ${BINDIR}/ifroute
	${INSTALL} -o ${OWNER} -g ${GROUP} -m ${SMODE} ifstat ${BINDIR}/ifstat
	${INSTALL} -o ${OWNER} -g ${GROUP} -m ${SMODE} nlpatch ${BINDIR}/nlpatch

lc:
	wc -l ${SRCS} ${HDRS} ${OTHER}

clean:
	rm -f *.o flaglex.c flagexp.c ftscprod.c core ${ALL} lastmtime \
	iflog ifdebug filelist version.c Makefile.bak

ifcico:	${OBJCICO} ${UTLIB}
	${CC} ${LDFLAGS} ${OBJCICO} ${UTLIB} -o ifcico ${LIBS}

ifindex: ${OBJINDEX} ${UTLIB}
	${CC} ${LDFLAGS} ${OBJINDEX} ${UTLIB} -o ifindex ${LIBS}

ifinfo: ${OBJINFO} ${UTLIB}
	${CC} ${LDFLAGS} ${OBJINFO} ${UTLIB} -o ifinfo ${LIBS}

ifreq: ${OBJREQ} ${UTLIB}
	${CC} ${LDFLAGS} ${OBJREQ} ${UTLIB} -o ifreq ${LIBS}

ifroute: ${OBJROUTE} ${UTLIB}
	${CC} ${LDFLAGS} ${OBJROUTE} ${UTLIB} -o ifroute ${LIBS} ${LIBRESOLV}

ifstat: ${OBJSTAT} ${UTLIB}
	${CC} ${LDFLAGS} ${OBJSTAT} ${UTLIB} -o ifstat ${LIBS}

nlpatch: ${OBJPATCH} ${UTLIB}
	${CC} ${LDFLAGS} ${OBJPATCH} ${UTLIB} -o nlpatch ${LIBS}

lastmtime: lastmtime.c
	${CC} lastmtime.c -o lastmtime

tar:	ifcico.tar.z

ifcico.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 ifcico-${VERSION}/$${BASE}/$$f; done) \
	>filelist

man:
	${INSTALL} -o ${MANOWNER} -g ${MANGROUP} -m ${MANMODE} ifcico.8 ${MANDIR}/man8/ifcico.8
	${INSTALL} -o ${MANOWNER} -g ${MANGROUP} -m ${MANMODE} ifindex.8 ${MANDIR}/man8/ifindex.8
	${INSTALL} -o ${MANOWNER} -g ${MANGROUP} -m ${MANMODE} ifinfo.8 ${MANDIR}/man8/ifinfo.8
	${INSTALL} -o ${MANOWNER} -g ${MANGROUP} -m ${MANMODE} ifreq.8 ${MANDIR}/man8/ifreq.8
	${INSTALL} -o ${MANOWNER} -g ${MANGROUP} -m ${MANMODE} ifroute.8 ${MANDIR}/man8/ifroute.8
	${INSTALL} -o ${MANOWNER} -g ${MANGROUP} -m ${MANMODE} ifstat.8 ${MANDIR}/man8/ifstat.8
	${INSTALL} -o ${MANOWNER} -g ${MANGROUP} -m ${MANMODE} nlpatch.8 ${MANDIR}/man8/nlpatch.8

man.gz:	man
	( cd ${MANDIR}/man8/ ; gzip -f9 ifcico.8 ifindex.8 ifinfo.8 ifreq.8 ifroute.8 ifstat.8 nlpatch.8 )

config:
	test -f config

version.c:	${SRCS} ${HDRS} flaglex.l flagexp.y lastmtime ../CONFIG
	echo 'char *version=${VERSION};' >version.c
	echo 'char *copyright=${COPYRIGHT};' >>version.c
	echo "char *reldate=\"`./lastmtime ${SRCS} ${HDRS} flaglex.l flagexp.y`\";" >>version.c

depend:	version.c
	@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} version.c; \
	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

# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT
# Dependencies generated by make depend
lastmtime.o:
ifcico.o: ../iflib/getopt.h ../iflib/lutil.h ../iflib/xutil.h ../iflib/ftn.h nodelist.h ../iflib/trap.h ../iflib/config.h ../iflib/version.h
nodelist.o: dbz.h ../iflib/directory.h ../iflib/xutil.h ../iflib/lutil.h ../iflib/ftn.h ../iflib/config.h nodelist.h nlindex.h
call.o: ../iflib/lutil.h ../iflib/xutil.h ../iflib/ftn.h nodelist.h ../iflib/config.h session.h ../iflib/callstat.h
callall.o: ../iflib/xutil.h ../iflib/lutil.h ../iflib/ftn.h nodelist.h ../iflib/config.h ../iflib/scanout.h
answer.o: ../iflib/lutil.h ../iflib/ftn.h nodelist.h session.h ../iflib/config.h
modemstr.o: ../iflib/config.h nodelist.h
openport.o: ../iflib/lutil.h ../iflib/xutil.h ../iflib/ulock.h ttyio.h
opentcp.o: ../iflib/lutil.h ttyio.h
dial.o: ../iflib/lutil.h nodelist.h ../iflib/config.h
session.o: ttyio.h ../iflib/lutil.h ../iflib/xutil.h ../iflib/ftn.h nodelist.h statetbl.h session.h ../iflib/config.h emsi.h ../iflib/version.h
chat.o: ../iflib/lutil.h ../iflib/xutil.h nodelist.h ../iflib/config.h
ttyio.o: ttyio.h ../iflib/lutil.h
emsi.o: ../iflib/xutil.h ../iflib/lutil.h ttyio.h session.h statetbl.h ../iflib/config.h emsi.h nodelist.h ../iflib/version.h
ftsc.o: ../iflib/ftn.h ../iflib/getheader.h ../iflib/xutil.h ../iflib/lutil.h session.h ttyio.h statetbl.h ../iflib/config.h
yoohoo.o: statetbl.h ../iflib/xutil.h ../iflib/lutil.h ttyio.h session.h ftscprod.h ../iflib/config.h ../iflib/ftn.h emsi.h nodelist.h ../iflib/version.h
filelist.o: ../iflib/xutil.h ../iflib/lutil.h ../iflib/bwrite.h session.h ../iflib/ftn.h ../iflib/config.h
xmsend.o: session.h ../iflib/lutil.h ttyio.h statetbl.h ../iflib/version.h
xmrecv.o: session.h ttyio.h statetbl.h ../iflib/xutil.h ../iflib/lutil.h ../iflib/config.h
sendbark.o: ../iflib/ftn.h ../iflib/lutil.h ttyio.h session.h statetbl.h
recvbark.o: ../iflib/lutil.h ttyio.h session.h statetbl.h
filetime.o:
m7recv.o: statetbl.h ttyio.h ../iflib/lutil.h
m7send.o: statetbl.h ttyio.h ../iflib/lutil.h
respfreq.o: ../iflib/directory.h session.h ../iflib/xutil.h ../iflib/lutil.h ../iflib/config.h ../iflib/ftnmsg.h ../iflib/version.h
rdoptions.o: session.h ../iflib/xutil.h ../iflib/lutil.h nodelist.h ../iflib/config.h
emsidat.o: ../iflib/ftn.h ../iflib/xutil.h ../iflib/lutil.h emsi.h session.h ../iflib/config.h ../iflib/version.h
wazoo.o: ../iflib/lutil.h ttyio.h session.h statetbl.h ../iflib/config.h emsi.h
janus.o: ../iflib/xutil.h ../iflib/lutil.h ttyio.h session.h ../iflib/config.h emsi.h janus.h
hydra.o: ../iflib/lutil.h ../iflib/xutil.h filetime.h ttyio.h session.h statetbl.h ../iflib/config.h emsi.h openfile.h hydra.h
zmsend.o: ttyio.h ../iflib/xutil.h ../iflib/lutil.h session.h zmodem.h emsi.h
zmrecv.o: ../iflib/cspace.h ../iflib/xutil.h ../iflib/lutil.h ttyio.h zmodem.h session.h ../iflib/config.h emsi.h
zmmisc.o: ../iflib/xutil.h ../iflib/lutil.h ttyio.h zmodem.h
zmrle.o: ../iflib/lutil.h ttyio.h zmodem.h
tcp.o: ../iflib/lutil.h ttyio.h session.h statetbl.h ../iflib/config.h emsi.h
tcpproto.o: ../iflib/xutil.h ../iflib/lutil.h ttyio.h session.h ../iflib/config.h emsi.h
openfile.o: openfile.h ../iflib/xutil.h ../iflib/lutil.h ../iflib/config.h
dietifna.o: ../iflib/lutil.h ttyio.h session.h emsi.h
openterm.o: ../iflib/lutil.h
nlindex.o: ../iflib/directory.h dbz.h ../iflib/xutil.h ../iflib/lutil.h ../iflib/ftn.h ../iflib/config.h nodelist.h nlindex.h nldbz.h
nodebld.o: dbz.h nldbz.h ../iflib/directory.h ../iflib/xutil.h ../iflib/lutil.h ../iflib/ftn.h ../iflib/config.h nodelist.h nlindex.h
ifindex.o: ../iflib/getopt.h ../iflib/lutil.h nodelist.h nlindex.h ../iflib/config.h ../iflib/version.h ../iflib/trap.h
ifroute.o: ../iflib/getopt.h ../iflib/lutil.h ../iflib/xutil.h ../iflib/ftn.h nodelist.h ../iflib/config.h ../iflib/version.h ../iflib/trap.h
mxlookup.o:
nlpatch.o: ../iflib/getopt.h ../iflib/xutil.h ../iflib/lutil.h ../iflib/version.h ../iflib/config.h
nldbz.o: ../iflib/lutil.h ../iflib/xutil.h nldbz.h dbz.h
dbz.o: dbz.h
ifstat.o: ../iflib/getopt.h ../iflib/lutil.h ../iflib/xutil.h ../iflib/ftn.h ../iflib/config.h ../iflib/scanout.h ../iflib/version.h ../iflib/trap.h
ifinfo.o: ../iflib/getopt.h ../iflib/lutil.h ../iflib/xutil.h ../iflib/ftn.h nodelist.h nlindex.h ../iflib/config.h ../iflib/version.h ../iflib/trap.h
ifreq.o: ../iflib/getopt.h ../iflib/lutil.h ../iflib/xutil.h ../iflib/ftn.h ../iflib/config.h ../iflib/version.h ../iflib/trap.h
version.o:
# End of generated dependencies
