#
#   userver -- a fairly simple web server designed for experimentation.
#   Copyright (C) 2003  Hewlett-Packard Company
#   Contributed by Tim Brecht <brecht@cs.uwaterloo.ca>
#   Partially based on servers by: 
#      David Mosberger <david.mosberger@hp.com> and
#      Abhishek Chandra <abhishek@cs.umass.edu>
#   See AUTHORS file for list of contributions.
#
#   This file is part of userver, a simple web server designed for
#   performance experiments.
#
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License as
#   published by the Free Software Foundation; either version 2 of the
#   License, or (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#   General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
#   02111-1307 USA
#


include Makefile.base

MAKE-GPROF      = Makefile.gprof
MAKE-NOGPROF    = Makefile.nogprof
MAKE-SEND       = Makefile.send
MAKE-SEND-GPROF = Makefile.send-gprof
BIN             = $(HOME)/bin

PGMS =  userver userver-gprof userver-send

cur: userver
# cur: userver-send

all: userver man

man: userver.txt userver.ps userver.pdf userver.html

userver.txt: userver.1
	groff -man -Tascii userver.1 > userver.txt

userver.ps: userver.1
	groff -man -Tps userver.1 > userver.ps

userver.pdf: userver.ps
	ps2pdf userver.ps userver.pdf

userver.html: userver.1
	man2html userver.1 > userver.html

os: FORCE
	echo os = $(OS)

userver-gprof: FORCE
	$(MAKE) -f $(MAKE-GPROF) userver-gprof

userver-send: FORCE
	$(MAKE) -f $(MAKE-SEND) userver-send

userver-send-gprof: FORCE
	$(MAKE) -f $(MAKE-SEND-GPROF) userver-send-gprof

predepend:
	touch .depend

depend: predepend userver-depend

userver-depend: predepend FORCE
	$(MAKE) -f $(MAKE-NOGPROF) userver-depend

userver-send-depend: FORCE
	$(MAKE) -f $(MAKE-SEND) userver-send-depend

userver: FORCE
	$(MAKE) -f $(MAKE-NOGPROF) userver

install: FORCE
	mv $(PGMS) $(BIN)

clean: FORCE
	rm -f *.o

vclean: FORCE
	-rm -f *.o $(PGMS) core .depend events.out
	-rm -f userver.ps userver.pdf userver.txt userver.html

ctags: FORCE
	ctags *.[ch]

tags: FORCE
	ctags *.[ch]

DIST_VER  = 0.3.2
DIST_NAME = userver-$(DIST_VER)
DIST_DEST = ../$(DIST_NAME)
SCRIPTS_DEST = ../$(DIST_NAME)/scripts
TESTS_DEST = ../$(DIST_NAME)/docs

dist: userver.txt userver.ps userver.pdf userver.html
	-mkdir $(DIST_DEST)
	-mkdir $(SCRIPTS_DEST)
	-mkdir $(TESTS_DEST)
	cp -p $(DIST_LIST) $(DIST_DEST)
	cp -p $(SCRIPTS) $(SCRIPTS_DEST)
	cp -p $(TESTDOCS) $(TESTS_DEST)
	csh -c "cd .. ; pwd ; tar -czf $(DIST_NAME).tar.gz $(DIST_NAME)/"

updist:
	scp CHANGELOG bcr2.uwaterloo.ca:www/userver/src/CHANGELOG-$(DIST_VER).txt
	scp ../$(DIST_NAME).tar.gz bcr2.uwaterloo.ca:www/userver/src
	ssh bcr2.uwaterloo.ca 'chmod a+r www/userver/src/*'

# upindex:
#  	scp index.html bcr2:www/userver/src

FORCE:

