# $Id: Portfile 100827 2012-12-27 23:14:40Z g5pw@macports.org $

PortSystem 1.0

name          tcl
version       8.6.0
revision      1
# Tk (x11/tk) port depends on this version
categories    lang
license       Tcl/Tk
maintainers   mww openmaintainer
platforms     darwin freebsd
description   Tool Command Language
long_description \
  Tcl (Tool Command Language) is a very powerful but easy to learn dynamic \
  programming language, suitable for a very wide range of uses, including web \
  and desktop applications, networking, administration, testing and many more. \
  Open source and business-friendly, Tcl is a mature yet evolving language \
  that is truly cross platform, easily deployed and highly extensible.

homepage      http://www.tcl.tk/
master_sites  sourceforge:project/tcl/Tcl/${version}

checksums     rmd160  656d100ad89d3c63596159b43c36f0fbd0507aca \
              sha256  354422b9c4791685499123b2dfe01faa98b555c08906c010cb4449ddc75dcade

dist_subdir     tcltk
distname        ${name}${version}-src
worksrcdir      ${name}${version}/unix
configure.args  --mandir=${prefix}/share/man \
                --disable-corefoundation \
                --disable-threads
configure.cppflags-delete  -I${prefix}/include
configure.ldflags-delete   -L${prefix}/lib

post-configure {
    reinplace -E {s|-arch [^ ]+||g} ${worksrcpath}/tclConfig.sh
}

destroot.destdir  INSTALL_ROOT=${destroot}
post-destroot {
    ln -s tclsh8.6 ${destroot}${prefix}/bin/tclsh
    ln -s libtcl8.6.dylib ${destroot}${prefix}/lib/libtcl.dylib
}

# dont enable threads by default as Tcl uses thread-local storage which makes
# passing Tcl_Obj* around between threads fatal
variant threads description {add multithreading support} {
    configure.args-delete --disable-threads
    configure.args-append --enable-threads
}

platform macosx {
    # CF is not fork()-safe and software e.g. using tk and fork() will crash
    variant corefoundation description {Enable CoreFoundation support (not fork-safe)} {
        configure.args-delete --disable-corefoundation
    }
    # tk +quartz crashes at launch without CF support
    default_variants-append +corefoundation
}

variant memdebug description {enable memory debugging support} {
    configure.args-append --enable-symbols=mem
}

platform darwin {
    configure.args-append tcl_cv_type_64bit="long long"
}

default_variants +threads

platform darwin 8 {
    # See http://trac.macports.org/ticket/32930 for why this is needed.
    configure.cppflags-append -DSQLITE_WITHOUT_ZONEMALLOC
}

# Files with failing tests: socket.test
test.run      yes

livecheck.type  regex
livecheck.regex {Tcl/Tk (\d+(?:\.\d+)*)</a>}
