From c8eadc33695d4bf8b974a43f9db0c19fa14ea273 Mon Sep 17 00:00:00 2001
From: Gabor Kovesdan <gabor@FreeBSD.org>
Date: Sun, 31 Mar 2013 21:11:07 +0000
Subject: [PATCH] Always build pdf from ps and remove related nits. This is
 what was already done with Handbook and building pdf directly does not seem
 to work correctly anyway. This change will help simplifying the build process
 and spare some image conversions.

---
 de_DE.ISO8859-1/books/handbook/Makefile  |  1 -
 el_GR.ISO8859-7/books/handbook/Makefile  |  1 -
 en_US.ISO8859-1/books/handbook/Makefile  |  1 -
 es_ES.ISO8859-1/books/handbook/Makefile  |  1 -
 fr_FR.ISO8859-1/books/handbook/Makefile  |  1 -
 hu_HU.ISO8859-2/books/handbook/Makefile  |  1 -
 it_IT.ISO8859-15/books/handbook/Makefile |  1 -
 ja_JP.eucJP/books/handbook/Makefile      |  1 -
 mn_MN.UTF-8/books/handbook/Makefile      |  1 -
 nl_NL.ISO8859-1/books/handbook/Makefile  |  1 -
 pl_PL.ISO8859-2/books/handbook/Makefile  |  1 -
 pt_BR.ISO8859-1/books/handbook/Makefile  |  1 -
 ru_RU.KOI8-R/books/handbook/Makefile     |  1 -
 share/mk/doc.docbook.mk                  | 45 +++---------------------
 zh_CN.GB2312/books/handbook/Makefile     |  1 -
 zh_TW.Big5/books/handbook/Makefile       |  1 -
 16 files changed, 4 insertions(+), 56 deletions(-)

diff --git a/de_DE.ISO8859-1/books/handbook/Makefile b/de_DE.ISO8859-1/books/handbook/Makefile
index 5787f7d20e..d3775164db 100644
--- a/de_DE.ISO8859-1/books/handbook/Makefile
+++ b/de_DE.ISO8859-1/books/handbook/Makefile
@@ -23,7 +23,6 @@ DOC?= book
 FORMATS?= html-split
 
 HAS_INDEX= true
-USE_PS2PDF= yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/el_GR.ISO8859-7/books/handbook/Makefile b/el_GR.ISO8859-7/books/handbook/Makefile
index 8038073aa3..fe5f159acd 100644
--- a/el_GR.ISO8859-7/books/handbook/Makefile
+++ b/el_GR.ISO8859-7/books/handbook/Makefile
@@ -44,7 +44,6 @@ DOC?=		book
 FORMATS?=	html-split
 
 HAS_INDEX=	true
-USE_PS2PDF=	yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/en_US.ISO8859-1/books/handbook/Makefile b/en_US.ISO8859-1/books/handbook/Makefile
index 5f31dca821..65e6220067 100644
--- a/en_US.ISO8859-1/books/handbook/Makefile
+++ b/en_US.ISO8859-1/books/handbook/Makefile
@@ -40,7 +40,6 @@ DOC?= book
 FORMATS?= html-split
 
 HAS_INDEX= true
-USE_PS2PDF=	yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/es_ES.ISO8859-1/books/handbook/Makefile b/es_ES.ISO8859-1/books/handbook/Makefile
index 4b13f0b455..96f6a5e7fa 100755
--- a/es_ES.ISO8859-1/books/handbook/Makefile
+++ b/es_ES.ISO8859-1/books/handbook/Makefile
@@ -37,7 +37,6 @@ DOC?= book
 FORMATS?= html-split
 
 HAS_INDEX= true
-USE_PS2PDF=	yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/fr_FR.ISO8859-1/books/handbook/Makefile b/fr_FR.ISO8859-1/books/handbook/Makefile
index 7547f19f3f..e19bd2cc04 100644
--- a/fr_FR.ISO8859-1/books/handbook/Makefile
+++ b/fr_FR.ISO8859-1/books/handbook/Makefile
@@ -34,7 +34,6 @@ DOC?= book
 FORMATS?= html-split
 
 HAS_INDEX= true
-USE_PS2PDF=	yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/hu_HU.ISO8859-2/books/handbook/Makefile b/hu_HU.ISO8859-2/books/handbook/Makefile
index 5096c38eb2..abc2388059 100644
--- a/hu_HU.ISO8859-2/books/handbook/Makefile
+++ b/hu_HU.ISO8859-2/books/handbook/Makefile
@@ -45,7 +45,6 @@ DOC?= book
 FORMATS?= html-split
 
 HAS_INDEX= true
-USE_PS2PDF=	yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/it_IT.ISO8859-15/books/handbook/Makefile b/it_IT.ISO8859-15/books/handbook/Makefile
index ac5c446808..185b307110 100644
--- a/it_IT.ISO8859-15/books/handbook/Makefile
+++ b/it_IT.ISO8859-15/books/handbook/Makefile
@@ -35,7 +35,6 @@ DOC?= book
 FORMATS?= html-split
 
 HAS_INDEX= true
-USE_PS2PDF= yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/ja_JP.eucJP/books/handbook/Makefile b/ja_JP.eucJP/books/handbook/Makefile
index c8d615af24..1bd163b587 100644
--- a/ja_JP.eucJP/books/handbook/Makefile
+++ b/ja_JP.eucJP/books/handbook/Makefile
@@ -42,7 +42,6 @@ DOC?= book
 FORMATS?= html-split
 
 HAS_INDEX= true
-USE_PS2PDF=	yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/mn_MN.UTF-8/books/handbook/Makefile b/mn_MN.UTF-8/books/handbook/Makefile
index 3b0258dab4..7485ab93cd 100644
--- a/mn_MN.UTF-8/books/handbook/Makefile
+++ b/mn_MN.UTF-8/books/handbook/Makefile
@@ -43,7 +43,6 @@ DOC?= book
 FORMATS?= html-split
 
 HAS_INDEX= true
-USE_PS2PDF=	yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/nl_NL.ISO8859-1/books/handbook/Makefile b/nl_NL.ISO8859-1/books/handbook/Makefile
index ae8a4d7ab1..68d8975067 100644
--- a/nl_NL.ISO8859-1/books/handbook/Makefile
+++ b/nl_NL.ISO8859-1/books/handbook/Makefile
@@ -43,7 +43,6 @@ DOC?= book
 FORMATS?= html-split
 
 HAS_INDEX= true
-USE_PS2PDF=	yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/pl_PL.ISO8859-2/books/handbook/Makefile b/pl_PL.ISO8859-2/books/handbook/Makefile
index 5d124e69b0..e1aaa878a6 100644
--- a/pl_PL.ISO8859-2/books/handbook/Makefile
+++ b/pl_PL.ISO8859-2/books/handbook/Makefile
@@ -35,7 +35,6 @@ DOC?= book
 FORMATS?= html-split
 
 HAS_INDEX= true
-USE_PS2PDF=	yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/pt_BR.ISO8859-1/books/handbook/Makefile b/pt_BR.ISO8859-1/books/handbook/Makefile
index eec5933db2..69946296b9 100644
--- a/pt_BR.ISO8859-1/books/handbook/Makefile
+++ b/pt_BR.ISO8859-1/books/handbook/Makefile
@@ -36,7 +36,6 @@ DOC?= book
 FORMATS?= html-split
 
 HAS_INDEX= true
-USE_PS2PDF=	yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/ru_RU.KOI8-R/books/handbook/Makefile b/ru_RU.KOI8-R/books/handbook/Makefile
index 2d3e729f56..1cf517348f 100644
--- a/ru_RU.KOI8-R/books/handbook/Makefile
+++ b/ru_RU.KOI8-R/books/handbook/Makefile
@@ -38,7 +38,6 @@ DOC?= book
 FORMATS?= html-split
 
 #HAS_INDEX= true
-USE_PS2PDF=	yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/share/mk/doc.docbook.mk b/share/mk/doc.docbook.mk
index 1dd75a000b..8d560c028c 100644
--- a/share/mk/doc.docbook.mk
+++ b/share/mk/doc.docbook.mk
@@ -452,31 +452,12 @@ ${DOC}.rtf:
 
 .if ${RENDERENGINE} == "jade"
 .if !defined(NO_TEX)
-#
-# This sucks, but there's no way round it.  The PS and PDF formats need
-# to use different image formats, which are chosen at the .tex stage.  So,
-# we need to create a different .tex file depending on our eventual output
-# format, which will then lead on to a different .dvi file as well.
-#
-
 ${DOC}.tex: ${SRCS} ${LOCAL_IMAGES_EPS} ${PRINT_INDEX} \
 		${LOCAL_IMAGES_TXT} ${LOCAL_IMAGES_EN} \
 		${DOC}.parsed.xml
 	${JADE} -V tex-backend ${PRINTOPTS} \
 		${JADEOPTS} -t tex -o ${.TARGET} ${XMLDECL} ${DOC}.parsed.xml
 
-${DOC}.tex-ps: ${DOC}.tex
-	${LN} -f ${.ALLSRC} ${.TARGET}
-
-.if !target(${DOC}.tex-pdf)
-${DOC}.tex-pdf: ${SRCS} ${IMAGES_PDF} ${PRINT_INDEX} \
-		${LOCAL_IMAGES_TXT} ${DOC}.parsed.xml
-	${RM} -f ${.TARGET}
-	${CAT} ${PDFTEX_DEF} > ${.TARGET}
-	${JADE} -V tex-backend ${PRINTOPTS} -ioutput.print.pdf \
-		${JADEOPTS} -t tex -o /dev/stdout ${XMLDECL} ${DOC}.parsed.xml >> ${.TARGET}
-.endif
-
 .if !target(${DOC}.dvi)
 ${DOC}.dvi: ${DOC}.tex ${LOCAL_IMAGES_EPS}
 .for _curimage in ${LOCAL_IMAGES_EPS:M*share*}
@@ -492,41 +473,23 @@ ${DOC}.dvi: ${DOC}.tex ${LOCAL_IMAGES_EPS}
 .endif
 
 .if !target(${DOC}.pdf)
-.if !defined(USE_PS2PDF)
-${DOC}.pdf: ${DOC}.tex-pdf ${IMAGES_PDF}
-.else
 ${DOC}.pdf: ${DOC}.ps ${IMAGES_PDF}
-.endif
-.for _curimage in ${IMAGES_PDF:M*share*}
-	${CP} -p ${_curimage} ${.CURDIR:H:H}/${_curimage:H:S|${IMAGES_EN_DIR}/||:S|${.CURDIR}||}
-.endfor
-.if !defined(USE_PS2PDF)
-	${PDFJADETEX_PREPROCESS} < ${DOC}.tex-pdf > ${DOC}.tex-pdf-tmp
-	@${ECHO} "==> PDFTeX pass 1/3"
-	-${PDFJADETEX_CMD} '${TEX_CMDSEQ} \nonstopmode\input{${DOC}.tex-pdf-tmp}'
-	@${ECHO} "==> PDFTeX pass 2/3"
-	-${PDFJADETEX_CMD} '${TEX_CMDSEQ} \nonstopmode\input{${DOC}.tex-pdf-tmp}'
-	@${ECHO} "==> PDFTeX pass 3/3"
-	-${PDFJADETEX_CMD} '${TEX_CMDSEQ} \nonstopmode\input{${DOC}.tex-pdf-tmp}'
-.else
+#.for _curimage in ${IMAGES_PDF:M*share*}
+#	${CP} -p ${_curimage} ${.CURDIR:H:H}/${_curimage:H:S|${IMAGES_EN_DIR}/||:S|${.CURDIR}||}
+#.endfor
 	${PS2PDF} ${DOC}.ps ${.TARGET}
 .endif
-.endif
 
 ${DOC}.ps: ${DOC}.dvi
 	${DVIPS} ${DVIPSOPTS} -o ${.TARGET} ${.ALLSRC}
 .else
 #  NO_TEX
-${DOC}.tex ${DOC}.tex-ps ${DOC}.dvi ${DOC}.ps:
+${DOC}.tex ${DOC}.dvi ${DOC}.ps:
 	${TOUCH} ${.TARGET}
 .if !target(${DOC}.pdf)
 ${DOC}.pdf:
 	${TOUCH} ${.TARGET}
 .endif
-.if !target(${DOC}.tex-pdf)
-${DOC}.tex-pdf:
-	${TOUCH} ${.TARGET}
-.endif
 .endif
 
 .elif ${RENDERENGINE} == "fop"
diff --git a/zh_CN.GB2312/books/handbook/Makefile b/zh_CN.GB2312/books/handbook/Makefile
index 5ab9d25bab..2163726fd9 100644
--- a/zh_CN.GB2312/books/handbook/Makefile
+++ b/zh_CN.GB2312/books/handbook/Makefile
@@ -41,7 +41,6 @@ DOC?= book
 FORMATS?= html-split
 
 HAS_INDEX= true
-USE_PS2PDF=	yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=
diff --git a/zh_TW.Big5/books/handbook/Makefile b/zh_TW.Big5/books/handbook/Makefile
index 5c92346891..a86b5c2c8f 100644
--- a/zh_TW.Big5/books/handbook/Makefile
+++ b/zh_TW.Big5/books/handbook/Makefile
@@ -34,7 +34,6 @@ DOC?= book
 FORMATS?= html-split
 
 HAS_INDEX= true
-USE_PS2PDF=	yes
 
 INSTALL_COMPRESSED?= gz
 INSTALL_ONLY_COMPRESSED?=