.SUFFIXES: .c .o

# CUSTOMIZE THIS

GCC = gcc

# Pathname of directory to install binary
PREFIX = /usr/bin
# Pathname of directory to install the man page
MANDIR = /usr/man/man1
# Pathname of directory to install kernel module
MODDIR = /lib/modules/2.4.9/kernel/net/ipv4/netfilter

# END CUSTOMIZE

INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644

OBJS = shared/hash.o shared/functions.o \
	application/classifier.o application/conn_stats.o \
	application/flow_stats.o application/main.o \
	application/process.o application/rate_limit.o \
	application/rl_stats.o application/dward_ioctl.o \
	application/get_packet_info.o application/replay.o \

LIBS = -lcrypto -lpcap -lnsl -lpthread -lm

ALL = shared kernel application dward 

all: $(ALL)

dward: FORCE 
	$(GCC) -o dward $(OBJS) $(LIBS) 

shared: FORCE
	cd shared; make

kernel: FORCE
	cd kernel; make

application: FORCE
	cd application; make

gui: FORCE
	cd gui; make

call: FORCE
	$(RM) -rf debug/* stats/*

clean: FORCE
	./del
	$(RM) core libJavaNativeSocket.so dward 
	cd shared; make clean
	cd kernel; make clean
	cd application; make clean
	cd gui; make clean

install:
	[ -d $(MODDIR) ] || \
	    (mkdir -p $(MODDIR); chmod 755 $(MODDIR))
	$(INSTALL_PROGRAM) kernel/rl.o $(MODDIR)/rl.o
	[ -d $(PREFIX) ] || \
	    (mkdir -p $(PREFIX); chmod 755 $(PREFIX))
	$(INSTALL_PROGRAM) dward $(PREFIX)/dward
	[ -d $(MANDIR) ] || \
	    (mkdir -p $(MANDIR); chmod 755 $(MANDIR))
	$(INSTALL_DATA) ./dward.1 $(MANDIR)/dward.1
FORCE:

depend:
	cd shared; make depend
	cd kernel; make depend
	cd application; make depend
	cd gui; make depend

# DO NOT DELETE THIS LINE -- mkdep uses it.

