# $Id: Makefile,v 1.2 1998/05/10 06:01:40 mhpower Exp $

# tools
SHELL = /bin/sh
CC = gcc
COPTS = -Wall -O -g
RM = rm -f
INSTALL = ginstall
PROGINSTALL = -s -c -m 755
FILEINSTALL = -c -m 644

# C defines
CONFIG = -DDEBUG -DBACKGROUND
DEFINES = -DPOSIX_SOURCE  -DPROGNAME=\"diswww\" $(CONFIG)

## configuration parameters
# server hostname (for mail and backward HTTP links)
HOST = www.mit.edu
# port for the server
PORT = 8008
# file accessed as "http://server:port/"
INDEX = index.html
# maintainers' e-mail address
WEBM = webmaster@$(HOST)

# paths
INCPATH = -I/usr/athena/include
LIBPATH = -L/usr/athena/lib

# where the stuff is getting installed
DESTDIR = /var/local/diswww
FILESDIR = $(DESTDIR)/files

# if your machine has the bad luck of running Solaris, you'll need this...
# EXTRALIBS = -lsocket -lnsl -lc -lucb -lelf -ldl

# with Kerberized Discuss:
DSLIBS    = -ldsk -lkrb -ldes -lusp -lcom_err
# with non-Kerberized Discuss, try something like
# DSLIBS    = -lds -lusp -lcom_err

### Nothing after this point should need to be changed.  I hope.  =)

# configuration defines
CONFDEF=-DSRV_ROOT_DIR=\"$(FILESDIR)\" \
	-DSRV_PORT=$(PORT) \
	-DSRV_SELF=\"\" \
	-DSRV_DISWWW=\"http://$(HOST):$(PORT)\" \
	-DSRV_WEBMASTER=\"$(WEBM)\" \
	-DSRV_INDEX=\"$(INDEX)\"

CFLAGS  = $(COPTS) $(INCPATH) $(DEFINES) $(CONFDEF)
LDFLAGS = $(LIBPATH)

# the files we're making
SOURCES = main.c signal.c talk.c stuff.c dsread.c thttp.c quote.c
OBJECTS = main.o signal.o talk.o stuff.o dsread.o thttp.o quote.o
HEADERS = extern.h proto.h status.h version.h

### rules
all:: TAGS diswww

TAGS: $(HEADERS) $(SOURCES)
	etags $(HEADERS) $(SOURCES)

diswww:  $(OBJECTS)
	$(CC) -o diswww $(OBJECTS) $(LDFLAGS) $(DSLIBS) $(EXTRALIBS)

clean::
	$(RM) diswww $(OBJECTS) TAGS core *~

$(DESTDIR)::
	-mkdir $(DESTDIR)

install:: $(DESTDIR)
	$(INSTALL) $(PROGINSTALL) diswww $(DESTDIR)

# subdirectory rules
all::
	cd files; $(MAKE) $(MFLAGS) FILESDIR='$(FILESDIR)' all
install::
	cd files; $(MAKE) $(MFLAGS) FILESDIR='$(FILESDIR)' install
clean::
	cd files; $(MAKE) $(MFLAGS) FILESDIR='$(FILESDIR)' clean
