# $Id$

PortSystem      1.0

name            lv
version         4.51
revision        3
categories      textproc
maintainers     nomaintainer
description     Powerful Multilingual File Viewer / Grep
long_description \
                ${description}
platforms       darwin
license         GPL-2+
homepage        http://www.ff.iij4u.or.jp/~nrt/lv/index.html
master_sites    http://www.ff.iij4u.or.jp/~nrt/freeware/
distfiles       ${name}451.tar.gz
patchfiles      patch-src_stream.c.diff \
                patch-src_configure.diff \
                patch-src_Makefile.in.diff
checksums       md5 85b70ae797f935741ec9a1cbe92f00e9 \
                sha1 1a70299c27aa317a436976a557853858db4dcb5f \
                rmd160 ae0d58b52dbf714f8b371f51ac87490ecba1c994

depends_lib     port:ncurses
depends_run     bin:bzcat:bzip2 \
                bin:gzcat:gzip

worksrcdir      ${name}451

pre-patch {
    if {[variant_isset lesslikeslash]} {
        patchfiles-append patch-src_command.c.diff
    }
}

configure.cflags-append -I${prefix}/include/ncurses
configure.dir   ${worksrcpath}/build
configure.cmd   ../src/configure

build.dir       ${worksrcpath}/build
build.target
use_parallel_build  yes

destroot {
    xinstall -m 755 -d ${destroot}${prefix}/lib/lv

    xinstall -m 755 ${worksrcpath}/build/lv ${destroot}${prefix}/bin
    xinstall -m 755 ${worksrcpath}/build/lv ${destroot}${prefix}/bin/lgrep
    xinstall -m 644 ${worksrcpath}/lv.hlp ${destroot}${prefix}/lib/lv
    xinstall -m 644 ${worksrcpath}/lv.1 ${destroot}${prefix}/share/man/man1
}

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    foreach f {GPL.txt README hello* index.html relnote.html} {
        eval xinstall -m 644 [glob ${worksrcpath}/${f}] ${destroot}${prefix}/share/doc/${name}
    }
}

default_variants +xz

variant lesslikeslash description {Make the behavior of the search command more similar to the one in Less} {}

variant with_xz requires xz description {Legacy compatibility variant} {}

variant xz description {Experimental support for XZ Utils} {
    patchfiles-append   xz_support.diff
    depends_run-append  path:bin/xz:xz
}

livecheck.type  regex
livecheck.url   ${homepage}
livecheck.regex The latest version is ver (\[0-9.a-z\]+)