#
# Makefile:
# Top-level Makefile for web site.
#
# This contains the top-level directives and options, as well as stuff for the
# root directory of the site.
#
# $Id: Makefile,v 1.26 2004/06/23 20:07:00 chris Exp $
#

#
# Options
#
export	# export variables to sub-makes

#
# Global definitions
#
OUTPUT = $(shell test -d ../output || mkdir ../output ; cd ../output ; pwd)

generic_makefile = $(shell echo "`pwd`/Makefile.generic")

# Makefile.defs should define LOCAL_TARGET, the `staging server' for this
# machine, and REMOTE_TARGET, the remote machine. Makefile.defs MUST NOT be in
# CVS.
include Makefile.defs

#
# Programs
#
RSYNC = /software/bin/rsync -r --rsh=/usr/bin/ssh --rsync-path=/software/bin/rsync --stats -p

#
# Stuff for this directory
#
WWW_PATH = /
FILES = index.html links.html html.html design.html future.html moral.html \
        anneal.f90.html ucam.chat-May-23-1999.html books.html \
        search-report-expln.html practical-knowledge-for-all.jpg \
        self-portrait.jpg Makefile Makefile.generic software.html loch.jpg \
        src.jpg cliff.jpg bulldozer.jpg toad.jpg gpgkey.html GPL.txt \
        xface.png dancing.jpg photos.html sitemap.html software-toc.html \
        email.html

SUBDIRS = fiction images stuff status-example www.inactive.demon.co.uk \
          vmail-sql tlsproxyd tpop3d sucks openssh-patches silly xdata \
          random driftnet vpn-udp wtd ngml factlets scripts wwwitter \
          consolidate

#
# Top-level rules: install the stuff, clean the directories, etc.
#
install: pages subdirs
	rm -f sitemap.html software-toc.html
	make sitemap.html software-toc.html
	@echo -- installing pages to local $(LOCAL_TARGET)
	$(RSYNC) $(OUTPUT)/ $(LOCAL_TARGET)

remote:	all
	@echo -- installing pages to remote $(REMOTE_TARGET)
	$(RSYNC) -v $(OUTPUT)/ $(REMOTE_TARGET)

#
# Generic rules: create the pages for this directory and its
# subdirectories.
#

include $(generic_makefile)

clean:
	@echo -- Removing junk
	rm -vf `find . -name \*~ -or -name \*% -or -name \*.bak -or -name pages`

nuke: clean
	@echo -- Removing output tree
	rm -rf $(OUTPUT)

#
# Rules for constructing files in this directory
#

# The links page (links.html)
links.html:	links/head.html links/body.html links/tail.html links/data
	make -C links body.html
	cat links/head.html links/body.html links/tail.html > links.html

gpgkey.html:    gpgkey.html.head gpgkey.html.tail ~/.gnupg/pubring.gpg
	gpg --export --armor chris@ex-parrot.com | cat gpgkey.html.head - gpgkey.html.tail > gpgkey.html

# Site map
sitemap.html:   sitemap.head.html sitemap.tail.html FORCE
	./sitemap | cat sitemap.head.html - sitemap.tail.html > sitemap.html

# Software ToC
software-toc.html:  software-toc.head.html software-toc software-toc.tail.html FORCE
	./makesoftwaretoc | cat software-toc.head.html - software-toc.tail.html > software-toc.html

FORCE:
