diff --git a/share/mk/doc.docbook.mk b/share/mk/doc.docbook.mk
index d38f18714e..b45b9f3ee1 100644
--- a/share/mk/doc.docbook.mk
+++ b/share/mk/doc.docbook.mk
@@ -686,17 +686,19 @@ install-${_curformat}: ${DOC}.${_curformat}
 # directory seperator, make the subdirectories, and install.  Then loop over
 # the ones that don't contain a directory separator, and install them in the
 # top level.
+# en_US.ISO8859-1 is replaced with the LANGCODE to allow installation of
+# images built in en_US.ISO8859-1/ directory
 .for _curimage in ${IMAGES_PNG:M*/*}
-	${MKDIR} -p ${DESTDIR}/${_curimage:H}
-	${INSTALL_DOCS} ${_curimage} ${DESTDIR}/${_curimage:H}
+	${MKDIR} -p ${DESTDIR}/${_curimage:H:S|${CURDIR}||:S|en_US.ISO8859-1|${LANGCODE}|}
+	${INSTALL_DOCS} ${_curimage} ${DESTDIR}/${_curimage:H:S|${CURDIR}||:S|en_US.ISO8859-1|${LANGCODE}|}
 .endfor
 .for _curimage in ${IMAGES_PNG:N*/*}
 	${INSTALL_DOCS} ${_curimage} ${DESTDIR}
 .endfor
 .elif ${_cf} == "tex" || ${_cf} == "dvi"
 .for _curimage in ${IMAGES_EPS:M*/*}
-	${MKDIR} -p ${DESTDIR}/${_curimage:H}
-	${INSTALL_DOCS} ${_curimage} ${DESTDIR}/${_curimage:H}
+	${MKDIR} -p ${DESTDIR}/${_curimage:H:S|${CURDIR}||:S|en_US.ISO8859-1|${LANGCODE}|}
+	${INSTALL_DOCS} ${_curimage} ${DESTDIR}/${_curimage:H:S|${CURDIR}||:S|en_US.ISO8859-1|${LANGCODE}|}
 .endfor
 .for _curimage in ${IMAGES_EPS:N*/*}
 	${INSTALL_DOCS} ${_curimage} ${DESTDIR}
diff --git a/share/mk/doc.images.mk b/share/mk/doc.images.mk
index cdb08cde96..ff0533f6af 100644
--- a/share/mk/doc.images.mk
+++ b/share/mk/doc.images.mk
@@ -114,6 +114,7 @@ EPSTOPDF?=	${PREFIX}/bin/epstopdf
 EPSTOPDFOPTS?=	${EPSTOPDFFLAGS}
 PS2EPS?=	${PREFIX}/bin/ps2epsi
 PIC2PS?=	${GROFF} -p -S -Wall -mtty-char -man 
+REALPATH?=	/bin/realpath
 
 # Use suffix rules to convert .scr files to .png files
 .SUFFIXES:	.scr .pic .png .eps
@@ -125,8 +126,12 @@ PIC2PS?=	${GROFF} -p -S -Wall -mtty-char -man
 		${PNGTOPNM} ${PNGTOPNMOPTS} | \
 		${PNMTOPS} ${PNMTOPSOPTS} > ${.TARGET}
 
+# Some versions of ghostscript (7.04) have problems with the use of
+# relative path when the arguments are passed by peps; realpath will
+# correct the problem.
 .pic.png: ${.TARGET:S/.png$/.eps/}
-	${EPS2PNG} ${EPS2PNGOPTS} -o ${.TARGET} ${.ALLSRC}
+	${EPS2PNG} ${EPS2PNGOPTS} -o ${.TARGET} \
+	`${REALPATH} ${.TARGET:S/.png$/.eps/}`
 
 .pic.eps:
 	${PIC2PS} ${.ALLSRC} > ${.TARGET:S/.eps$/.ps/}
@@ -139,7 +144,7 @@ PIC2PS?=	${GROFF} -p -S -Wall -mtty-char -man
 
 .for _curimage in ${IMAGES_GEN_PNG}
 ${_curimage}: ${_curimage:S/.png$/.eps/}
-	${EPS2PNG} ${EPS2PNGOPTS} -o ${.TARGET} ${.ALLSRC}
+	${EPS2PNG} ${EPS2PNGOPTS} -o ${.TARGET} `${REALPATH} ${.ALLSRC}`
 .endfor
 
 .for _curimage in ${IMAGES_GEN_EPS}