# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 90801 2012-03-14 20:42:27Z snc@macports.org $

PortSystem          1.0

name                lilypond
version             2.14.2
revision            1
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          textproc
maintainers         snc openmaintainer
license             GPL-3+
conflicts           lilypond-devel
description         An automated engraving system for typesetting sheet music.
long_description    Lilypond is a unix-based automated engraving system that \
                    generates beautiful sheet music from input files. Lilypond \
                    uses its own input format, .ly, which in many ways is \
                    similar to LaTeX. Lilypond can export sheet music to PDF, \
                    EPS, SVG, and PNG formats, and can also create MIDI files.

homepage            http://lilypond.org/
platforms           darwin
master_sites        http://download.linuxaudio.org/lilypond/sources/v${branch}/
dist_subdir         ${name}/${version}_${revision}
checksums           rmd160  74123b2db40519feaf8144fd19becf3ad81738e7 \
                    sha256  243a6b3845722a37083d73ed681e69ffde0b3b9c6158af20db3c0926dd982696

depends_build       port:t1utils \
                    port:texi2html \
                    port:pkgconfig
depends_lib         port:fontforge \
                    port:ghostscript \
                    port:mftrace \
                    port:guile \
                    port:texinfo \
                    path:lib/pkgconfig/pango.pc:pango \
                    port:flex \
                    port:t1utils \
                    port:texlive-metapost \
                    port:dblatex \
                    port:urw-fonts

patchfiles          patch-scripts-build-mf2pt1.pl.diff
post-patch {
    reinplace s|__vector|lily_vector|g ${worksrcpath}/flower/include/std-vector.hh
    fs-traverse file ${worksrcpath} {
        if {[file isfile $file]} {
            if {[variant_isset python25]} {
                reinplace {s|env python|env python2.5|} $file
                reinplace {s|bin/python|bin/python2.5|} $file
            }

            if {[variant_isset python26]} {
                reinplace {s|env python|env python2.6|} $file
                reinplace {s|bin/python|bin/python2.6|} $file
            }
 
            if {[variant_isset python27]} {
                reinplace {s|env python|env python2.7|} $file
                reinplace {s|bin/python|bin/python2.7|} $file
            }
        }
    }
}

if {${configure.compiler} == "clang"} {
    configure.compiler  llvm-gcc-4.2
}

configure.args  --with-ncsb-dir=${prefix}/share/fonts/urw-fonts \
    --disable-documentation

configure.env       LTDL_LIBRARY_PATH=${prefix}/lib

build.env           LTDL_LIBRARY_PATH=${prefix}/lib

destroot.env        LTDL_LIBRARY_PATH=${prefix}/lib
post-destroot {
    move ${destroot}${prefix}/bin/lilypond \
        ${destroot}${prefix}/libexec/lilypond-bin
    xinstall -m 755 ${filespath}/lilypond.in ${destroot}${prefix}/bin/lilypond
    reinplace "s|@@PREFIX@@|${prefix}|g" ${destroot}${prefix}/bin/lilypond
}

variant python25 conflicts python26 python27 {
    depends_run-append  port:py25-socket-ssl
}

variant python26 conflicts python25 python27 {
    depends_run-append  port:python26
}

variant python27 conflicts python25 python26 {
    depends_run-append  port:python27
}

if {![variant_isset python25] && ![variant_isset python26] && ![variant_isset python27]} {
    default_variants +python27
}

variant docs description {Build documentation files} {
    configure.args-delete   --disable-documentation
    configure.args-append   --enable-documentation
    depends_lib-append      port:netpbm
}

livecheck.type  regex
livecheck.url   ${homepage}/source.html
livecheck.regex ${name}-(\\d+(\\.\\d+)+)
