#
# Makefile for http-analyze
#
# $Id: Makefile,v 2.4.1.3 1999/11/02 16:30:19 stefan Exp stefan $

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

# Local conventions
# -----------------
#
# HA_BINDIR	is the directory where the executable is installed.
# HA_LIBDIR	is the directory where the required files are installed.
#
HA_BINDIR = /usr/local/bin
HA_LIBDIR = /usr/local/lib/http-analyze

# Required libraries
# ------------------
#
# REQINCS	location of the include files for library functions.
# REQLIBS	location of the required libraries.
#
REQINCS	= -I/usr/local/include
REQLIBS	= -L/usr/local/lib -lgd -lpng -lz

# Platform selection
# ------------------
#
# Select the platform below to include the actual macro definitions for
# this platform in the file config.h. The default settings in config.h
# should work fine if your platform is selected below.
#
# OPTIM		is set to optimization by default. If you experience
#		core dumps, you might want to change this to -g to
#		view a stack backtrace with the debugger.
# DEFINES	contains compiler options which are also passed to lint.
# PLATFORM	contains platform-specific options not passed to lint,
#		but to the loader.
# COMDEFS	are definitions common to all platforms. Remove NDEBUG
#		to include various assertion checks in the program.
# EXTRA_LIBS	are extra libraries needed on certain platforms.
#
COMDEFS   = -DTIME_STATS -DNDEBUG -DHA_LIBDIR=\"$(HA_LIBDIR)\"

# SGI IRIX 6.2 MipsPRO Compilers
# Congratulations! You're using one of the best platforms for porting SW.
#
#DEFINES  = -DIRIX
#
# for the mips-3 ABI:
#OPTIM    = -O2 -OPT:Olimit=2580
#PLATFORM = -n32 -xansi
#
# or for the mips-2 ABI:
#OPTIM    = -O2 -Olimit 1270
#PLATFORM = -o32 -xansi

# SunOS 4.x/Solaris 2.x.
# Note: On SunOS 4.x you will need to define -DNOT_REALLY_ANSI_C
# to include an own strerror() functions which is missing from the
# standard C library on SunOS.
#
#DEFINES  = -DSUN -Dunix
#OPTIM    = -O2
#PLATFORM = -ansi
#CC       = gcc

# AIX 4.2
#
#DEFINES  = -DAIX -Dunix
#OPTIM    = -O
#PLATFORM =

# DIGITAL UNIX V4.0
#
#DEFINES  = -DDEC -Dunix
#OPTIM    = -O
#PLATFORM = -newc

# HP/UX 10.20
#
#DEFINES  = -DHPUX -Dunix
#OPTIM    = -O
#PLATFORM = -Ae

# Linux flavours
#
#DEFINES  = -Dlinux -Dunix
#OPTIM    = -O2
#PLATFORM = 
#CC       = gcc

# SCO 3.2
#
#DEFINES  = -DSCO
#OPTIM    = -O
#PLATFORM =

# BSD/OS 3.0 and FreeBSD 2.2.6-RELEASE
#
#DEFINES  = -DBSD -Dunix
#OPTIM    = -O2
#PLATFORM =
#CC       = gcc

# AT&T (vanilla) Unix System V.4
#
#DEFINES  = -DSVR4
#OPTIM    = -O2
#PLATFORM = -Xa
#EXTRA_LIBS = -lucb

# AT&T (vanilla) Unix System V.3
#
#DEFINES  = -DSVR3
#OPTIM    = -O
#PLATFORM = 

# BeOS
#
#DEFINES  = -DBEOS -Dunix
#OPTIM    = -O
#PLATFORM = -relax_pointers

# Windows NT/Netware
#
#DEFINES = -DWIN32
#DEFINES = -DNETWARE
#PLATFORM = 

CFLAGS  = $(PLATFORM) $(OPTIM) $(DEFINES) $(COMDEFS)
LIBS	= $(REQLIBS) $(EXTRALIBS) -lm
LINT	= lint -k -Dunix -Xa -xu
NROFF	= nroff
NRFLAGS	= -u1 -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

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

http-analyze.o:	http-analyze.c config.h defs.h patchlevel.h
	$(CC) $(CFLAGS) -c http-analyze.c

cntrycode.o: cntrycode.c cntrycode.h config.h defs.h
	$(CC) $(CFLAGS) -c cntrycode.c

utils.o: utils.c config.h defs.h
	$(CC) $(CFLAGS) -c utils.c

vrml.o: vrml.c config.h defs.h
	$(CC) $(CFLAGS) -c vrml.c

images.o:	images.c config.h defs.h
	$(CC) $(CFLAGS) -c $(REQINCS) images.c

lint.out:	$(HA_SRC) config.h defs.h cntrycode.h patchlevel.h
	$(LINT) $(DEFINES) $(REQINCS) $(HA_SRC) >$@

# Uncomment next lines only if you have the nroff/troff typesetting
# package installed at your site. It's o.k. to use the pre-formatted
# manual page included in this package. See also NROFF and NRFLAGS.
#
#http-analyze.1:	http-analyze.man
#	$(NROFF) $(NRFLAGS) http-analyze.man | col >$@

install:	http-analyze
	@echo "Installing http-analyze in $(HA_BINDIR)"
	if test ! -d $(HA_BINDIR); then mkdir -p $(HA_BINDIR); \
	elif test -f $(HA_BINDIR)/http-analyze; then \
		mv -f $(HA_BINDIR)/http-analyze $(HA_BINDIR)/http-analyze.O; \
	fi
	cp http-analyze $(HA_BINDIR)
	-chmod 755 $(HA_BINDIR)/http-analyze
	-chgrp bin $(HA_BINDIR)/http-analyze && chown bin $(HA_BINDIR)/http-analyze
	@echo "\nInstalling buttons and files in $(HA_LIBDIR)"
	if test ! -d $(HA_LIBDIR); then \
		mkdir -p $(HA_LIBDIR); \
	else	rm -rf $(HA_LIBDIR).O; \
		mv $(HA_LIBDIR) $(HA_LIBDIR).O; \
		mkdir $(HA_LIBDIR); \
	fi
	(cd ../files; cp 3D* TLD bugreport.html $(HA_LIBDIR); \
	 for i in btn btn-*; do \
		if test ! -d $(HA_LIBDIR)/$$i; then mkdir $(HA_LIBDIR)/$$i; fi; \
		cp $$i/* $(HA_LIBDIR)/$$i; \
	done)
	if test -f $(HA_LIBDIR).O/REGID; then \
		cp $(HA_LIBDIR).O/REGID $(HA_LIBDIR)/REGID; \
		if test -f $(HA_LIBDIR).O/btn/netstore_sw.gif; then \
		    cp $(HA_LIBDIR).O/btn/netstore_s[wb].gif $(HA_LIBDIR)/btn; \
		fi; \
	fi

clean:
	-rm -f $(HA_OBJ)

realclean:	clean
	-rm -f core http-analyze lint.out

