-VPATH=src
+# Inspired by "Recursive Make: Reloaded" in the July, 2005 issue
+# of Linux Magazine, I've reworked the Makfiles so that they're no
+# longer recursive.
-.SUFFIXES: .rnc .rng .rnx .dtx .dtd
-.PHONY: tests html
+# Fair warning, this is a bit more complex than is maybe ideal, but it
+# works and it isn't recursive. I still need to get the documentation
+# build into the new system.
+
+include ../../../cvstools/Makefile.incl
+
+XSLTPROC=xsltproc
+PERL=perl
+MV ?= mv
+
+CLASS=wd
+VERSION=5.0b4
+SPECNAME=$(CLASS)-docbook-docbook-$(VERSION)
-DOCBOOK=../docbook
TOOLS=../tools
-RNGFILES=$(wildcard build/*.rng)
-
-all: sdocbook.rng sdocbook.dtd
-
-# ============================================================
-#
-# N.B. We need an explicit dependency on src/*.rnc for each *.rng
-# file because the build process produces an *output* RNC file
-# in the current directory and that's not the one we want to
-# depend on.
-#
-# That's also the reason for the curious sleep/touch pattern
-# in the build rules. We want to make sure that the output RNC
-# file is older than the output RNG file so that make doesn't
-# always think it needs to rebuild the RNG file.
-#
-# If we could take "." out of VPATH, we wouldn't need to do this.
-
-sdocbook.rng: src/sdocbook.rnc
-
-.rnc.rng:
- $(MAKE) -C build $@
- perl $(TOOLS)/trimgrammar.pl -o ,$@ build/$@
- saxon ,$@ $(TOOLS)/trimgrammar.xsl $@ use.extensions=1
- trang $@ `basename $<`
- sleep 2
- touch $@
- rm -f ,$@
-
-.rng.rnx:
- xsltproc -output $@ $(TOOLS)/rngdocxml.xsl $<
-
-.rnx.dtx:
- xsltproc -output $@ $(TOOLS)/doc2dtd.xsl $<
-
-.dtx.dtd:
- xsltproc -output $@ $(TOOLS)/xml2dtd.xsl $<
-
-# ============================================================
-
-clean:
- rm -f sdocbook*
+AUGMENT=$(TOOLS)/augment.xsl
+INCLUDE=$(TOOLS)/include.xsl
+CLEANUP=$(TOOLS)/cleanup.pl
+
+.PHONY: all
+
+all::
+_OUTTOP ?= .
+_OUTTOP := $(_OUTTOP)/build
+
+DISTRIB=$(_OUTTOP)/docbook-$(VERSION)
+
+.PHONY: clean
+
+clean:: ; rm -rf $(_OUTTOP)
+
+.SUFFIXES:
+
+MODULES=sdocbook
+
+include $(addsuffix /Makefile,$(MODULES))
+
+.PHONY: tests
+
+distrib:
+ echo not working yet
+
+#distrib: docbook.dtd docbook.rng docbook.rnc docbook.sch \
+# docbookxi.rng docbookxi.rnc docbook.xsd
+# $(MAKE) -C howto
+# $(MAKE) -C spec
+# rm -rf $(DISTRIB)
+# mkdir -p $(DISTRIB)/{rng,dtd,xsd,sch,docs,tools}
+# mkdir $(DISTRIB)/docs/images
+# echo $(VERSION) > $(DISTRIB)/VERSION
+# cp docbook.{rng,rnc} docbookxi.{rng,rnc} $(DISTRIB)/rng/
+# cp docbook.dtd $(DISTRIB)/dtd/
+# cp docbook.sch $(DISTRIB)/sch/
+# trang docbook.dtd $(DISTRIB)/xsd/docbook.xsd
+# grep -v "xs:import" $(DISTRIB)/xsd/xlink.xsd > $(DISTRIB)/xsd/,xlink.xsd
+# mv $(DISTRIB)/xsd/,xlink.xsd $(DISTRIB)/xsd/xlink.xsd
+# grep -v "xs:import" $(DISTRIB)/xsd/xml.xsd > $(DISTRIB)/xsd/,xml.xsd
+# mv $(DISTRIB)/xsd/,xml.xsd $(DISTRIB)/xsd/xml.xsd
+# cp howto/howto.xml howto/howto.html howto/howto.pdf $(DISTRIB)/docs/
+# cp howto/images/*.png $(DISTRIB)/docs/images/
+# cp spec/docbook.xml $(DISTRIB)/docs/$(SPECNAME).xml
+# cp spec/docbook.html $(DISTRIB)/docs/$(SPECNAME).html
+# cp spec/docbook.pdf $(DISTRIB)/docs/$(SPECNAME).pdf
+# saxon -8b ../tools/catalog.xsl ../tools/catalog.xsl $(DISTRIB)/catalog.xml version=$(VERSION)
+# cp ../tools/db4-upgrade.xsl $(DISTRIB)/tools/
+# cp ../tools/db4-entities.pl $(DISTRIB)/tools/
+# cp README $(DISTRIB)/
--- /dev/null
+# -*- Makefile -*-
+
+$(_MODULE)_OBJS := $(addsuffix .rng,$(addprefix $($(_MODULE)_OUTPUT)/,$(basename $(SRCS))))
+
+$(_MODULE)_BINARY := $($(_MODULE)_OUTPUT)/$(BINARY)
+
+.PRECIOUS: $($(_MODULE)_OBJS)
+
+$($(_MODULE)_OUTPUT)/%.rng: $(_MODULE)/%.rnc $($(_MODULE)_OUTPUT)/.f
+ $(RUNTRANG) $< $@
+
+$($(_MODULE)_OUTPUT)/%.rnx: $($(_MODULE)_OBJS) $($(_MODULE)_OUTPUT)/.f
+ $(XSLT) $< $(INCLUDE) $@, use.extensions=1
+ $(XSLT) $@, $(AUGMENT) $@ use.extensions=1
+ $(PERL) $(CLEANUP) $@ > $@,
+ $(MV) $@, $@
+
+#$($(_MODULE)_OUTPUT)/%.rng: $(_MODULE)/%.rnc $($(_MODULE)_OUTPUT)/.f
+# $(RUNTRANG) $< $@
+#
+#$($(_MODULE)_OUTPUT)/%.rng: $($(_MODULE)_OBJS) $($(_MODULE)_OUTPUT)/.f
+# @echo build $< $@
+# $(XSLT) $< $(INCLUDE) $@, use.extensions=1
+# $(XSLT) $@, $(AUGMENT) $@ use.extensions=1
+# $(PERL) -i $(CLEANUP) $@
+# $(RM) $@,
+
+#$($(_MODULE)_OUTPUT)/%.rnx: $($(_MODULE)_OUTPUT)/%.rne
+# $(XSLT) $< $(INCLUDE) $@, use.extensions=1
+# $(XSLT) $@, $(AUGMENT) $@ use.extensions=1
+# $(PERL) -i $(CLEANUP) $@
+# $(RM) $@,
+
+$($(_MODULE)_OUTPUT)/%.rnd: $($(_MODULE)_OUTPUT)/%.rnx
+ $(XSLTPROC) -output $@ $(TOOLS)/rngdocxml.xsl $<
+
+$($(_MODULE)_OUTPUT)/%.dtx: $($(_MODULE)_OUTPUT)/%.rnd
+ $(XSLTPROC) -output $@ $(TOOLS)/doc2dtd.xsl $<
+
+all:: $($(_MODULE)_BINARY)
+
+$(_MODULE): $($(_MODULE)_BINARY)
--- /dev/null
+include _header.mak
+
+REMOVESCHEMATRON=0
+
+SRCS = sdocbook.rnc
+
+BINARY = sdocbook.rnd
+
+all:: sdocbook.rng sdocbook.rnc sdocbook.dtd sdocbook.sch sdocbook.xsd
+
+clean:: ; rm -f sdocbook.rng sdocbook.rnc sdocbook.dtd sdocbook.sch *.xsd
+
+$(_OUTTOP)/sdocbook/sdocbook.rng: sdocbook/sdocbook.rnc \
+ ../docbook/src/hier.rnc \
+ ../docbook/src/bibliography.rnc \
+ ../docbook/src/calstbl.rnc \
+ ../docbook/src/htmltbl.rnc \
+ ../docbook/src/pool.rnc
+
+include _footer.mak
+
+sdocbook.rng: $(basename $(sdocbook_BINARY)).rnx
+ $(XSLTPROC) --param remove-schematron $(REMOVESCHEMATRON) --output $@ $(TOOLS)/removedoc.xsl $<
+
+sdocbook.rnc: sdocbook.rng
+ $(RUNTRANG) $< $@
+
+sdocbook.dtd: $(basename $(sdocbook_BINARY)).dtx sdocbook.rnc
+ $(XSLTPROC) -output $@ $(TOOLS)/xml2dtd.xsl $<
+
+sdocbook.sch: $(basename $(sdocbook_BINARY)).rnx
+ $(XSLTPROC) --output $@ $(TOOLS)/schematron.xsl $<
+
+sdocbook.xsd: sdocbook.dtd
+ $(RUNTRANG) $< $@
+