Subject: [RFC] mk/latex.mk to handle latex dependencies
To: None <tech-pkg@NetBSD.org>
From: Antoine Reilles <Antoine.Reilles@loria.fr>
List: tech-pkg
Date: 11/03/2005 17:12:17
--hQiwHBbRI9kgIhsi
Content-Type: multipart/mixed; boundary="rwEMma7ioTxnRzrJ"
Content-Disposition: inline


--rwEMma7ioTxnRzrJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi all,

I wrote a while ago a latex.mk makefile fragment to handle =20
dependencies over various teTeX versions. It comes from the fact that =20
many packages to depends on the teTeX package, which is for tetex2, =20
while they could work as well with tetex3. Also, using teTeX3 require =20
to take care of it at each update, since  pkg_chk and pkgdepgraph =20
will remove the teTeX3 packages, and put teTeX2.

This latex.mk allows one to set LATEX_VERSION_DEFAULT=3D3 in /etc/=20
mk.conf, to use tetex3.
It also exports LATEX_TEXMFPREFIX and LATEX_LOCALTEXMFPREFIX =20
variables, both pointing for now to ${PREFIX}/share/texmf. They can =20
be sed in PLIST.
Those could be usefull to help manage packaging latex packages that =20
are included in teTeX3, with old versions, they could be installed in =20
the local texmf, since teTeX3 supports it (see http://mail-=20
index.netbsd.org/tech-pkg/2005/04/06/0013.html and following).

A package using latex.mk can set
LATEX_VERSIONS_ACCEPTED, which is by default "2 3", and also can set
USE_LATEX to "build" to get only a build dependency. The default is =20
"run", which causes also buildlink, so print/teTeX/=20
kpathsea.buildlink.mk is no more needed.

Since pkgsrc will probably continue support tetex1,2 and 3, it would =20
be usefull to have such a facility, to easy creating packages using =20
latex. This could also let us rewrite the print/teTex/ package to use =20
it, and install the required teTeX package, handling version.

So far, i've converted locally all packages using latex to this, and =20
encountered no problems with those i tested.
(see patch at http://www.loria.fr/~reilles/divers/latex.diff)

Any objections? suggestions? ideas?
antoine


--rwEMma7ioTxnRzrJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="latex.mk"

# $NetBSD$
#
# A Makefile fragment for tex and latex packages
#
# 	* Determine the version of teTeX to be used.
#     Modify LATEX_VERSION_DEFAULT to change the default version (default to teTeX-2)
#
#	* tex files are installed...
#	  	teTeX-[1-2]
#	  		-> ${PREFIX}/share/texmf
#		  teTeX-3
#	  		->${PREFIX}/share/texmf-local
#   The variables LATEX_TEXMFPREFIX and LATEX_LOCALTEXMFPREFIX defines the main
#   texmf tree, where teTeX should install his own texmf tree, and the local
#   texmf tree, which is the place where other packages should install their
#   latex files, like additional styles.
#   NOTE: before all latex related packages are converted to use these
#   variables, we will keep
#   LATEX_TEXMFPREFIX=LATEX_LOCALTEXMFPREFIX=${PREFIX}/share/texmf
#
#	* Assume each package supports teTeX {2,3} by default.
#	  To change the supported latex versions, define LATEX_VERSIONS_ACCEPTED
#	  explicitly before including mk/latex.mk.  Note that the order is
#	  important.
#
# * Optionally set USE_LATEX to "build" to only add a build-time
#   dependency on Latex. That may be useful for creating documentation
#
# Variables for users:
#
# LATEX_VERSION_DEFAULT
#   Description:
#     The user's favorite latex implementation
#   Possible values:
#     1, 2, 3
#   Default value:
#     2
#
# Variables tex packages can provide:
#
# USE_TETEX1
#  Description:
#    Set if the package wants teTeX1
#  Possible values:
#    <undefined>, <defined>
#  Default value:
#    <undefined>
#
# USE_LATEX
#  Description:
#    Set latex as DEPENDS or BUILD_DEPENDS
#  Possible values:
#    run, build
#  Default value:
#    run
#
# LATEX_VERSIONS_ACCEPTED
#  Description:
#    Versions the package accepts (supports).
#  Possible values:
#    1, 2, 3
#  Default value:
#    2, 3
#
# Variables provided for tex packages:
#
# LATEX_TEXMFPREFIX
#   Description:
#     Path to the directory the standard tex files can be found
#   Possible values:
# 	  ${PREFIX}/share/texmf
# 	  ${PREFIX}/share/texmf-dist
#
# LATEX_LOCALTEXMFPREFIX
#   Description:
#     Path to the directory the tex for extentions should be installed into
#   Possible values:
#   	${PREFIX}/share/texmf
#     ${PREFIX}/share/texmf-local
#
# LATEX_VERSION
#   Description:
#     The version of the used teTeX package
#   Possible values:
#     1.*, 2.*, 3.*
#
# LATEX_PKG_VERSION
#   Description:
#     The full version of the used teTeX package (with PKGREVISION)
#   Possible values:
#     1.*(nb*)?, 2.*(nb*)?, 3.*(nb*)?

.if !defined(LATEX_MK)
LATEX_MK=	# defined

.include "../../mk/bsd.prefs.mk"

USE_LATEX?= run
# Assume only teTeX {2-3} are supported by default.
#
LATEX_VERSION_DEFAULT?=		2
.if !defined(USE_TETEX1)
LATEX_VERSIONS_ACCEPTED?=	2 3
.else
LATEX_VERSIONS_ACCEPTED?=	1
.endif

# set up variables for buildlink or depends
#
BUILDLINK_DEPENDS.teTeX1+=	teTeX-bin>=1.0
BUILDLINK_PKGSRCDIR.teTeX1?=	../../print/teTeX1-bin
BUILDLINK_DEPENDS.teTeX2+=	teTeX-bin>=2.0
BUILDLINK_PKGSRCDIR.teTeX2?=	../../print/teTeX-bin
BUILDLINK_DEPENDS.teTeX3+=	teTeX-bin>=3.0
BUILDLINK_PKGSRCDIR.teTeX3?=	../../print/teTeX3-bin

.for v in ${LATEX_VERSIONS_ACCEPTED}
_LATEX_VERSION_${v}_OK=	yes
.endfor

# Look for teTeX-bin-{1-3}
#
_TMP!=	${PKG_INFO} -e teTeX-bin || ${ECHO}
.if ${_TMP} != ""
_LATEX_VERSION_LATEX_FULL:=	${_TMP}
_LATEX_VERSION_LATEX=	${_LATEX_VERSION_LATEX_FULL:C/^.*-//}
_LATEX_VERSION_LATEX_MAJOR=	${_LATEX_VERSION_LATEX:C/\..*//}
.if ${_LATEX_VERSION_LATEX_MAJOR} == "1"
_LATEX_VERSION_1_INSTALLED=	yes
.elif ${_LATEX_VERSION_LATEX_MAJOR} == "2"
_LATEX_VERSION_2_INSTALLED=	yes
.elif ${_LATEX_VERSION_LATEX_MAJOR} == "3"
_LATEX_VERSION_3_INSTALLED=	yes
.endif
.endif

# Determine the Latex version to be used.
#
.if defined(LATEX_VERSION_REQD)
_LATEX_VERSION=	${LATEX_VERSION_REQD}
.endif
.if !defined(_LATEX_VERSION)
.if defined(_LATEX_VERSION_${LATEX_VERSION_DEFAULT}_OK)
.if defined(_LATEX_VERSION_${LATEX_VERSION_DEFAULT}_INSTALLED)
_LATEX_VERSION=	${LATEX_VERSION_DEFAULT}
.endif
.endif
.endif
.if !defined(_LATEX_VERSION)
.for v in ${LATEX_VERSIONS_ACCEPTED}
.if defined(_LATEX_VERSION_${v}_INSTALLED)
_LATEX_VERSION?=	${v}
.else
_LATEX_VERSION_FIRSTACCEPTED?=	${v}
.endif
.endfor
.endif
.if !defined(_LATEX_VERSION)
.if defined(_LATEX_VERSION_${LATEX_VERSION_DEFAULT}_OK)
_LATEX_VERSION=	${LATEX_VERSION_DEFAULT}
.endif
.endif
.if !defined(_LATEX_VERSION)
_LATEX_VERSION=	${_LATEX_VERSION_FIRSTACCEPTED}
.endif

# Set version specifics.
#
.if ${_LATEX_VERSION} == "3"
LATEX_DEPENDENCY=	${BUILDLINK_DEPENDS.teTeX3}
LATEX_PKGSRCDIR=  ${BUILDLINK_PKGSRCDIR.teTeX3}
#LATEX_TEXMFPREFIX=	${PREFIX}/share/texmf-dist
LATEX_TEXMFPREFIX=	${PREFIX}/share/texmf
#LATEX_LOCALTEXMFPREFIX=	${PREFIX}/share/texmf-local
LATEX_LOCALTEXMFPREFIX=	${PREFIX}/share/texmf
.elif ${_LATEX_VERSION} == "2"
LATEX_DEPENDENCY=	${BUILDLINK_DEPENDS.teTeX2}
LATEX_PKGSRCDIR=  ${BUILDLINK_PKGSRCDIR.teTeX2}
LATEX_TEXMFPREFIX=	${PREFIX}/share/texmf
LATEX_LOCALTEXMFPREFIX=	${PREFIX}/share/texmf
.elif ${_LATEX_VERSION} == "1"
LATEX_DEPENDENCY=	${BUILDLINK_DEPENDS.teTeX1}
LATEX_PKGSRCDIR=  ${BUILDLINK_PKGSRCDIR.teTeX1}
LATEX_TEXMFPREFIX=	${PREFIX}/share/texmf
LATEX_LOCALTEXMFPREFIX=	${PREFIX}/share/texmf
.else
PKG_SKIP_REASON+=	"Accepted versions are: ${LATEX_VERSIONS_ACCEPTED}"
PKG_SKIP_REASON+=	"No valid Latex version installed found"
.endif
.if (${USE_LATEX} == "build")
BUILD_DEPENDS+=	${LATEX_DEPENDENCY}:${LATEX_PKGSRCDIR}
.else
USE_LATEX:= run
# in this case, do a real buildlink
BUILDLINK_DEPTH:=		${BUILDLINK_DEPTH}+
TETEX_BIN_BUILDLINK3_MK:=	${TETEX_BIN_BUILDLINK3_MK}+

.if !empty(BUILDLINK_DEPTH:M+)
BUILDLINK_DEPENDS+=	teTeX-bin
.endif
BUILDLINK_PACKAGES:=	${BUILDLINK_PACKAGES:NteTeX-bin}
BUILDLINK_PACKAGES+=	teTeX-bin
.if !empty(TETEX_BIN_BUILDLINK3_MK:M+)
BUILDLINK_DEPENDS.teTeX-bin+=	${LATEX_DEPENDENCY}
BUILDLINK_PKGSRCDIR.teTeX-bin?=	${LATEX_PKGSRCDIR}
.endif	# TETEX_BIN_BUILDLINK3_MK
BUILDLINK_DEPTH:=     ${BUILDLINK_DEPTH:S/+$//}
.endif

# Provide some macro definitions.
#
LATEX_PKG_VERSION=	${_LATEX_VERSION_LATEX_FULL:C|^.*-||}

# strip out nb?
LATEX_VERSION=${LATEX_PKG_VERSION:C|nb[0-9]*$||}
PLIST_SUBST+=	LATEX_VERSION=${LATEX_VERSION}
PLIST_SUBST+=	LATEX_TEXMFPREFIX=${LATEX_TEXMFPREFIX:C|^${PREFIX}/||}
PLIST_SUBST+=	LATEX_LOCALTEXMFPREFIX=${LATEX_LOCALTEXMFPREFIX:C|^${PREFIX}/||}

.endif	# LATEX_MK

--rwEMma7ioTxnRzrJ--

--hQiwHBbRI9kgIhsi
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (NetBSD)

iD8DBQFDajbG4VqmoGDE/mwRAqP8AJ4+/Bx2zTKpdEr9abaziLgH1iHyZQCeOWdc
Kh1rKwRxuMfUWVpWaH8xJDw=
=D1Lu
-----END PGP SIGNATURE-----

--hQiwHBbRI9kgIhsi--