# Makefile for timesheet documentation

# significant SGML files
SGMLFILES	:= install.sgml operations.sgml releasetests.sgml
WWWTARGETS	:= $(SGMLFILES:.sgml=.html) $(SGMLFILES:.sgml=.txt)
SGML_VALIDATE	:= nsgmls -E0 -gues

# destination for documentation
DESTDIR		:= /usr/local/doc/onshore-timesheet
# how to install
INSTALL		:= install -o root -g root -m 0644
# script for creating test data in SGML table format
RELTEST		:= ./reltests.pl
SQL2SGML	:= ./sql2sgml.pl
SQL_IN		:= ../db/tables.sql
FRAGMENTS	:= tests.ent datadict.ent

.PHONY: default
default:	$(WWWTARGETS)

.PHONY: wwwdist
wwwdist:	default

# preheat is a system we use to create Makefile targets
-include Makefile.docs

Makefile.docs: Makefile.docs.in
	preheat -o $@ $<

tests.ent:
	$(RELTEST) tests.in > tests.ent

datadict.ent:
	$(SQL2SGML) $(SQL_IN) > datadict.ent

install:
	$(INSTALL) *.html *.txt $(DESTDIR)

# validate our SGML files
.PHONY: validate
validate:	$(FRAGMENTS)
	@for file in $(SGMLFILES); do				 	 \
		echo "validating $$file"				;\
		$(SGML_VALIDATE) $$file					;\
		echo							;\
	done

.PHONY: distclean
distclean:	clean
	rm -f Makefile.docs

.PHONY: clean
clean:	preheat-clean
	rm -f tests.ent
	rm -f datadict.ent
	rm -f *~ *.bak *.log
	rm -f *.html *.txt
	rm -rf operations install

