# Makefile for the pingtunnel utility
# (c) 2004-2005 Daniel Stdle, daniels@stud.cs.uit.no

CC	 		= gcc
CFLAGS		= -Wall -g
LDOPTS		= -lpthread -lpcap
PT_OBJS		= ptunnel.o md5.o
prefix		= /usr
bindir		= $(prefix)/bin
mandir		= $(prefix)/share/man/man8

all: ptunnel

dist:
	rm -rf PingTunnel/
	mkdir PingTunnel
	cp ptunnel.c ptunnel.h Makefile.dist PingTunnel/
	mv PingTunnel/Makefile.dist PingTunnel/Makefile
	

install: ptunnel
	install -d $(bindir)/
	install -d $(mandir)/
	install ./ptunnel $(bindir)/ptunnel
	install ./ptunnel.8 $(mandir)/ptunnel.8

ptunnel: $(PT_OBJS)
	$(CC) -o $@ $^ $(LDOPTS)

clean:
	rm -f *.o ptunnel
	rm -f .depend

depend: .depend
.depend:
	$(CC) $(CFLAGS) -MM *.c > $@

%.o:%.c
	$(CC) $(CFLAGS) -c -o $@ $<

-include .depend
