#
# Makefile for http-analyze
#

# the shell to use for executing commands by make
SHELL	= /bin/sh

# LOCALBIN is the directory where the executable is installed.
# LOCALMAN defines the directory for the (pre-formatted) manpage.
LOCALBIN = /usr/local/bin
LOCALMAN = /usr/local/man/cat1

# Which program to use for compressing the manpage
# (pack is the System V standard)
COMPRESS = pack
#COMPRESS = compress

# where your gd library and include files reside
GDLIB	= /usr/local/lib/libgd.a
GDINC	= /usr/local/include/gd

# Customization
#
# NS_FASTTRACK
#	If defined, http-analyze skips the first line in
#	the logfile, which is used by Netscape's new server
#	generation (i.e. Fasttrack and Enterprise servers)
#	to determine the format which should be used for
#	those logfile entries. Note that http-analyze does
#	not recognize other log formats than the common
#	logfile format (CLF), so don't change the this!
#
# COUNT_EXTRA_BYTES
#	If defined, accounts for the protocol overhead,
#	which already may or may not be accounted for
#	by the HTTP daemon.
#
# USER_AGENT
#	If defined, includes code for generating statistics
#	about the user agents (not excessively tested).
#
# USE_GETHOSTNAME
#	If defined, use gethostname(2) to determine the
#	server's full qualified domain name, otherwise
#	use uname(2) to determine the hostname (which
#	may not be fully qualified).
#
# USE_FGETS
#	If defined, use fgets(3) to read log entries
#	rather than the built-in function which has
#	been highly optimized for speed.
#
# BEST_IO_SIZE=#
#	Set this to the recommended buffer size for I/O when
#	using the built-in function to process the logfile
#	(i.e. if USE_FGETS hasn't been defined). On SGI Indys
#	running IRIX 5.3, the best I/O size seems to be 64KB.
#	This is the default if BEST_IO_SIZE is left undefined.
#
# TIME_STATS
#	Activates code for performance measurement.
#

#DEFINES = -DCOUNT_EXTRA_BYTES -DUSER_AGENT -DUSE_GETHOSTNAME -DUSE_FGETS
DEFINES	= -DUSE_GETHOSTNAME

VERSION	= -DVERSION=\"1.9e\"

OBJ	= http-analyze.o images.o cntrycode.o utils.o
SRC	= http-analyze.c images.c cntrycode.c utils.c
TARGETS	= http-analyze http-analyze.1

# Compiler flags
CC	= cc
#CFLAGS	= -O -xansi -fullwarn -wlint,-pui -woff 827,828 $(DEFINES) $(VERSION)
#CFLAGS	= -O $(DEFINES) $(VERSION) -DTIME_STATS
CFLAGS	= -O $(DEFINES) $(VERSION) 
LDFLAGS	= 
LINT	= lint -u
LIBS	= -lm
NROFF	= nroff
NRFLAGS	= -u1 -man

all:	$(TARGETS)

http-analyze: $(OBJ)
	$(CC) $(LDFLAGS) -o $@ $(OBJ) $(GDLIB) $(LIBS)

http-analyze.o:	http-analyze.c
	$(CC) $(CFLAGS) -c -I$(GDINC) http-analyze.c

images.o:	images.c
	$(CC) $(CFLAGS) -c -I$(GDINC) images.c

lint.out:	$(SRC) defs.h cntrycode.h
	$(LINT) $(CFLAGS) -I$(GDINC) $(SRC) >$@

http-analyze.1:	http-analyze.man
	$(NROFF) $(NRFLAGS) http-analyze.man | col >$@

http-analyze.o:	defs.h cntrycode.h
images.o:	defs.h
utils.o:	defs.h
cntrycode.o:	defs.h cntrycode.h

install:	$(TARGETS)
	cp http-analyze $(LOCALBIN)/
	cp http-analyze.1 $(LOCALMAN)/
	chmod 755 $(LOCALBIN)/http-analyze
	chmod 444 $(LOCALMAN)/http-analyze.1
	chown bin.bin $(LOCALBIN)/http-analyze \
		      $(LOCALMAN)/http-analyze.1
	-rm $(LOCALMAN)/http-analyze.1.gz
	$(COMPRESS) $(LOCALMAN)/http-analyze.1

clean:
	-rm -f $(OBJ) lint.out

realclean:	clean
	-rm -f core http-analyze http-analyze.1

clobber::	realclean
	-rm -f index.html stats*.html stats*.hist sites*.html files*.html *.gif

