# top_srcdir = @top_srcdir@
PART = xm

VPATH = $(top_srcdir)/$(PART)
@do_include@ $(top_srcdir)/$(PART)/Makefile.am
PERLXM = sh $(top_srcdir)/perlxm -I$(top_srcdir)
SUBDIRS = pfe code css doctype

DISTFILES = Makefile.am Makefile.in # because do_include has set EXTRA_DIST
CLEANFILES = *.xml *.html
doc docs : index.html
	@ for i in $(SUBDIRS) ; do $(MAKE) -C $$i $@ ; done

index.html : $(xm_PM:.pm=.html) Makefile.html 
$(xm_PM:.pm=.html) Makefile.html : index.xml 
index.xml : $(xm_PM:.pm=.xml) Makefile.xml
	@ echo '<title>PM List</title><ul>' >$@
	@ if test "_$(SUBDIRS)" != "_" ; then : \
	; SUBDIRS="$(SUBDIRS)" ; for i in $$SUBDIRS ; do : \
	; echo '<li><a href="'"$$i/index.html"'">'"$$i/*"'</a></li>' >>$@ \
	; done fi
	@ for i in $? ; do : \
	; echo '<li><CONTENT href="'`basename $$i .xml`.html'">' >>$@ \
	; echo `basename $$i .xml`'</CONTENT href></li>' >>$@ \
	; done
	@ echo '</ul>' >>$@
	$(PERLXM) $(XMFLAGS) xm::navheaderhrefsfromindex: $(DOCARG) $@

%.xml : %.pm
	@ echo $@ : $<
	@ $(PERLXM) $(XMFLAGS) xm::code::perl: $(DOCARG) -- $< \
	| $(PERLXM) $(XMFLAGS) xm::allpre: - >$@
%.xml : %.am
	@ echo $@ : $<
	@ $(PERLXM) $(XMFLAGS) xm::code::make: $(DOCARG) -- $< \
	| $(PERLXM) $(XMFLAGS) xm::allpre: - >$@

%.html : %.xml
	@ echo $@ : $<
	@ $(PERLXM) $(XMFLAGS) xm::css::mkhtml4:  $(DOCARG) \
	-- --ext=xml --css=$(top_srcdir)/doc/docbook.css $<