HTMLS:=
XSLT:=xsltproc

#argument is (1) an xml file to be validated
#result is a validated xml file of extension "xmllint"
define LINTXMLFILE
 $(patsubst %.xml,%.xmllint,$(1))
endef

#argument is (1) an xml file to be published as html
#result is a rule to make the html file from a validated version of arguemnt (1)
#side effect is the appendation of the html file to the (HTMLS) list
#alt version of last line        $(XSLT) --nonet -o $@ xml/alpha/html.xsl $<
define HTMLDEPRULE
 override $(TMPHTML):=$(patsubst %.xmllint,%.html,$(1))
 HTMLS+=$(TMPHTML)
 $(TMPHTML) : $(1)
	$(XSLT) --nonet -o $(TMPHTML) html.xsl $(1)
endef

#look for *.book.xml underneath CURDIR
BOOKS:=$(addprefix $(CURDIR),$(shell find . -type f -name "*.book.xml" -print | sed 's/^\.//'))

#here is the function that writes rules for creating each book
#AFAIK, this function call can't be replaced by implict rules
#in the regular version (not this one):
#the rules depend on a shell call that determines the (one to many) relationship
#between the (Docbook) xml source files and their chunked html outputs
$(warning $(BOOKS))
$(foreach SOURCEFILE,$(BOOKS),$(eval $(call HTMLDEPRULE,$(call LINTXMLFILE,$(SOURCEFILE)))))
$(warning $(HTMLS))

.PHONY : all clean

all : HTML

HTML : $(HTMLS)

#implicit rule to create validated xml files
%.xmllint : %.xml
	xmllint --xinclude --nonet --postvalid $< > $@

clean :
	-rm $(HTMLS)
