# $Id$

PortSystem 1.0
name		sphinx3
version		0.8
description	Speech recognition package
long_description	Sphinx-3 is CMU's state-of-the-art large vocabulary \
			speech recognition system. It uses Hidden Markov \
			Models (HMM) with continuous output probability \
			density functions (PDF). 
maintainers	singingwolfboy openmaintainer
categories	audio
platforms	darwin freebsd
homepage	http://cmusphinx.sourceforge.net/
master_sites     sourceforge:cmusphinx

use_bzip2   yes
depends_lib     port:sphinxbase port:python26

checksums           md5     e32bf4c507509b27482adf4cfc467e8f \
                    sha1    2e58b5a5ec7f397a7db8ef996043daf8162e3657 \
                    rmd160  95d05c09914bc30ae0b9d849c2141fa3d7a0bdd3

configure.cppflags-append   "-I${prefix}/include/sphinxbase"

pre-configure {
    # configure ignores cppflags, so we have to fix it
    reinplace "s|CPPFLAGS=\"-I/usr/include/sphinxbase -I/usr/local/include/sphinxbase\"|CPPFLAGS=\"-I${prefix}/include/sphinxbase\"|" ${worksrcpath}/configure
}

set python.branch       2.6
set python.prefix       ${frameworks_dir}/Python.framework/Versions/${python.branch}
set python.bin  ${python.prefix}/bin/python${python.branch}
set python.lib  ${python.prefix}/Python
set python.libdir ${python.prefix}/lib/python${python.branch}
set python.pkgd ${python.prefix}/lib/python${python.branch}/site-packages
set python.include      ${python.prefix}/include/python${python.branch} 

post-destroot {
    reinplace "s|/usr/local/include/sphinx|${prefix}/include/sphinx|" ${worksrcpath}/python/setup.py
    system "cd ${worksrcpath}/python && ${python.bin} setup.py --no-user-cfg install --prefix=${python.prefix} --root=${destroot}"
    
    xinstall -d -m 755 ${destroot}${prefix}/share/doc/
    system "find ${worksrcpath}/doc -name .svn -print0 | xargs -0 rm -rf"
    file copy ${worksrcpath}/doc ${destroot}${prefix}/share/doc/${name}
}

livecheck.type  regex
livecheck.url   http://sourceforge.net/projects/cmusphinx/files
livecheck.regex /${name}-(\[0-9.\]+)${extract.suffix}