# $OpenBSD: Makefile,v 1.9 2007/06/06 20:36:23 kili Exp $
#
# Credits to Matt Jibson. He did the initial work on this port and many
# tools it depends on.

SHARED_ONLY=		Yes

COMMENT-main=		"text based music notation system"
COMMENT-docs=		"lilypond documentation"

VERSION=		2.10.25
DISTNAME=		lilypond-${VERSION}
DISTNAME-docs=		${DISTNAME}-1.documentation
PKGNAME-main=		lilypond-${VERSION}
PKGNAME-docs=		lilypond-docs-${VERSION}
CATEGORIES=		print

DISTFILES=		${DISTNAME}.tar.gz ${DISTNAME-docs}.tar.bz2:0
EXTRACT_ONLY=		${DISTNAME}.tar.gz

MULTI_PACKAGES=		-main -docs

HOMEPAGE=		http://lilypond.org/web/

MAINTAINER=		Matthias Kilian <kili@openbsd.org>

# GPL
PERMIT_PACKAGE_FTP=	Yes
PERMIT_PACKAGE_CDROM=	Yes
PERMIT_DISTFILES_FTP=	Yes
PERMIT_DISTFILES_CDROM=	Yes

MASTER_BASE=		http://download.linuxaudio.org/lilypond/
MASTER_SITES=		${MASTER_BASE}sources/v${VERSION:C,\.[0-9]*$,,}/
MASTER_SITES0=		${MASTER_BASE}binaries/documentation/

# We don't use the standard autoconf mechanisms from the ports
# system, because it doesn't work for lilypond. Instead, we use
# autogen.sh and add AUTOCONV_VERSION to the environment.
AUTOCONF_VERSION=	2.61
CONFIGURE_STYLE=	gnu
CONFIGURE_SCRIPT=	autogen.sh
CONFIGURE_ENV=		AUTOCONF_VERSION=${AUTOCONF_VERSION} \
			PYTHON=${MODPY_BIN} \
			FLEXLEXER_PATH=/usr/include/g++
CONFIGURE_ARGS+=	--disable-{debugging,optimising,pipe} \
			--with-ncsb-dir=${LOCALBASE}/lib/X11/fonts/ghostscript
USE_GMAKE=		Yes
USE_X11=		Yes
MAKE_FILE=		GNUmakefile

# Stupid fontforge writes autosave data to ~/.PfaEdit, even in
# scripting mode, so give it a HOME to stop systrace warnings.
PORTHOME=		${WRKDIR}

PKG_ARCH-docs=		*
LIB_DEPENDS-docs=
RUN_DEPENDS-docs=

WANTLIB-main=		c expat fontconfig freetype m stdc++ z X11
MODULES=		devel/gettext lang/python
LIB_DEPENDS-main=	${LIB_DEPENDS} \
			guile.>=15,guile-ltdl.>=1::lang/guile \
			glib-2.0.>=1000,gmodule-2.0.>=1000,gobject-2.0.>=1000::devel/glib2 \
			pango-1.0.>=1200,pangoft2-1.0.>=1200::devel/pango
RUN_DEPENDS=		::print/ghostscript/gnu
BUILD_DEPENDS= 		::print/mftrace \
			::devel/bison \
			::archivers/bzip2 \
			:autoconf-${AUTOCONF_VERSION}:devel/autoconf/${AUTOCONF_VERSION} \
			${RUN_DEPENDS}

SUBST_VARS+=		VERSION

NO_REGRESS=		Yes

# Extract the documentation distfiles.
# Remove files generated by bison to avoid some recompilations
# during fake stage.
post-extract:
	bzip2 -cd ${FULLDISTDIR}/${DISTNAME-docs}.tar.bz2 | \
		pax -rs '!^\.!${WRKDIR}/docs!'
	rm -rf ${WRKSRC}/lily/out

post-install:
	${INSTALL_DATA_DIR} ${PREFIX}/share/doc/lilypond/${VERSION}
	umask 022 && cp -R ${WRKDIR}/docs/* \
		${PREFIX}/share/doc/lilypond/${VERSION}

.include <bsd.port.mk>
