EXTRA_DIST=changelog.htm pstoedit.tex pstoedit.trans pstoedit.linux.prerequisites.md  
# Include these in dist tarball in case target does not have LaTeX (pdflatex) or latex2man.
# See "if DOCS" conditional below, and option ./configure --enable-docs=no
# which disables *regeneration* of docs, but not their installation.
EXTRA_DIST += pstoedit.pdf pstoedit.htm pstoedit.1 latex2man.local latex2man.css latex2man.cfg latex2man.sty
# a local version of latex2man is included since the last released version has some issues
# showing up when processing the pstoedit documentation.
#
man_MANS = pstoedit.1

doc_DATA = pstoedit.pdf pstoedit.htm changelog.htm 
## Unfortunately this is broken:
#info_TEXINFOS = pstoedit.texi

# Section for pstoedit documentation
# (adapted from `Makefile' in the latex2man package) 
# Rolf Niepraschk, niepraschk@ptb.de, 99/08/20
#

SUFFIXES = .htm .1 .tex .ps .info .texi .txt

all : alldoc
gendocs : alldoc

# This conditional guards use of the entire documentation generation
# subsystem, which involves LaTeX and latex2man and such.  If turned
# off, no attempt is made to generate them, instead the files in the
# distribution tarball are installed.
if DOCS
alldoc : pstoedit.1 pstoedit.htm pstoedit.pdf
P=../src/pstoedit

generalhelplong.tex: $P
	$P -doculong | grep -v "DLL interface" > $@

generalhelpshort.tex: $P
	$P -docushort | grep -v "DLL interface" > $@

driverhelp.tex: $P
	$P -dumphelp | grep -v "DLL interface" | sed -e 's/_/\\_/g' -e 's/>=/$>=$ /g' > $@

latex_src = pstoedit.tex version.tex generalhelplong.tex generalhelpshort.tex driverhelp.tex
latex2man_src = $(latex_src) pstoedit.trans

pstoedit.dvi : $(latex_src)
	$(LATEX) $<
	$(LATEX) $<

pstoedit.ps : pstoedit.dvi
	$(DVIPS) -Pwww -o $@ $<


pstoedit.pdf : $(latex_src)
	$(PDFLATEX) $<
	$(PDFLATEX) $<

## default rule works fine
# pstoedit.info : pstoedit.texi
# 	makeinfo $<

pstoedit.txt : pstoedit.1
	$(GROFF) -t -man -Tlatin1 $<    |	\
		sed -e 's/.//g' 	        \
		    -e 's/\[[0-9]*m//g'      	\
		    -e 's/7|//g' 	        \
		    -e 's/[6-9]//g' 	        \
		    -e 's///g'      	        \
		    -e 's/­$$/- /'      > $@

# TMP - until latex2man fixes go into mainstream
#
LATEX2MANLOCAL=./latex2man.local

pstoedit.1 : $(latex2man_src)
	$(LATEX2MANLOCAL) -t $(srcdir)/pstoedit.trans -M $< $@
	sed -e "s/ .PP/.PP/g" -i pstoedit.1

# fix some smaller issues in the pstoedit.htm file generated by latex2man
# to conform better with HTML checkers like tidy
# 1. insert a charset into header
# 2. add quotes to the "center" value
# 3. change HTML version
pstoedit.htm : $(latex2man_src)
	$(LATEX2MANLOCAL) -t $(srcdir)/pstoedit.trans -H $< $@
	sed -e 's,<head><title>,<head><meta http-equiv="content-type" content="text\/html; charset=UTF-8"><title>,' -i $@
	sed -e 's,align=center,align="center",' -i $@
	sed -e 's,HTML 3.2 Final,HTML 4.01 Transitional,' -i $@ 

pstoedit.texi : $(latex2man_src)
	$(LATEX2MANLOCAL) -t $(srcdir)/pstoedit.trans -T $< $@

pstoedit.rtf : pstoedit.1
	$(RMAN) -f RTF $< $@

MOSTLYCLEANFILES = pstoedit.aux pstoedit.log pstoedit.out pstoedit.dvi

CLEANFILES = pstoedit.ps pstoedit.pdf pstoedit.1 pstoedit.texi \
	  pstoedit.info pstoedit.txt pstoedit.rtf generalhelplong.tex \
	  generalhelpshort.tex driverhelp.tex
else
alldoc :
endif
