# $Id: Makefile.in,v 1.23 1996/12/10 05:10:13 minshall Exp $

# Targets (for user):
#	all (default)	-	makes tcpdpriv
#	clean -			cleans up .o, core, and tcpdpriv
#	distclean -		does a "clean", and removes Makefile
#
# Targets (for maintainer):
#	distribution -		makes the .tar.Z and .web.tar files
#	webinstall -		installs the .web.tar file in
#				    ${HOME}/public_html/dist/sw
#	maintainer-clean -	does a "distclean" and removes .0, .0.txt,
#				    any .tar, .tar.Z, and .web.tar.

# version for distribution...
VERS=`cat VERSION`

LIBPATH = -L/usr/local/lib

INCLUDES = -I/usr/local/include -I${HOME}/usr/include

LIBPCAP = -lpcap

WARNINGS	= -Wall

CC = gcc
#have-SVR4#SVR4 = -DSVR4
#have-OSF1#OSF1 = -D__STDC__=2 -Dosf1

#have-SVR4#LIBSVR4 = -lsocket -lnsl

CFLAGS	= -g ${INCLUDES} ${WARNINGS} ${SVR4} ${OSF1} -DWIDE

SOURCES = tcpdpriv.c tcpdutil.c tcpdpriv.1 tcpdpriv.vtml \
				attack50.tex Makefile.in configure INSTALL

DISTRIBUTION = ${SOURCES} tcpdpriv.0 tcpdpriv.0.txt tcpdpriv.html \
				attack50/attack50.html attack50.ps


all:	tcpdpriv

distribution:	fixrev tcpdpriv-${VERS}.tar.Z tcpdpriv.web.tar

webinstall: distribution
	install tcpdpriv.web.tar ${HOME}/public_html/dist/sw

clean:
	-rm -f tcpdpriv tcpdpriv.o tcpdutil.o *.core \
	    attack50.aux attack50.dvi attack50.log \
	    attack50/.ID_MAP.db attack50/.IMG_PARAMS.db attack50/.ORIG_MAP.db \
	    attack50/attack50.css attack50/contents.pl attack50/sections.pl

distclean: clean
	-rm -f Makefile

maintainer-clean: distclean
	-rm -f tcpdpriv.0 tcpdpriv.0.txt tcpdpriv.html tcpdpriv-*.tar \
		    tcpdpriv-*.tar.Z tcpdpriv.web.tar \
		    attack50.ps attack50/attack50.html
	-rmdir attack50

# keep version numbers going... (assume always at least "x.y")

# 1.y.z -> 2.0
majorrev:
	co -l VERSION
	awk '{ \
	    n = split($$0,x,"."); \
	    print (x[1]+1)"."0 \
	}' < VERSION > VERSION.new
	mv VERSION.new VERSION
	ci -u -m"new fix version" VERSION

# x.2.z -> x.3
minorrev:
	co -l VERSION
	awk '{ \
	    n = split($$0,x,"."); \
	    print x[1]"."(x[2]+1) \
	}' < VERSION > VERSION.new
	mv VERSION.new VERSION
	ci -u -m"new fix version" VERSION

# x.y.3 -> x.y.4
fixrev:
	co -l VERSION
	awk '{ \
	    n = split($$0,x,"."); \
	    if (n == 2) { \
		print x[1]"."x[2]".1" \
	    } else { \
		print x[1]"."x[2]"."(x[3]+1) \
	    } \
	}' < VERSION > VERSION.new
	mv VERSION.new VERSION
	ci -u -m"new fix version" VERSION

tcpdpriv:	tcpdpriv.o tcpdutil.o
	${CC} ${CFLAGS} -o tcpdpriv ${LDFLAGS} tcpdpriv.o tcpdutil.o \
					    ${LIBPATH} ${LIBPCAP} ${LIBSVR4}

tcpdpriv.0:	tcpdpriv.1
	nroff -man tcpdpriv.1 > tcpdpriv.0

tcpdpriv.0.txt:	tcpdpriv.0
	colcrt < tcpdpriv.0 > tcpdpriv.0.txt

tcpdpriv.html:	tcpdpriv.vtml VERSION
	sed -e "s/__VERSION__/${VERS}/g" -e "s/__DATE__/`date "+%d %h %y"`/g" \
					tcpdpriv.vtml > tcpdpriv.html

tcpdpriv-${VERS}.tar.Z:	${DISTRIBUTION}
	tar cf tcpdpriv-${VERS}.tar ${DISTRIBUTION}
	rm -f tcpdpriv-${VERS}.tar.Z
	compress tcpdpriv-${VERS}.tar

tcpdpriv.web.tar:	tcpdpriv-${VERS}.tar.Z
	tar cf tcpdpriv.web.tar tcpdpriv-${VERS}.tar.Z \
			tcpdpriv.html tcpdpriv.0.txt attack50/attack50.html

attack50/attack50.html:     attack50.tex
	latex2html -split 0 -info "" \
	    -address "greg minshall <a href=mailto:minshall@ipsilon.com>&lt; minshall@ipsilon.com&gt;</a>" \
	    attack50

attack50.dvi:	attack50.tex
	latex attack50.tex

attack50.ps:	attack50.dvi
	dvips attack50.dvi -q -f < attack50.dvi > attack50.ps
