Subject: Re: [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 19:04:22
--OwLcNYc0lM97+oe1
Content-Type: multipart/mixed; boundary="5vNYLRcllDrimb99"
Content-Disposition: inline


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

On Thu, Nov 03, 2005 at 05:12:17PM +0100, Antoine Reilles wrote:
> 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.
[snip]
> Any objections? suggestions? ideas?

I did a lot of changes to the proposition, thanks to jlam's comments.

The file now is mk/latex.buildlink3.mk
I removed the FIRST_ACCEPTED logic, so now if a package do not accept the
default version, which is defined by the user settable LATEX_VERSION (defau=
tls
to "teTeX2"), it will fail, and require the user to explicitly set his
LATEX_DEFAULT to something the package can accept.

The packages can set LATEX_ACCEPTED to teTeX1, teTeX2, teTeX3
(who knows if we don't want to support other latex distribution in the futu=
re).

Also, instead of having the old kpathsea.buildlink3.mk in this file, call t=
he
buildlink3.mk file of the latex package to be installed.
kpathsea.buildlink3.mk was a standard buildlink3.mk file for teTeX-bin. This
only requires to write a buildlink3.mk file for teTeX3-bin, and change
kpathsea.buildlink3.mk to buildlink3.mk in othe teTeX[1-3]-bin packages

Those changes make the file much more simple:
http://www.loria.fr/~reilles/divers/latex.buildlink3.mk

and an example of package using it:
http://www.loria.fr/~reilles/divers/bibtex2html.diff

Is it woing the good way? Comments?

antoine

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

# $NetBSD$
#
# A Makefile fragment for tex and latex packages
#
# 	* Determine the version of teTeX to be used.
#     Modify LATEX_DEFAULT to change the default version (default to teTeX2)
#
#	* tex files are installed...
#	  	teTeX[1-2]
#	  		-> ${PREFIX}/share/texmf
#		  teTeX3
#	  		->${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_ACCEPTED
#	  explicitly before including mk/latex.buildlink3.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_DEFAULT
#   Description:
#     The user's favorite latex implementation
#   Possible values:
#     teTeX1, teTeX2, teTeX3
#   Default value:
#     teTeX2
#
# Variables tex packages can provide:
#
# USE_LATEX
#  Description:
#    Set latex as DEPENDS or BUILD_DEPENDS
#  Possible values:
#    run, build
#  Default value:
#    run
#
# LATEX_ACCEPTED
#  Description:
#    Versions the package accepts (supports).
#  Possible values:
#    teTeX1, teTeX2, teTeX3
#  Default value:
#    teTeX2, teTeX3
#
# 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_TYPE
#   Description:
#     The type of the used latex package
#   Possible values:
#     teTeX1, teTeX2, teTeX3

.if !defined(LATEX_BUILDLINK3_MK)
LATEX_BUILDLINK3_MK=	# defined

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

USE_LATEX?= run

# Assume only teTeX {2-3} are supported by default.
LATEX_DEFAULT?=		teTeX2
LATEX_ACCEPTED?=	teTeX2 teTeX3

# 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

# Determine the Latex version to be used.
#
.if !defined(_LATEX_TYPE)
_LATEX_TYPE=	${LATEX_DEFAULT}
.endif

.if !empty(LATEX_ACCEPTED:M${_LATEX_TYPE})
LATEX_TYPE=	${_LATEX_TYPE}
.else
LATEX_TYPE=	none
.endif

# Set version specifics.
#
.if ${LATEX_TYPE} == "teTeX3"
_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_TYPE} == "teTeX2"
_LATEX_DEPENDENCY=	${BUILDLINK_DEPENDS.teTeX2}
_LATEX_PKGSRCDIR=	${BUILDLINK_PKGSRCDIR.teTeX2}
LATEX_TEXMFPREFIX=	${PREFIX}/share/texmf
LATEX_LOCALTEXMFPREFIX=	${PREFIX}/share/texmf
.elif ${LATEX_TYPE} == "teTeX1"
_LATEX_DEPENDENCY=	${BUILDLINK_DEPENDS.teTeX1}
_LATEX_PKGSRCDIR=	${BUILDLINK_PKGSRCDIR.teTeX1}
LATEX_TEXMFPREFIX=	${PREFIX}/share/texmf
LATEX_LOCALTEXMFPREFIX=	${PREFIX}/share/texmf
.else # LATEX_TYPE == "none"
PKG_FAIL_REASON+=	"${_LATEX_TYPE} is not an acceptable latex version for ${PKGNAME}"
.endif

PLIST_SUBST+=	LATEX_TYPE=${LATEX_TYPE}
PLIST_SUBST+=	LATEX_TEXMFPREFIX=${LATEX_TEXMFPREFIX:C|^${PREFIX}/||}
PLIST_SUBST+=	LATEX_LOCALTEXMFPREFIX=${LATEX_LOCALTEXMFPREFIX:C|^${PREFIX}/||}

.endif	# LATEX_BUILDLINK3_MK

.if (${USE_LATEX} == "build")
BUILD_DEPENDS+=	${_LATEX_DEPENDENCY}:${_LATEX_PKGSRCDIR}
.else
USE_LATEX:= run
.  include "${_LATEX_PKGSRCDIR}/buildlink3.mk"
.endif

--5vNYLRcllDrimb99--

--OwLcNYc0lM97+oe1
Content-Type: application/pgp-signature
Content-Disposition: inline

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

iD8DBQFDalEl4VqmoGDE/mwRAlJwAKCCDgVqKBBobus/QXuzpoJg81ZpUgCfbm6V
PAESpEAi77gS4mQZOsWxLPk=
=veZJ
-----END PGP SIGNATURE-----

--OwLcNYc0lM97+oe1--