#
# 
# Copyright (c) 1993 The RARE Association 
# 
# All Rights Reserved
# 
# Permission to use, copy, modify, and distribute this software and its 
# documentation for any purpose and without fee is hereby granted, 
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in 
# supporting documentation, and that the name of the author not be
# used in advertising or publicity pertaining to distribution of the
# software without specific, written prior permission.  
# 
# THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
# AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
# AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
#
#
#       $RCSfile: Makefile,v $
#       $Revision: 1.5 $
#       $Author: david $
#       $Date: 1996/03/28 13:28:49 $
#
# Makefile for policy routing tools

SRC=		prtraceroute.pl hostname.c
MAN=		prtraceroute.8

#CC=		cc
CC=		gcc
#
# Local install stuff
BINDIR=		/usr/local/bin
PERL=		/usr/local/bin/perl
MANDIR=		/usr/local/man
MANEXT=		8
HOSTCMD=	/bin/hostname
TRACEROUTE=	traceroute
WHOISHOST=	whois.ripe.net
PORT=		43 
# 
# If you are running Solaris 2.* set SOCKSTREAM to 2
# otherwise leave it as it is
#
SOCKSTREAM=	1
#
KEEPOPEN=	TRUE
FAST=		TRUE
VERSION=	TRUE
SHAR=		shar -odist.shar

OBJ=		prtraceroute
DIST=		$(SRC) $(MAN) Makefile README INSTALL CHANGES

prtraceroute: prtraceroute.pl Makefile $(DEP)
	sed     -e 's:WHOISHOST:$(WHOISHOST):' \
		-e 's:PORT:$(PORT):' \
		-e 's:PERL:$(PERL):' \
		-e 's:HOSTCMD:$(HOSTCMD):' \
		-e 's:TRACEROUTE:$(TRACEROUTE):' \
		-e 's:KEEPOPEN:$(KEEPOPEN):' \
		-e 's:SOCKSTREAM:$(SOCKSTREAM):' \
		-e 's:FAST:$(FAST):' \
		-e 's:VERSION:$(VERSION):' \
		< prtraceroute.pl | \
	$(PERL) -e 'while(<>) { chop; s/\s*$$//; next if (/^# #/); if(/(^.*)(# #.*$$)/) { printf "$$1\n"; next; } print "$$_\n"; }' > $@
	chmod 755 $@

# the lib is currently not used!!!

lib: prtraceroute.pl.lib
	./parseincludes < prtraceroute.pl.lib > prtraceroute.pl

install: $(OBJ) Makefile $(MAN) $(DEP)
	sed -e 's:WHOISHOST:$(WHOISHOST):' \
	    -e 's:XPORT:$(PORT):' $(MAN) > /tmp/$(MAN).tmp
	-install -c -m 755 $(OBJ) $(BINDIR)
	-install -m 644 /tmp/${MAN}.tmp ${MANDIR}/man${MANEXT}/${MAN}

hostname: hostname.o
	$(CC) $(CFLAGS) -o hostname hostname.o
	strip hostname

distribution:
	tar cvf - $(DIST) | gzip -9 > prtraceroute.tar.gz

all: prtraceroute hostname distribution

man: $(MAN)
	-install -m 644 ${MAN} ${MANDIR}/man${MANEXT}/${MAN}

clean:
	-rm -f core a.out dist.shar *.o ,* $(OBJ)


