From 84d847ce68ec639e0347b60f19004ab72b4064dc Mon Sep 17 00:00:00 2001
From: Hiroki Sato <hrs@FreeBSD.org>
Date: Fri, 18 Jun 2004 15:29:44 +0000
Subject: [PATCH] print/teTeX restructuring: 	Add a dependency of
 print/teTeX-base.

Approved by:	linimon (mentor)
---
 print/xdvik/Makefile                          | 30 ++++++++++++++-----
 .../files/patch-texk::xdvik::Makefile.in      | 10 +++++++
 print/xdvik/files/pkg-install.in              | 20 +++++++++++++
 print/xdvik/pkg-plist                         | 11 +++----
 4 files changed, 56 insertions(+), 15 deletions(-)
 create mode 100644 print/xdvik/files/patch-texk::xdvik::Makefile.in
 create mode 100644 print/xdvik/files/pkg-install.in

diff --git a/print/xdvik/Makefile b/print/xdvik/Makefile
index 5de9435adfe7..f1357c1743eb 100644
--- a/print/xdvik/Makefile
+++ b/print/xdvik/Makefile
@@ -7,15 +7,21 @@
 
 PORTNAME=	xdvik
 PORTVERSION=	22.78
+PORTREVISION=	1
 CATEGORIES=	print
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=	xdvi
+PKGNAMESUFFIX=	-tetex
 
 MAINTAINER=	hrs@FreeBSD.org
 COMMENT=	DVI Previewer(kpathsearch) for X
 
-BUILD_DEPENDS=	mktexlsr:${PORTSDIR}/print/teTeX
-RUN_DEPENDS=	mktexlsr:${PORTSDIR}/print/teTeX
+BUILD_DEPENDS=	tetex-modesw:${PORTSDIR}/print/tex-texmflocal \
+		${LOCALBASE}/${TEXMF}/LICENSE.texmf:${PORTSDIR}/print/teTeX-texmf \
+		mktexlsr:${PORTSDIR}/print/teTeX-base
+RUN_DEPENDS=	tetex-modesw:${PORTSDIR}/print/tex-texmflocal \
+		${LOCALBASE}/${TEXMF}/LICENSE.texmf:${PORTSDIR}/print/teTeX-texmf \
+		mktexlsr:${PORTSDIR}/print/teTeX-base
 LIB_DEPENDS=	t1.5:${PORTSDIR}/devel/t1lib
 
 USE_XLIB=	yes
@@ -27,21 +33,29 @@ CONFIGURE_ARGS=	--prefix=${PREFIX} \
 CONFIGURE_ENV=	INSTALL_SCRIPT="${INSTALL_SCRIPT}" \
 		INSTALL_DATA="${INSTALL_DATA}" \
 		INSTALL_PROGRAM="${INSTALL_PROGRAM}"
+INSTALL_WRKSRC=	${WRKSRC}/texk/xdvik
 
-PLIST_SUB=	TEXMFDIR=${TEXMFDIR} MKTEXLSR=${MKTEXLSR}
+PLIST_SUB=	TEXMF=${TEXMF} MKTEXLSR=${MKTEXLSR}
 CONFLICTS=	xdvi-* *-xdvi*
 
 MAN1=		xdvi.1 t1mapper.1 xdvizilla.1
 
-TEXMFDIR?=	share/texmf
+TEXMF?=		share/texmf
 MKTEXLSR?=	${LOCALBASE}/bin/mktexlsr
 LIBT1_PREFIX?=	${LOCALBASE}
 DOC_FILES=	BUGS CHANGES INSTALL \
 		README README.CVS README_maintainer TODO
 
-do-install:
-	cd ${WRKSRC}/texk/xdvik && \
-		${MAKE_ENV} ${MAKE} ${INSTALL_TARGET}
+TETEX_MODESW=	${LOCALBASE}/bin/tetex-modesw
+PKGINSTALL=	${WRKDIR}/pkg-install.sh
+PKGDEINSTALL=	${WRKDIR}/pkg-install.sh
+PKGINSTALL_SUB=	TETEX_MODESW=${TETEX_MODESW} \
+		MKTEXLSR=${MKTEXLSR}
+
+pre-build:
+	${SED} ${PKGINSTALL_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
+		< ${FILESDIR}/pkg-install.in > ${PKGINSTALL}
+	${CHMOD} 0755 ${PKGINSTALL}
 
 post-install:
 	${INSTALL_SCRIPT} ${WRKSRC}/texk/xdvik/t1mapper ${PREFIX}/bin
@@ -49,6 +63,6 @@ post-install:
 	${MKDIR} ${DOCSDIR}
 	${INSTALL_DATA} ${DOC_FILES:S@^@${WRKSRC}/@} ${DOCSDIR}
 .endif
-	${MKTEXLSR}
+	@${PKGINSTALL} ${PKGNAME} POST-INSTALL
 
 .include <bsd.port.mk>
diff --git a/print/xdvik/files/patch-texk::xdvik::Makefile.in b/print/xdvik/files/patch-texk::xdvik::Makefile.in
new file mode 100644
index 000000000000..c935841f15b1
--- /dev/null
+++ b/print/xdvik/files/patch-texk::xdvik::Makefile.in
@@ -0,0 +1,10 @@
+--- texk/xdvik/Makefile.in.orig	Sat May 15 01:15:17 2004
++++ texk/xdvik/Makefile.in	Sat May 15 01:15:39 2004
+@@ -137,7 +137,6 @@
+ 	$(SHELL) $(top_srcdir)/../mkinstalldirs $(mandir) 
+ 	$(SHELL) $(top_srcdir)/../mkinstalldirs $(texmf)/xdvi/pixmaps
+ 	$(INSTALL_DATA) $(srcdir)/$(manpage).1 $(mandir)/$(manpage).$(manext)
+-	$(INSTALL_DATA) $(srcdir)/texmf/XDvi $(texmf)/xdvi/XDvi
+ 	$(INSTALL_DATA) $(srcdir)/pixmaps/toolbar.xpm $(srcdir)/pixmaps/toolbar2.xpm $(texmf)/xdvi/pixmaps
+ 	if \
+ 	    grep 'original xdvi.cfg --' $(texmf)/xdvi/xdvi.cfg >/dev/null 2>&1 \
diff --git a/print/xdvik/files/pkg-install.in b/print/xdvik/files/pkg-install.in
new file mode 100644
index 000000000000..e77b345ce298
--- /dev/null
+++ b/print/xdvik/files/pkg-install.in
@@ -0,0 +1,20 @@
+#!/bin/sh
+# $FreeBSD$
+
+GREP=/usr/bin/grep
+SED=/usr/bin/sed
+MODE=default
+
+MKTEXLSR=%%MKTEXLSR%%
+TETEX_MODESW=%%TETEX_MODESW%%
+
+case $2 in
+POST-INSTALL)
+	${TETEX_MODESW} ${MODE} XDvi forceinstall
+	${MKTEXLSR}
+	;;
+DEINSTALL)
+	${TETEX_MODESW} uninstall XDvi
+	${MKTEXLSR}
+	;;
+esac
diff --git a/print/xdvik/pkg-plist b/print/xdvik/pkg-plist
index 6e98cf47fe45..6134f03d6e03 100644
--- a/print/xdvik/pkg-plist
+++ b/print/xdvik/pkg-plist
@@ -4,11 +4,10 @@ bin/xdvi
 bin/xdvi-xaw.bin
 bin/xdvi.bin
 bin/xdvizilla
-%%TEXMFDIR%%/xdvi/XDvi
-%%TEXMFDIR%%/xdvi/xdvi.cfg
-%%TEXMFDIR%%/xdvi/pixmaps/toolbar.xpm
-%%TEXMFDIR%%/xdvi/pixmaps/toolbar2.xpm
-@dirrm %%TEXMFDIR%%/xdvi/pixmaps
+%%TEXMF%%/xdvi/xdvi.cfg
+%%TEXMF%%/xdvi/pixmaps/toolbar.xpm
+%%TEXMF%%/xdvi/pixmaps/toolbar2.xpm
+@dirrm %%TEXMF%%/xdvi/pixmaps
 %%PORTDOCS%%%%DOCSDIR%%/BUGS
 %%PORTDOCS%%%%DOCSDIR%%/CHANGES
 %%PORTDOCS%%%%DOCSDIR%%/INSTALL
@@ -17,5 +16,3 @@ bin/xdvizilla
 %%PORTDOCS%%%%DOCSDIR%%/README_maintainer
 %%PORTDOCS%%%%DOCSDIR%%/TODO
 %%PORTDOCS%%@dirrm %%DOCSDIR%%
-@exec %%MKTEXLSR%%
-@unexec %%MKTEXLSR%%