#CC=	gcc -W -Wunused -Wreturn-type -Wcast-qual -Wpointer-arith -Wwrite-strings -Wcomment -Wswitch -Wshadow -pipe
CC=	cc
LIBS=-lm
CFLAGS= -g -DDBG -DPKTLOG -DIFF_MULTICAST

LINTFLAGS=-hp $(CFLAGS)

HEADS=	avl/ort_avl.h\
	port/ospf_port.h\
	port/ospf_log.h\
	port/ospf_mem.h\
	port/ospf_mib.h\
	port/ospf_port_rtab.h\
	port/ospf_types.h\
	ospf.h\
	ospf_const.h\
	ospf_pkts.h\
	ospf_timerq.h\
	ospf_rtab.h\
	ospf_lsdb.h\
	ospf_timer_calls.h

SOURCE=	\
	ospf_build_dbsum.c\
	ospf_build_ls.c\
	ospf_choose_dr.c\
	ospf_flood.c\
	ospf_lsdb.c\
	ospf_newq.c\
	ospf_rtab.c\
	ospf_rxack.c\
	ospf_rxdb.c\
	ospf_rxhello.c\
	ospf_rxlinkup.c\
	ospf_rxpkt.c\
	ospf_rxreq.c\
	ospf_spf.c\
	ospf_spf_leaves.c\
	ospf_states.c\
	ospf_timerq.c\
	ospf_tqhandle.c\
	ospf_txpkt.c

OBJS=$(SOURCE:.c=.o)

PORTSRC= 	\
	port/oport_ase.c\
	port/oport_chksum.c\
	port/oport_conf.c\
	port/oport_log.c\
	port/oport_main.c\
	port/oport_mib.c\
	port/oport_mib_print.c\
	port/oport_mib_tst.c\
	port/oport_port.c\
	port/oport_rtab.c\
	port/oport_rxmon.c\
	port/oport_sock.c\
	port/oport_trace.c\
	port/oport_txpkt.c

PORTOBJS=$(PORTSRC:.c=.o)

AVLSRC=	avl/ort_avl.c
AVLOBJS= avl/ort_avl.o

ospfd:  portdir avldir $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) $(PORTOBJS) $(AVLOBJS) -o $@ $(LIBS)

portdir:
	(cd port; make)

avldir:
	(cd avl; make)

sim:  $(OBJS) $(PORTOBJS)

clean:
	-rm -f *.o port/*.o avl/*.o util/*.o util/util core ospfd linterrs iolog.out pkt.dmp

lint:
	lint $(LINTFLAGS) $(SOURCE) | tee linterrs


$(OBJS):	$(HEADS)
