#-*- Makefile -*-
# Makefile for building docfiles

docfiles: FAQs

RPREFIX = $(shell perl fixed/rwver.pl ../../VERSION)
SED=sed
RVER = `cut -d' ' -f1 ../../VERSION | sed -n 1p`

SEDVER = -e s/@RVER@/$(RVER)/g -e s/@RWVER@/$(RPREFIX)/g

FAQs: rw-FAQ fixed/html/rw-FAQ.html

fixed/html/rw-FAQ.html: rw-FAQ.texi ../../VERSION
	@$(SED) $(SEDVER) $< > tmp.texi
	makeinfo --no-split --html --no-headers --number-sections -o tmp.html tmp.texi
	-tidy tmp.html > tmp2.html 2> /dev/null
	@if [ ! -s tmp2.html ] ; then \
	  echo "*** tidy appears to be non-functional ***" ; \
	  exit 111 ; \
	fi
	@mv -f tmp2.html $@
	@rm tmp.texi tmp.html

rw-FAQ: rw-FAQ.texi ../../VERSION
	$(SED) $(SEDVER) $< | \
	  makeinfo --no-headers --number-sections -o $@