#
#  ipband - IP bandwidth watchdog
#  Change this variables to match your installation
#
#  Note: When the version changes, you also have to change
#  the RPM spec file

V=0.7.2

MAKE=make

CPPFLAGS=-I/usr/include/pcap
LIBS=-lpcap
CFLAGS=-Wall
CC=gcc 


BIN 	= ipband
SRC_C 	= main.c error.c init.c packets.c \
	  pcapfunc.c popen.c reports.c utils.c hash.c
OBJ_C   = $(SRC_C:.c=.o)


all: 	$(BIN)

$(BIN):	$(OBJ_C)
	$(CC) -o $(BIN) $(OBJ_C) $(LIBS) $(CFLAGS)
	strip $(BIN)


install: all
	install -D ipband   /usr/local/bin/ipband
	install -D ipband.1 /usr/local/man/man1/ipband.1
	install -D ipband.sample.conf /etc/ipband.sample.conf
	install -D ipband.rc /etc/rc.d/init.d/ipband


clean:
	rm -f *.o
	rm -f ipband


#
#  -------------------------------------------------------------------------
#
#  If we need rpm

SRC_ROOT = Makefile CHANGELOG COPYING README INSTALL ipband.spec
SRC_SRCS = Makefile *.c *.h ipband.1
SRC_CONF = ipband.sample.conf ipband.rc

tgz:	
	mkdir ipband-$(V)
	cp $(SRC_ROOT) ipband-$(V)/
	cp $(SRC_SRCS) ipband-$(V)/
	cp $(SRC_CONF) ipband-$(V)/
	tar -czvf ipband-$(V).tgz ipband-$(V)/
	rm -rf ipband-$(V)

rpm:    tgz
	mv ipband-$(V).tgz /usr/src/redhat/SOURCES
	cp ipband.spec /usr/src/redhat/SPECS
	rpm -bb ipband.spec
