# This makefile builds 2 executables. One with IDENT support, (RFC931)
# and one without. Rename the one you want to klaxon and install it as
# usual.
# mine.c is included if you wish to statically link this program
# on Solaris2.X machines, just cc -c it and then link it with
# the executable

# - known to compile cleanly on linux 1.2.13 kernel of slackware 3.0

# Change the line below if you don't like the 3 second timeout
# For finding out IDENT information
TIMEOUT=-DRFC931_TIMEOUT=3

#
# Uncomment the below line if you have a heavily hit service that you
# want to klaxon (e.g. tftp) that will generate a lot of klaxons all
# of a sudden that may take a while to die.
# CFLAGS += -DPREEMPTIVE_TIMEOUT

# The line below is for logging of data. It will log 128 byte of data
# or the amount of data that is received in 3 seconds, whichever is less.
# CFLAGS += -DLOG_DATA

target: 
	@if [ -f /vmunix -o -f /vmlinuz ]; then \
		make all OS="4x" CFLAGS="$(CFLAGS) -DUSE_IDENT $(TIMEOUT)"; \
		rm klaxon.o ; \
		make all2 OS="4x" ; \
	elif [ -f /kernel/genunix ]; then \
		make all CFLAGS="$(CFLAGS) -DUSE_IDENT -DSYSV -DSVR4 $(TIMEOUT)" LDFLAGS="-lnsl -lsocket $(LDFLAGS)" OS="5x" ; \
		rm klaxon.o ; \
		make all2 CFLAGS="$(CFLAGS) -DSYSV -DSVR4" LDFLAGS="-lnsl -lsocket $(LDFLAGS)" OS="5x" ; \
	else \
		make all CFLAGS="$(CFLAGS) -DUSE_IDENT -DSVR4 $(TIMEOUT)" OS="5x" ; \
		rm klaxon.o ; \
		make all2 CFLAGS="$(CFLAGS) -DSVR4" OS="5x" ; \
	fi;

all: klaxon.$(OS).ident
all2: klaxon.$(OS)

klaxon.$(OS).ident: klaxon.o rfc931.o 
	$(CC) -o $@ klaxon.o rfc931.o $(LDFLAGS)

klaxon.$(OS): klaxon.o
	$(CC) -o $@ klaxon.o $(LDFLAGS)

clean: 
	-rm *.o klaxon.4x klaxon.5x klaxon.4x.ident klaxon.5x.ident

tar: clean
	(cd .. ; /opt/gnu/bin/tar cvfz /home/ftp/pub/doug/klaxon.tar.gz klaxon)
