PREFIX?=	/usr/local
AGURIDIR?=	$(PREFIX)/lib/aguri

# uncomment for non-bsd platforms (including linux)
#COMPAT_INCLUDES=	-Ibsd-compat

PROG=	aguri
OBJS=	aguri.o aguri_ip.o aguri_pcap.o aguri_plot.o aguri_tree.o \
	read_pcap.o xtree.o
SCRIPTS=	scripts/agurify.pl scripts/makeplot.pl \
	scripts/makeimages.pl scripts/density.pl

CFLAGS=		-O2 -Wall -DNDEBUG
DEFINES=	-DINET6 -DAGURI_STATS $(SYS_DEFINES) # -DXTREE
INCLUDES=	-I. $(COMPAT_INCLUDES) $(SYS_INCLUDES) # -I/usr/X11R6/include
LIBS=		$(SYS_LIBS) -lpcap # -R/usr/X11R6/lib -L/usr/X11R6/lib -lX11 

all: $(PROG)

install: $(PROG)
	$(INSTALL) $(COPY) -m 0755 $(PROG) $(PREFIX)/bin
	$(INSTALL) $(COPY) -m 444 -o bin -g bin aguri.1 $(PREFIX)/man/man1
	if [ ! -d $(AGURIDIR) ]; then \
		mkdir $(AGURIDIR); \
	fi
	$(INSTALL) -m 755 -o bin -g bin $(SCRIPTS) $(AGURIDIR)

aguri: $(OBJS)
	$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -o $@ $(OBJS) $(LIBS)

.c.o: 
	$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -c $*.c

clean:;	-rm -f $(PROG) *.o core *.core *.bak ,* *~ "#"* *.gmon
