
# This Makefile will help automate the installation of the binaries that
# are needed to enable Van Jacobson's traceroute.  This Makefile has been
# written for and tested on a Sun 3, Sun 3x, and Sun 4 machines running
# SunOS 4.0.x.  There is no reason, however, why it could not be expanded
# to the 386i or other machines.
#
# Note that this Makefile will overwrite the existing (SunOS 4.0.x versions)
# of /sys/arch/OBJ/raw_ip.o and /sys/arch/OBJ/ip_icmp.o, where "arch" is
# your kernel architecture.  If you want to save the 4.0.x versions of
# raw_ip.o and ip_icmp.o, you need to do this by hand before running
# the Makefile. 
#

# To install, set the ARCH_K and DESTDIR variables properly.  (See
# accompanying notes elsewhere in the # Makefile.)
#
# Then become root and type "make install"
#
# REMINDER:
# YOU MUST RECOMPILE AND REINSTALL YOUR KERNEL AFTER RUNNING THIS MAKEFILE!!
# IF YOU DO NOT DO THIS, TRACEROUTE WILL NOT BE ENABLED ON YOUR MACHINE.
#
# Manavendra K. Thakur <thakur@zerkalo.harvard.edu>  11/24/89
# Revised to fix DESTDIR. 01/29/90


# ARCH_K should be set to the output you get when you type "arch -k"
# on your system.  (Should be one of sun3, sun3x, sun4, or sun4c.)
ARCH_K= sun3

# Set DESTDIR to the directory in which the traceroute executable will be
# installed.  /usr/etc is a good place to put a network debugging tool such
# as this.

DESTDIR= /usr/etc

# You shouldn't need to change anything below this line.

CC= cc
CFLAGS = -O
KFLAGS= -fsoft -DKERNEL -D$(ARCH_K)

# At the moment, the INCL variable isn't really needed for anything.
INCL = -I.
LIBS = 
MANDIR= /usr/man/man8

# SUN_INCL_DIR should be set to the full pathname of the system include
# directory in which ip_icmp.h lives.  For SunOS 4.0.3 and 4.0.3c, this is
# /usr/include/netinet.
SUN_INCL_DIR= /usr/include/netinet

# SYS_OBJ_DIR is the directory in which kernel object modules live.
# Assuming you set ARCH_K properly above, you shouldn't need to change
# this.
SYS_OBJ_DIR= /sys/$(ARCH_K)/OBJ


all: traceroute ip_icmp.o raw_ip.o

traceroute: traceroute.c
	$(CC) $(CFLAGS) $(INCL) -o traceroute traceroute.c $(LIBS)

ip_icmp.o: $(SUN_INCL_DIR)/ip_icmp.h
	$(CC) $(CFLAGS) $(KFLAGS) $(INCL) -c ip_icmp.c

raw_ip.o:
	$(CC) $(CFLAGS) $(KFLAGS) $(INCL) -c raw_ip.c

install: all
	install -o root -g bin -m 4755 traceroute ${DESTDIR}
	install -o root -g staff -m 755 traceroute.8 ${MANDIR}
	install -o root -g staff -m 444 ip_icmp.o $(SYS_OBJ_DIR)
	install -o root -g staff -m 444 raw_ip.o $(SYS_OBJ_DIR)
	@ echo ""
	@ echo "Binaries and man page installed."
	@ echo ""
	@ echo "NOW YOU MUST RECOMPILE AND REINSTALL YOUR KERNEL!!"
	@ echo "IF YOU DO NOT, THEN TRACEROUTE WILL NOT BE ENABLED."

lint:
	lint -b -h -x $(INCL) traceroute.c | \
	  grep -v 'possible pointer alignment problem'

$(SUN_INCL_DIR)/ip_icmp.h: ./ip_icmp.h
	mv $(SUN_INCL_DIR)/ip_icmp.h   $(SUN_INCL_DIR)/ip_icmp.h.old
	cp -p ./ip_icmp.h   $(SUN_INCL_DIR)

clean:
	rm -f *.o traceroute

FRC:

