# $Id: Portfile 87059 2011-11-08 23:23:06Z ryandesign@macports.org $

PortSystem          1.0

name                elinks-devel
conflicts           elinks
version             0.12pre5
revision            1
categories          www
maintainers         nomaintainer
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             GPL-2
homepage            http://elinks.or.cz/

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

depends_build       port:pkgconfig port:gmake
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

variant universal {}

post-patch {
    reinplace "s|@ARCHS@|[get_canonical_archflags]|g" ${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

# elinks-0.12pre5/src/ecmascript/Makefile needs GNU Make 3.81 or later
# due to the "else" followed by a conditional.
build.cmd           gmake

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

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:python27

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

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}
}

default_variants    +colors
