# -*- 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$

PortSystem          1.0

name                elinks-devel
conflicts           elinks
version             0.12pre6
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/

depends_build       port:pkgconfig
depends_lib         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  68703f9fa8862c243a8083833d8447d4e09280ff \
                    sha256  c0b3a7871f4aea954b0a66d5bbc6ce6de55ad17aa25aba3987f775707067c800

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-idn \
                    --with-libiconv \
                    --with-openssl \
                    --with-spidermonkey=${prefix} \
                    --with-tre \
                    --without-gc \
                    --without-gnutls \
                    --without-gpm \
                    --without-gssapi \
                    --without-guile \
                    --without-lua \
                    --without-lzma \
                    --without-perl \
                    --without-python \
                    --without-ruby \
                    --without-see \
                    --without-x \
                    --without-xterm

if {${os.major} < 11 || ${os.platform} ne "darwin"} {
    configure.args-delete   --without-gc
    configure.args-append   --with-gc
    depends_lib-append      path:include/gc.h:boehmgc
}

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.
platform darwin 8 {
    depends_build-append    port:gmake
    build.cmd               ${prefix}/bin/gmake
}

compiler.blacklist          llvm-gcc-4.2

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

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

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

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

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

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

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

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

variant lua description {Enable support for Lua scripting} {
    depends_lib-append      path:bin/lua:lua

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

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-delete   --without-perl
    configure.args-append   --with-perl
}

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

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

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

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

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

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

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

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

default_variants    +colors

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