CC	=	g++
#CC	=	egcs
MOC	=	$(QTDIR)/bin/moc
CXXFLAGS	=	-O -s -fno-rtti -fno-const-strings
#CXXFLAGS	=	-O -s -fno-rtti #-fno-const-strings
INCLUDE_FLAGS	=	-I$(QTDIR)/include -I/opt/kde1/include -I$(KDEDIR)/include -I$(KDEDIR)/include/kde  -I/usr/lib/qt-2.0.2/include -I/usr/include/qt
LDFLAGS	=	-O -s -L$(QTDIR)/lib -L$(KDEDIR)/lib -lkdecore -lkdeui -lqt 
OBJS = knat_toolbar.o knat_functions.o knat_window.o knat_rules.o \
       knat_nat.o knat_modules.o knat_masq.o knat_mangle.o \
       main.o knat_initialize.o

# set MAKEFLAG to -j[2+] in your env on multiprocessor systems
#MAKE = make -j4

all: knetfilter

knetfilter: knat.h version.h $(OBJS)
	$(CC) $(LDFLAGS) -o knetfilter $(OBJS)

main.o: knat_initialize.o

install:
	install -m644 play.xpm $(KDEDIR)/share/icons
	install -m644 stop.xpm $(KDEDIR)/share/icons
	install -m644 play_tcp.xpm $(KDEDIR)/share/icons
	install -m644 stop_tcp.xpm $(KDEDIR)/share/icons
	install -m644 play_udp.xpm $(KDEDIR)/share/icons
	install -m644 stop_udp.xpm $(KDEDIR)/share/icons
	install -m644 play_icmp.xpm $(KDEDIR)/share/icons
	install -m644 stop_icmp.xpm $(KDEDIR)/share/icons
	install -m644 probe.xpm $(KDEDIR)/share/icons
	install -m755 -s -g bin knetfilter $(KDEDIR)/bin
	install -m644 knetfilter.kdelnk $(KDEDIR)/share/applnk/Internet
	mkdir -p $(KDEDIR)/share/doc/HTML/default/knetfilter
	install -m755 docs/index.html $(KDEDIR)/share/doc/HTML/default/knetfilter
	export PATH="$(PATH):/sbin:/usr/sbin"
	install -m755 -g bin scripts/getip /bin
	install -m755 -g bin scripts/getnetmask /bin
	install -m755 -g bin scripts/getloop /bin
	install -m755 -g bin scripts/kiptables-save /usr/bin
	install -m755 -g bin scripts/kiptables-restore /usr/bin

uninstall:
	rm -rf $(KDEDIR)/share/doc/HTML/default/knetfilter
	rm -f $(KDEDIR)/share/icons/play.xpm
	rm -f $(KDEDIR)/share/icons/stop.xpm
	rm -f $(KDEDIR)/share/icons/play_tcp.xpm
	rm -f $(KDEDIR)/share/icons/stop_tcp.xpm
	rm -f $(KDEDIR)/share/icons/play_udp.xpm
	rm -f $(KDEDIR)/share/icons/stop_udp.xpm
	rm -f $(KDEDIR)/share/icons/play_icmp.xpm
	rm -f $(KDEDIR)/share/icons/stop_icmp.xpm
	rm -f $(KDEDIR)/share/icons/probe.xpm
	rm -f $(KDEDIR)/bin/knetfilter
	rm -f $(KDEDIR)/share/applnk/Internet/knetfilter.kdelnk
	rm -f /bin/getip /bin/getnetmask /bin/getloop /usr/bin/kiptables-save /usr/bin/kiptables-restore


knat.moc: knat.h
	$(MOC) knat.h -o knat.moc

%.o: %.cpp knat.moc
	$(CC) -c $(INCLUDE_FLAGS) $(CXXFLAGS) $*.cpp

clean:
	rm -f *.o
	rm -f *.moc
	rm -f knetfilter
