#
# Makefile for http-analyze
#
# $Id: makefile,v 1.5 1999/03/14 15:49:27 siebert Exp $
#

VERSION = 2.2

# Shell to use for executing commands by make.
#SHELL	= /bin/sh

#
# Local conventions
# -----------------
#
# LOCALLIB is the directory where the required files are installed.
# LOCALBIN is the directory where the executables are installed.
# LOCALMAN defines the directory for the manpage in source or
# pre-formatted format. If COMPRESS is set to contain the name
# of a compression command, the manpage will be compressed.
# EXTENSION is either '1' or 'man' to define whether the pre-formatted
# manpage or the source is to be installed. The name of the
# installed manpage always ends in '.1' (hard-coded).
#
# Here are some examples for LOCALMAN, COMPRESS and EXTENSION:
#
#	OS	LOCALMAN		COMPRESS	EXTENSION
#	---------------------------------------------------------
#	IRIX	/usr/local/man/cat1	pack -f		1
#	SVR4	/usr/share/man/cat1	-		1
#	Linux	/usr/local/man/man1	-		man
#
LOCALLIB = /usr/local/lib
LOCALBIN = /usr/local/bin
LOCALMAN = /usr/local/man/cat1

# Program to use for compressing the manpage.
# If set to 'true', no compression is applied.
#COMPRESS = pack -f
#COMPRESS = compress -f
COMPRESS = true

# Extension of the source to be installed as manpage.
# if it is set to '1', the pre-formatted format is used,
# if it is set to 'man', the source format is used.
#EXTENSION = man
EXTENSION = 1

# Location of the GD library and include files.
GDLIB	= /usr/local/lib/libgd.a
GDINC	= /usr/local/include

#
# Platform selection
# ------------------
#
# Select the platform in the Makefile, then see config.h for the actual macro
# definitions to be used on this platform. If you add/modify any compiler
# settings, please send them back to us together with a short description
# of the machine, the OS, and the C environment. Thank you very much!
#
# DEFINES defines the compiler options which are also passed to lint.
#
# PLATFORM are platform-specific compiler options not passed to lint.
#
# EXTRA_LIBS are any extra libraries needed on a certain platform.
#
# Suggested settings for DEFINES, PLATFORM and EXTRA_LIBS currently exist
# for IRIX, Unix System V, SunOS/Solaris, HP/UX, Linux, Windows NT, and
# Netware (not fully supported yet).

# OPTIM is now -g by default to include debugging information in the binary
#	to be able to reproduce stack backtraces in case of core dumps.
#	If you prefer optimization of the generated code, uncomment the
#	next line and comment out the -g definition.
#
OPTIM = -O2
#OPTIM = -g

# COMDEFS are definitions common to all platforms.
# Remove NDEBUG to include various assertion checks in the program.
COMDEFS = -DTIME_STATS -DNDEBUG

# Uncomment and/or modify the defines for the appropriate platform.
# All suggested configuration settings here have been tested except
# for the NETWARE platform.

# SGI IRIX
#
#DEFINES = -DIRIX $(COMDEFS)
#PLATFORM = -xansi

# SunOS/Solaris
#
# The gcc environment on SunOS sometimes lacks strerror() and
# other ANSI C functions for whatever reason. If you get errors
# from the linker about the missing function strerror, add
# -DNOT_REALLY_ANSI_C to the DEFINES below. Alternatively,
# download our binary for Solaris 2.5. We had absolutely no
# problems to compile it using gcc given the options below and
# the standard (unchanged) configuration setting in config.h.
#
#DEFINES = -DSUN $(COMDEFS)
#PLATFORM = -ansi -Dunix
#CC = gcc

# HP/UX
#
# Lacks definition of the 'unix' macro in it's compiler, so we
# define it here.
#
#DEFINES = -DHPUX $(COMDEFS)
#PLATFORM = -Ae -Dunix

# Unix System V.4
#
#DEFINES = -DSVR4 $(COMDEFS)
#PLATFORM = -Xa
#EXTRA_LIBS = -lucb

# Unix System V.3
#
#DEFINES = -DSVR3 $(COMDEFS)
#PLATFORM = 

# BSD and flavours
# Tested on FreeBSD so far
#
#DEFINES = -DBSD $(COMDEFS)
#PLATFORM = -ansi -Dunix
#CC = gcc

# Linux systems
#
#DEFINES = -Dlinux $(COMDEFS)
#PLATFORM = 
#CC = gcc

# Windows NT/Netware
#
#DEFINES = -DWIN32 $(COMDEFS)
#DEFINES = -DNETWARE $(COMDEFS)
#PLATFORM = 

# OS/2 with EMX
#
DEFINES = $(COMDEFS)
PLATFORM =
CC = gcc
GDLIB	= gd1.3/libgd.a
GDINC	= gd1.3

CFLAGS  = $(OPTIM) $(PLATFORM) $(DEFINES)
LDFLAGS	= -Zexe
LINT	= lint -Dunix -Xa -xu
LIBS	= -lm
#NROFF	= nroff
#NRFLAGS	= -u1 -man
NROFF	= groff
NRFLAGS	= -Wall -mtty-char -Tascii -man

HA_OBJ	= http-analyze.o images.o cntrycode.o utils.o vrml.o
HA_SRC	= http-analyze.c images.c cntrycode.c utils.c vrml.c
3D_OBJ	= 3Dstats.o utils.o vrml.o
3D_SRC	= 3Dstats.c utils.c vrml.c

TARGETS	= http-analyze http-analyze.1

all:	$(TARGETS)

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

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

3Dstats: $(3D_OBJ)
	$(CC) $(LDFLAGS) -o $@ $(3D_OBJ)

3Dstats.o: 3Dstats.c
	$(CC) $(CFLAGS) $(3D_DEFS) -c 3Dstats.c

vrml.o: vrml.c
	$(CC) $(CFLAGS) -c vrml.c

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

lint.out:	$(HA_SRC) config.h defs.h cntrycode.h
	$(LINT) $(DEFINES) -I$(GDINC) $(HA_SRC) >$@

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

http-analyze.o:	config.h defs.h cntrycode.h
3Dstats.o:	config.h defs.h
images.o:	config.h defs.h
cntrycode.o:	config.h defs.h cntrycode.h
utils.o:	config.h defs.h
vrml.o:		config.h defs.h

install:	$(TARGETS)
	cp http-analyze ha-setup $(LOCALBIN)
	cp http-analyze.$(EXTENSION) $(LOCALMAN)/http-analyze.1
	chmod 755 $(LOCALBIN)/http-analyze $(LOCALBIN)/ha-setup
	chmod 444 $(LOCALMAN)/http-analyze.1
	chown bin.bin $(LOCALBIN)/http-analyze $(LOCALBIN)/ha-setup
	$(COMPRESS) $(LOCALMAN)/http-analyze.1
	-mkdir -p $(LOCALLIB)/http-analyze/btn
	cp files/3D* files/TLD files/bugreport.html sample.conf $(LOCALLIB)/http-analyze/
	cp files/btn/* $(LOCALLIB)/http-analyze/btn/
	@echo "\nNow run 'ha-setup' to configure http-analyze for your server (Unix only).\n"


dist:	$(TARGETS) realclean
	rm -f ..\http-analyze-$(VERSION).zip
	rm -fR dist.dir
	mkdir dist.dir
	mkdir dist.dir\btn
	mv http-analyze.exe dist.dir
	cp http-analyze.pdf http-analyze.ps.gz readme readme.emx license order.* dist.dir
	cp http-analyze.$(EXTENSION) dist.dir/http-analyze.man
	cp files/3D* files/TLD files/bugreport.html sample.conf dist.dir
	copy /q files\btn\* dist.dir\btn
	zip -D src * files/* files/btn/*
	mv src.zip dist.dir
	cd dist.dir & zip -r ..\..\http-analyze-$(VERSION).zip *

clean:
	-rm -f $(HA_OBJ) $(3D_OBJ) lint.out

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

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

