# $Id: Portfile 65959 2010-04-03 21:32:51Z perry@macports.org $

PortSystem          1.0

name                elinks-devel
version             0.12pre5
categories          www
maintainers         perry openmaintainer
platforms           darwin

description         Full-Featured Text WWW Browser
long_description    ELinks is an advanced and well-established feature-rich \
                    text mode web (HTTP/FTP/..) browser.
license             GPLv2
homepage            http://elinks.or.cz/

livecheck.regex     {unstable version is (.*),}
livecheck.type      regex
livecheck.url       ${homepage}

depends_build       port:pkgconfig
depends_lib \
    path:include/gc.h:boehmgc \
    port:bzip2 \
    port:expat \
    port:gettext \
    port:libiconv \
    port:libidn \
    port:openssl \
    port:spidermonkey \
    port:tre \
    port:zlib

distname            elinks-${version}
master_sites        ${homepage}download/

checksums           rmd160 517f8ef0e1978a204496631a63495656fbf51f19

patchfiles          patch-Makefile.lib.diff patch-configure.diff

post-patch {
    if {[variant_isset universal]} {
        reinplace "s|@ARCHS@|${configure.universal_ldflags}|" ${worksrcpath}/Makefile.lib
    } else {
        reinplace "s|@ARCHS@|-arch ${build_arch}|" ${worksrcpath}/Makefile.lib
    }
}

configure.args \
    --disable-256-colors \
    --disable-88-colors \
    --disable-debug \
    --disable-fsp \
    --disable-smb \
    --disable-true-color \
    --enable-bittorrent \
    --enable-cgi \
    --enable-exmode \
    --enable-finger \
    --enable-gopher \
    --enable-html-highlight \
    --enable-nntp \
    --with-gc \
    --with-idn \
    --with-libiconv \
    --with-openssl \
    --with-spidermonkey=${prefix} \
    --with-tre \
    --without-gnutls \
    --without-gpm \
    --without-gssapi \
    --without-guile \
    --without-lua \
    --without-lzma \
    --without-perl \
    --without-python \
    --without-ruby \
    --without-see \
    --without-x \
    --without-xterm

use_parallel_build  no

variant colors description {Enable support for 88/256 colors and True color} {
    configure.args-append \
        --enable-256-colors \
        --enable-88-colors \
        --enable-true-color
    configure.args-delete \
        --disable-256-colors \
        --disable-88-colors \
        --disable-true-color
}

variant debug description {Enable debug mode} {
    configure.args-append --enable-debug
    configure.args-delete --disable-debug
}

variant fsp description {Enable support for FSP (File Service Protocol)} {
    depends_build-append port:fsplib

    configure.args-append --enable-fsp
    configure.args-delete --disable-fsp
}

variant gnutls description {Use GnuTLS in lieu of OpenSSL} {
    depends_lib-append port:gnutls port:libtasn1
    depends_lib-delete port:openssl

    configure.args-append --with-gnutls --without-openssl
    configure.args-delete --without-gnutls --with-openssl
}

variant guile description {Enable support for Guile scripting} {
    depends_lib-append port:guile

    configure.args-append --with-guile
    configure.args-delete --without-guile
}

variant lua description {Enable support for Lua scripting} {
    depends_lib-append port:lua50

    configure.args-append --with-lua=${prefix}
    configure.args-delete --without-lua
}

variant perl description {Enable support for Perl scripting} {
    depends_lib-append path:bin/perl:perl5

    patchfiles-append patch-src-scripting-perl-hooks.h.diff

    configure.args-append --with-perl
    configure.args-delete --without-perl
}

variant python description {Enable support for Python scripting} {
    depends_lib-append port:python26

    configure.args-append --with-python
    configure.args-delete --without-python
    configure.python ${prefix}/bin/python2.6
}

variant ruby description {Enable support for Ruby scripting} {
    depends_lib-append port:ruby

    configure.args-append --with-ruby
    configure.args-delete --without-ruby
}

variant samba description {Enable support for Samba} {
    depends_lib-append port:samba3

    configure.args-append --enable-smb
    configure.args-delete --disable-smb
    configure.ldflags-append "-L${prefix}/lib/samba3"
}

variant see description {Use SEE in lieu of SpiderMonkey} {
    depends_lib-append port:see
    depends_lib-delete port:spidermonkey

    configure.args-append --enable-see
    configure.args-delete --with-spidermonkey=${prefix}
}
