
FORMATS=${addprefix xml.,pdf html info txt}

DVIPS= @DVIPS@
MAKEINFO= @MAKEINFO@
TEXI2DVI= @TEXI2DVI@
TEX= @TEX@

all: ${FORMATS} clean
all_check: examples all

examples: force
	cd sax; gnatmake -q -Pdefault
	cd dom; gnatmake -q -Pdefault
	cd schema; gnatmake -q -Pdefault

%.dvi: %.texi
ifneq (${TEX},)
	-echo x | ${TEX} $<
	-texindex ${<:%.texi=%.cp}
	-echo x | ${TEX} $<
else
	@echo "---------------------------------------------------"
	@echo "tex not found, cannot build DVI or PS documentation"
	@echo "---------------------------------------------------"
endif

%.ps: %.dvi
ifneq (${DVIPS},)
	-dvips -o $@ $<
else
	@echo "------------------------------------------------------"
	@echo "dvips not found, cannot build POSTSCRIPT documentation"
	@echo "------------------------------------------------------"
endif

%.pdf: %.texi
ifneq (${TEXI2DVI},)
	@echo x | ${TEXI2DVI} -p $<
else
	@echo "--------------------------------------------------"
	@echo "texi2dvi not found, cannot build PDF documentation"
	@echo "--------------------------------------------------"
endif

%.html: %.texi
ifneq (${MAKEINFO},)
	-${MAKEINFO} --html --no-split --css-include=xml.css $<
else
	@echo "----------------------------------------------------"
	@echo "texi2html not found, cannot build HTML documentation"
	@echo "----------------------------------------------------"
endif

%.info: %.texi
ifneq (${MAKEINFO},)
	-${MAKEINFO} $<
else
	@echo "---------------------------------------------------"
	@echo "makeinfo not found, cannot build INFO documentation"
	@echo "---------------------------------------------------"
endif

%.txt: %.texi
ifneq (${MAKEINFO},)
	-${MAKEINFO} -o $@ --number-sections $<
else
	@echo "---------------------------------------------------"
	@echo "makeinfo not found, cannot build TEXT documentation"
	@echo "---------------------------------------------------"
endif

clean: force
	@${RM} *.cp
	@${RM} *.aux
	@${RM} *.cps
	@${RM} *.fn
	@${RM} *.ky
	@${RM} *.log
	@${RM} *.pg
	@${RM} *.toc
	@${RM} *.tp
	@${RM} *.vr

clean_all: clean
	@${RM} ${FORMATS} *.html

force:
