# linux pingd Makefile
# daemon9|route <route@infonexus.com>

#   Define this if you want TCP wrapper-like access control.
#   default: enabled.
DEFINES     =   -DWRAP

#   Define this if you want syslog logging of ICMP_ECHO traffic.  This slows
#   slow down daemon response time a bit.
#   default: enabled.
DEFINES     +=   -DLOG

#   Define this if you want the pingd to verify the IP checksum of the ICMP
#   header.  This is recommended as the Linux kernel will not verify the
#   checksum of raw packets and it is therefore possible to receive corrupted
#   ICMP_ECHO  packets.  This will slow down daemon response time a bit also.
#   default: enabled.
DEFINES     +=   -DVERIFY_CHECKSUM

#   Define this if you want pingd to deviate the ICMP_ECHO RTTs a bit and
#   confuse the hell out of the ping client.  This will probably not work on
#   NT/95 ping clients as they default to putting nonsense in the ICMP_ECHO
#   data payload.
DEFINES     +=  -DSKEW_RTT

CC          =   gcc
VER         =   0.5.1
NETSRC      =   /usr/src/linux/net/ipv4
INSTALL_LOC =   /usr/sbin
MAN_LOC     =   /usr/man/man8
MANPAGE     =   pingd.8
PINGD       =   pingd
LIBS        =   -lnet -lwrap
DEFINES     +=   -D__BSD_SOURCE
CFLAGS      =   -O3 -funroll-loops -fomit-frame-pointer -pipe -m486 -Wall
OBJECTS     =   pingd.o

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

pingd:  $(OBJECTS)
	$(CC) $(CFLAGS) $(OBJECTS) -o pingd $(LIBS)
	strip pingd

all: patch pingd

patch:
	@(/usr/bin/patch -d $(NETSRC) < patchfile)
	@(echo "Patchfile installed")
	@(echo "You must now recompile your kernel")
	@(echo "")

install: pingd
	(install -m755 $(PINGD) $(INSTALL_LOC))
	(install -m644 $(MANPAGE) $(MAN_LOC))
	(echo ""                              >> /etc/rc.d/rc.local)
	(echo "echo \"Starting ping daemon\"" >> /etc/rc.d/rc.local)
	(echo "$(INSTALL_LOC)/$(PINGD)"       >> /etc/rc.d/rc.local)

dist:   clean
	@(cd ..; rm pingd-$(VER).tgz; tar cvzf pingd-$(VER).tgz Pingd/)

clean:
	rm -f *.o core pingd
# EOF
