SRCS=	checksum.c \
	grand.c \
	if.c \
	inet.c \
	krt.c \
	krt_rtread_kinfo.c \
	krt_ifread_ioctl.c \
	krt_rt_sock.c \
	krt_symbols_nlist.c \
	krt_ipmulti_nocache.c \
	policy.c \
	rt_aggregate.c \
	rt_radix.c \
	rt_redirect.c \
	rt_static.c \
	rt_table.c \
	sockaddr.c \
	str.c \
	targets.c \
	task.c \
	trace.c \
	parse.c \
	aspath.c \
	asmatch.c \
	bgp.c \
	bgp_init.c \
	bgp_rt.c \
	bgp_sync.c \
	hello.c \
	icmp.c \
	ospf_build_dbsum.c \
	ospf_build_ls.c \
	ospf_choose_dr.c \
	ospf_conf.c \
	ospf_flood.c \
	ospf_init.c \
	ospf_log.c \
	ospf_lsdb.c \
	ospf_newq.c \
	ospf_rt.c \
	ospf_rtab.c \
	ospf_rxlinkup.c \
	ospf_rxmon.c \
	ospf_rxpkt.c \
	ospf_spf.c \
	ospf_spf_leaves.c \
	ospf_states.c \
	ospf_tqhandle.c \
	ospf_trace.c \
	ospf_txpkt.c \
	rip.c \
	parser.c

O_SRCS=	ospf_monitor.c

C_SRCS=	signames.c \
	ffs.c \
	IEFBR14.c

R_SRCS=	ripquery.c

G_SRCS=	gdc.c \
	standalone.c

HDRS=	defs.h \
	config.h \
	if.h \
	include.h \
	inet.h \
	krt.h \
	krt_var.h \
	krt_ipmulti.h \
	policy.h \
	rt_table.h \
	rt_var.h \
	sockaddr.h \
	str.h \
	targets.h \
	task.h \
	trace.h \
	parse.h \
	unix.h \
	aspath.h \
	asmatch.h \
	bgp.h \
	bgp_proto.h \
	bgp_var.h \
	hello.h \
	icmp.h \
	ip_icmp.h \
	ospf.h \
	ospf_const.h \
	ospf_gated.h \
	ospf_log.h \
	ospf_lsdb.h \
	ospf_pkts.h \
	ospf_rtab.h \
	ospf_timer_calls.h \
	rip.h \
	paths.h

OBJS=	checksum.o \
	grand.o \
	if.o \
	inet.o \
	krt.o \
	krt_rtread_kinfo.o \
	krt_ifread_ioctl.o \
	krt_rt_sock.o \
	krt_symbols_nlist.o \
	krt_ipmulti_nocache.o \
	policy.o \
	rt_aggregate.o \
	rt_radix.o \
	rt_redirect.o \
	rt_static.o \
	rt_table.o \
	sockaddr.o \
	str.o \
	targets.o \
	task.o \
	trace.o \
	parse.o \
	aspath.o \
	asmatch.o \
	bgp.o \
	bgp_init.o \
	bgp_rt.o \
	bgp_sync.o \
	hello.o \
	icmp.o \
	ospf_build_dbsum.o \
	ospf_build_ls.o \
	ospf_choose_dr.o \
	ospf_conf.o \
	ospf_flood.o \
	ospf_init.o \
	ospf_log.o \
	ospf_lsdb.o \
	ospf_newq.o \
	ospf_rt.o \
	ospf_rtab.o \
	ospf_rxlinkup.o \
	ospf_rxmon.o \
	ospf_rxpkt.o \
	ospf_spf.o \
	ospf_spf_leaves.o \
	ospf_states.o \
	ospf_tqhandle.o \
	ospf_trace.o \
	ospf_txpkt.o \
	rip.o \
	parser.o \
	lexer.o \
	version.o

O_OBJS=	ospf_monitor.o \
	checksum.o \
	str.o \
	standalone.o

C_OBJS=	signames.o \
	ffs.o \
	IEFBR14.o

R_OBJS=	ripquery.o \
	checksum.o \
	str.o \
	standalone.o

G_OBJS=	gdc.o \
	str.o \
	standalone.o

DEFS=	

MYS=	

MANS=	gated.8

O_MANS=	ospf_monitor.8

R_MANS=	ripquery.8

G_MANS=	gdc.8

ALL_MANS=	gated.8 \
	ospf_monitor.8 \
	ripquery.8 \
	gdc.8

LINKS=	../checksum.c \
	../grand.c \
	../if.c \
	../inet.c \
	../krt.c \
	../krt_rtread_kinfo.c \
	../krt_ifread_ioctl.c \
	../krt_rt_sock.c \
	../krt_symbols_nlist.c \
	../krt_ipmulti_nocache.c \
	../policy.c \
	../rt_aggregate.c \
	../rt_radix.c \
	../rt_redirect.c \
	../rt_static.c \
	../rt_table.c \
	../sockaddr.c \
	../str.c \
	../targets.c \
	../task.c \
	../trace.c \
	../lexer.l \
	../parse.c \
	../defs.h \
	../config.h \
	../if.h \
	../include.h \
	../inet.h \
	../krt.h \
	../krt_var.h \
	../krt_ipmulti.h \
	../policy.h \
	../rt_table.h \
	../rt_var.h \
	../sockaddr.h \
	../str.h \
	../targets.h \
	../task.h \
	../trace.h \
	../parse.h \
	../unix.h \
	../aspath.c \
	../aspath.h \
	../asmatch.c \
	../asmatch.h \
	../bgp.c \
	../bgp_init.c \
	../bgp_rt.c \
	../bgp_sync.c \
	../bgp.h \
	../bgp_proto.h \
	../bgp_var.h \
	../hello.c \
	../hello.h \
	../icmp.c \
	../icmp.h \
	../ip_icmp.h \
	../ospf_build_dbsum.c \
	../ospf_build_ls.c \
	../ospf_choose_dr.c \
	../ospf_conf.c \
	../ospf_flood.c \
	../ospf_init.c \
	../ospf_log.c \
	../ospf_lsdb.c \
	../ospf_newq.c \
	../ospf_rt.c \
	../ospf_rtab.c \
	../ospf_rxlinkup.c \
	../ospf_rxmon.c \
	../ospf_rxpkt.c \
	../ospf_spf.c \
	../ospf_spf_leaves.c \
	../ospf_states.c \
	../ospf_tqhandle.c \
	../ospf_trace.c \
	../ospf_txpkt.c \
	../ospf.h \
	../ospf_const.h \
	../ospf_gated.h \
	../ospf_log.h \
	../ospf_lsdb.h \
	../ospf_pkts.h \
	../ospf_rtab.h \
	../ospf_timer_calls.h \
	../ospf_monitor.c \
	../rip.c \
	../rip.h \
	../ripquery.c \
	../gdc.c \
	../standalone.c \
	../compat/ffs.c \
	../compat/IEFBR14.c

#
#	Makefile for gated
#
# Public Release 3
# 
# $Id: Makefile.template,v 1.2 1997/07/17 22:46:19 chopps Exp $
#
# ------------------------------------------------------------------------
# 
# Copyright (c) 1996, 1997 The Regents of the University of Michigan
# All Rights Reserved
#  
# Royalty-free licenses to redistribute GateD Release
# 3 in whole or in part may be obtained by writing to:
# 
# 	Merit GateDaemon Project
# 	4251 Plymouth Road, Suite C
# 	Ann Arbor, MI 48105
#  
# THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
# EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF 
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE REGENTS OF THE
# UNIVERSITY OF MICHIGAN AND MERIT DO NOT WARRANT THAT THE
# FUNCTIONS CONTAINED IN THE SOFTWARE WILL MEET LICENSEE'S REQUIREMENTS OR
# THAT OPERATION WILL BE UNINTERRUPTED OR ERROR FREE. The Regents of the
# University of Michigan and Merit shall not be liable for
# any special, indirect, incidental or consequential damages with respect
# to any claim by Licensee or any third party arising from use of the
# software. GateDaemon was originated and developed through release 3.0
# by Cornell University and its collaborators.
# 
# Please forward bug fixes, enhancements and questions to the
# gated mailing list: gated-people@gated.merit.edu.
# 
# ------------------------------------------------------------------------
# 
# Copyright (c) 1990,1991,1992,1993,1994,1995 by Cornell University.
#     All rights reserved.
# 
# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
# LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE.
# 
# GateD is based on Kirton's EGP, UC Berkeley's routing
# daemon	 (routed), and DCN's HELLO routing Protocol.
# Development of GateD has been supported in part by the
# National Science Foundation.
# 
# ------------------------------------------------------------------------
# 
# Portions of this software may fall under the following
# copyrights:
# 
# Copyright (c) 1988 Regents of the University of California.
# All rights reserved.
# 
# Redistribution and use in source and binary forms are
# permitted provided that the above copyright notice and
# this paragraph are duplicated in all such forms and that
# any documentation, advertising materials, and other
# materials related to such distribution and use
# acknowledge that the software was developed by the
# University of California, Berkeley.  The name of the
# University may not be used to endorse or promote
# products derived from this software without specific
# prior written permission.  THIS SOFTWARE IS PROVIDED
# ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
#
#  The name of this Makefile
MAKEFILE=Makefile
CONFIG=Config

#  Directories
DESTDIR=
BINDIR=/usr/ucb
SBINDIR=/usr/ucb
SRCDIR=..
SMANDIR=../../man
MANDIR=/usr/local/man
MIBDIR=mib
UTILDIR=util
COMPATDIR=../compat
OBJDIR=obj.QNX4

#  Man stuff
MANTYPE=bsd44
TROFF=ptroff
LPR="| lpr"

#  Program names
GATED=gated
GDC=gdc
RIPQUERY=ripquery
OSPF_MONITOR=ospf_monitor

#  Files
PATH_CONFIG=/etc/%s.conf

SIGNAL_H=/usr/include/signal.h

#  Programs we use
AR=ar
AWK=awk
CAT=cat
CHGRP=chgrp
CHMOD=chmod
CHOWN=chown
DATE=date
TAGS=etags
TFLAGS=
HEAD=head -25
INSTALL=../util/install
#INSTALLFLAGS=-c -s
INSTALLFLAGS=-c
LINK=ln -s
MAKE=make
MKDEP=${SRCDIR}/${UTILDIR}/mkdep -flag -I../h
MKDEP_BUILD=${SRCDIR}/${UTILDIR}/mkdep.build
MV=mv
RANLIB=ranlib
RM=rm
SED=sed
SIZE=size
TEE=tee
TOUCH=touch

#  Stuff for gdc
GDC_MODE=4750
GDC_GROUP=wheel
GDC_USER=root

# Stuff for ospf_monitor
OSPFM_MODE=4755
OSPFM_USER=root

SNMP_IFLAGS=

CC=cc
#CFLAGS=-g -w9 -I../h
CFLAGS=-I../h
CWFLAGS=

LDFLAGS=-lsocket ../o/kvm.o
LDOTHERS=

LINT=lint
LINTFLAGS=-hxz

LEX=lex
LFLAGS=-I

YACC=yacc
YFLAGS=-d

LIBGATED=libgated.a

SIGCONV.AWK=${SRCDIR}/${UTILDIR}/sigconv.awk
VERSION.AWK=${SRCDIR}/${UTILDIR}/version.awk
CONFIG.SCRIPT=config_script
IDPR_YY.SED=${SRCDIR}/idpr/parser/idpr_yy.sed
CONFIG_SCRIPT=${UTILDIR}/config
FILES=${SRCDIR}/${UTILDIR}/files
TEMPLATE=${SRCDIR}/${UTILDIR}/Makefile.template

IFLAGS=${SNMP_IFLAGS}

.c.o:
	@echo "Compiling:	$*.c"
	@${CC} -c ${CFLAGS} ${CWFLAGS} ${IFLAGS} $*.c


#  The default is to build gated and ripquery
#
#
all::	make-start

.BEGIN:	make-start
.INIT:	make-start

make-start:	true
	@echo "Make started at `${DATE}` with:"
	@echo "CC = ${CC}"
	@echo "CFLAGS = ${CFLAGS}"
	@echo "CWFLAGS = ${CWFLAGS}"
	@echo "IFLAGS = ${IFLAGS}"

.DONE:	make-end
.END:	make-end

make-end:	true
	@echo "Make ended at `${DATE}`"

true:;


#	Rebuild Makefile
#
#
all::	${MAKEFILE}

.PRECIOUS:	${MAKEFILE} defines.h

config defines.h ${MAKEFILE}:	${CONFIG} ${FILES} ${TEMPLATE}
	@${MV} ${MAKEFILE} ${MAKEFILE}.bak
	@cd ${SRCDIR}; ${CONFIG_SCRIPT} ${OBJDIR}/${CONFIG}
	@${RM} -f ${MAKEFILE}.bak

#	Rules for gated
#	
${GATED}: ${OBJS} ${LIBGATED}
	@echo "Linking:	${GATED}"
	@${CC} ${CFLAGS} ${CWFLAGS} ${OBJS} -o ${GATED} ${LDFLAGS} ${LIBGATED} ${LDOTHERS} \
		&& ${SIZE} ${GATED}

all::	${GATED}

lint::
	${LINT} ${LINTFLAGS} ${IFLAGS} ${SRCS} version.c |\
		${SED} -e '/.*math.h.*/d' -e '/.*floatingpoint.h.*/d' -e '/trace.*used inconsistently.*/d' \
		-e '/[sf]printf.*used inconsistently.*/d' -e '/.*warning: possible pointer alignment problem.*/d' \
		| ${TEE} linterrs.${GATED}


#	This is the idpr specific parser
#
#
idpr_parser: idpr_lex.c idpr_parser.c

idpr_lex.c: idpr_lex.l
	@echo "Building:	idpr lex"
	@${LEX} -t idpr_lex.l | ${SED} -f ${IDPR_YY.SED} > idpr_lex.c

idpr_parser.c idpr_tokens.h: ${SRCDIR}/idpr/parser/idpr_parser.y
	@echo "Building:	idpr_parser"
	@$(YACC) -d ${SRCDIR}/idpr/parser/idpr_parser.y
	@${SED} -f ${IDPR_YY.SED} < y.tab.c > idpr_parser.c
	@${SED} -f ${IDPR_YY.SED} < y.tab.h > idpr_tokens.h
	@${RM} -f y.tab.c y.tab.h

clean::
	-${RM} -f core core.${GATED} ${GATED} ${OBJS} linterrs.${GATED}

cleanall::	clean


install:: ${DESTDIR}${SBINDIR}/${GATED}

${DESTDIR}${SBINDIR}/${GATED}:	${GATED}
	${INSTALL} ${INSTALLFLAGS} ${GATED} ${DESTDIR}${SBINDIR}/${GATED}

paths.h:	${CONFIG.SCRIPT} ${SRCDIR}/paths.h
	@echo "Building:	paths list"
	@./${CONFIG.SCRIPT} < ${SRCDIR}/paths.h > paths.h

man::	${MANS}

install-man::	inst-man ${MANS}
	MANDIR=${MANDIR} ./inst-man -${MANTYPE} ${MANS}


#	Man pages
#
#
all::	man inst-man

clean::	clean-man

clean-man:
	-${RM} -f ${ALL_MANS} inst-man

${ALL_MANS}:
	@echo "Building:	$@"
	@./${CONFIG.SCRIPT} < ${SMANDIR}/$@ | ${SED} s/%s/${GATED}/ > $@

inst-man:	${SRCDIR}/${UTILDIR}/inst-man.sh
	@echo "Building:	inst-man script"
	@./${CONFIG.SCRIPT} < ${SRCDIR}/${UTILDIR}/inst-man.sh > inst-man && ${CHMOD} +x inst-man

print-man:	${ALL_MANS}
	@for man in ${ALL_MANS}; do \
		${TROFF} $${man} ${LPR} ; \
	done

#
#  Build sys_signame[] if not available on this system.
#
#
signames.c:	${SIGCONV.AWK} ${SIGNAL_H}
	@echo "Building:	signal name list"
	@${AWK} -f ${SIGCONV.AWK} < ${SIGNAL_H} > signames.c

clean::
	-${RM} -f signames.c


#	The parser is not normally rebuilt as not all systems will have
#	yacc (bison) and lex (flex) available
#
#
parser:	parser.c lexer.c parse.c

parser.c parser.h:	parser.y
	@echo "Building:	parser"
	@${RM} -f parser.c parser.h
	@$(YACC) $(YFLAGS) parser.y
	@${MV} y.tab.c parser.c
	@${MV} y.tab.h parser.h

parser.y:	${SRCDIR}/parser.y ${CONFIG.SCRIPT}
	@echo "Configuring:	parser"
	@${RM} -f parser.y
	@./${CONFIG.SCRIPT} < ${SRCDIR}/parser.y > parser.y

lexer.c: lexer.l
	@echo "Building:	lexical analyzer"
	@${RM} -f lexer.c
	@${LEX} ${LFLAGS} lexer.l
	@${MV} lex.yy.c lexer.c

clean::
	-${RM} -f y.tab.* y.output

cleanall::
	-${RM} -f lexer.c parser.c parser.h


#  Build version ID from RCS info in file headers
#
#
version:	version.c

version.c:	${SRCDIR}/VERSION version.ids
	@echo 'Building:	version.c'
	@DATE=`${DATE}` ; \
		VERSION="`${CAT} ${SRCDIR}/VERSION`" ; \
		echo '#include "include.h"' > version.c ; \
		echo >> version.c ; \
		echo 'const char *gated_version = "'$${VERSION}'";' >> version.c ; \
		echo 'const char *build_date = "'$${DATE}'";' >> version.c ; \
		echo >> version.c ; \
		${CAT} version.c ; \
		echo >> version.c ; \
		echo 'const char *version_id = "@(#)${GATED} '$${VERSION}' '$${DATE}'";' >> version.c ; \
		echo >> version.c ; \
		${CAT} version.ids >> version.c

version.ids:	${SRCS} ${HDRS}
	@echo 'Updating:	version.ids with ${?}'
	@${TOUCH} version.ids
	@${AWK} -f ${VERSION.AWK} VERSION_IDS=version.ids version.ids ${?} >> version.ids.new
	@${MV} version.ids.new version.ids

clean::
	-${RM} -f version.c version.ids version.ids.new


#	Build the links
#
#
links:	cleanall
	@${MV} defines.h defines.h.save
	@${RM} -r -f *.[chlyo58] gated-mib.defs inst-man
	@${MV} defines.h.save defines.h
	@${LINK} ${LINKS} .

#
#  Build the ripquery program
#
#
${RIPQUERY}:	${R_OBJS} ${LIBGATED}
	@echo 'Linking:	${RIPQUERY}'
	@${CC} ${CFLAGS} ${CWFLAGS} ${IFLAGS} ${R_OBJS} -o ${RIPQUERY} ${LDFLAGS} ${LIBGATED} ${LDOTHERS} \
		&& ${SIZE} ${RIPQUERY}

all::	${RIPQUERY}

lint::
	${LINT} ${LINTFLAGS} ${R_SRCS} | ${TEE} linterrs.${RIPQUERY}

clean::
	-${RM} -f core.${RIPQUERY} ${RIPQUERY} ${R_OBJS} linterrs.${RIPQUERY}

install:: ${DESTDIR}${BINDIR}/${RIPQUERY}

man::	${R_MANS}

install-man::	inst-man ${R_MANS}
	MANDIR=${MANDIR} ./inst-man -${MANTYPE} ${R_MANS}

${DESTDIR}${BINDIR}/${RIPQUERY}:	${RIPQUERY}
	${INSTALL} ${INSTALLFLAGS} ${RIPQUERY} ${DESTDIR}${BINDIR}/${RIPQUERY}

#
#	Build the OSPF monitor program
#
#
${OSPF_MONITOR}:	${O_OBJS} ${LIBGATED}
	@echo 'Linking:	${OSPF_MONITOR}'
	@${CC} ${CFLAGS} ${CWFLAGS} ${IFLAGS} ${O_OBJS} -o ${OSPF_MONITOR} ${LDFLAGS} ${LIBGATED} ${LDOTHERS} \
		&& ${SIZE} ${OSPF_MONITOR}

all::	${OSPF_MONITOR}

lint::
	${LINT} ${LINTFLAGS} ${O_SRCS} | ${TEE} linterrs.${OSPF_MONITOR}

clean::
	-${RM} -f core.${OSPF_MONITOR} ${OSPF_MONITOR} ${O_OBJS} linterrs.${OSPF_MONITOR}

install:: ${DESTDIR}${BINDIR}/${OSPF_MONITOR}

man::	${O_MANS}

install-man::	inst-man ${O_MANS}
	MANDIR=${MANDIR} ./inst-man -${MANTYPE} ${O_MANS}

${DESTDIR}${BINDIR}/${OSPF_MONITOR}:	${OSPF_MONITOR}
	${INSTALL} ${INSTALLFLAGS} -o ${OSPFM_USER} -m ${OSPFM_MODE} ${OSPF_MONITOR} ${DESTDIR}${BINDIR}/${OSPF_MONITOR}



#  Build the gdc program
#
#
${GDC}:	${G_OBJS} ${LIBGATED}
	@echo 'Linking:	${GDC}'
	@${CC} ${CFLAGS} ${CWFLAGS} ${IFLAGS} ${G_OBJS} -o ${GDC} ${LDFLAGS} ${LIBGATED} ${LDOTHERS} \
		&& ${SIZE} ${GDC}

all::	${GDC}

lint::
	${LINT} ${LINTFLAGS} ${G_SRCS} | ${TEE} linterrs.${GDC}

clean::
	-${RM} -f core.${GDC} ${GDC} ${G_OBJS} linterrs.${GDC}

install:: ${DESTDIR}${BINDIR}/${GDC}

man::	${G_MANS}

install-man::	inst-man ${G_MANS}
	MANDIR=${MANDIR} ./inst-man -${MANTYPE} ${G_MANS}

${DESTDIR}${BINDIR}/${GDC}:	${GDC}
	-@${TOUCH} /tmp/$$ ; ${CHGRP} ${GDC_GROUP} /tmp/$$ \
			     && ${CHOWN} ${GDC_USER} /tmp/$$ ; \
		if [ $$? -eq 0 ]; then \
	       	   MODES="-m ${GDC_MODE} -o ${GDC_USER} -g ${GDC_GROUP}" ; \
		else \
			MODES= ; \
		fi ; \
		( set -x ; ${INSTALL} ${INSTALLFLAGS} $${MODES} ${GDC} ${DESTDIR}${BINDIR}/${GDC} ) ; \
		${RM} -f /tmp/$$


#
#	Build the emacs TAGS file
#
#
tags:	TAGS

TAGS:	${SRCS} ${HDRS}
	@echo "Building:	TAGS"
	@${TAGS} ${TFLAGS} ${SRCS} ${HDRS}

cleanall::
	-${RM} -f TAGS


#	Compatibility library
#
#
${LIBGATED}: ${C_OBJS}
	${AR} rc ${@} ${?}
#	${RANLIB} ${@}
#	${RM} -f ${OBJS}

clean::
	-${RM} -f ${LIBGATED} ${C_OBJS}

#
#	ISODE SNMP is not configured
#
#
gated-mib.defs:	true



#	Build dependency lists
#
#
depend:	${SRCS} ${HDRS} ${R_SRCS} ${C_SRCS} ${G_SRCS}
	@echo "Building:	dependency list using ${MKDEP}"
	@CC="${CC}" ${MKDEP} ${IFLAGS} ${SRCS} ${R_SRCS} ${O_SRCS} ${C_SRCS} ${G_SRCS}

build_depend:
	@echo "Building:	canned dependency list using ${MKDEP_BUILD}"
	@CC="${CC}" ${MKDEP_BUILD} ${IFLAGS}


#	Print a message at the end
#
all::	make-end

# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.

