# -*- 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                pth
version             2.0.7
revision            1
categories          devel
license             LGPL-2.1+
maintainers         nomaintainer
description         GNU Portable Threads
long_description    Pth is a very portable POSIX/ANSI-C based library for Unix platforms \
                    which provides non-preemptive priority-based scheduling for multiple \
                    threads of execution ("multithreading") inside server applications. All \
                    threads run in the same address space of the server application, but \
                    each thread has its own individual program-counter, run-time stack, \
                    signal mask and errno variable.

platforms           darwin

homepage            http://www.gnu.org/software/pth/
master_sites        gnu

checksums           md5 9cb4a25331a4c4db866a31cbe507c793 \
                    sha1 9a71915c89ff2414de69fe104ae1016d513afeee

configure.args      --mandir=${prefix}/share/man

post-configure {
    reinplace "s|CC -dynamiclib|CC -dynamiclib [get_canonical_archflags]|g" ${worksrcpath}/libtool
}

use_parallel_build  no

platform darwin {
    # makecontext/setcontext (the default) is leading to infinite loops in programs on PPC-platforms.
    # Switch to setjmp/longjmp when building for one of these platforms.
    # Latter should work equally well on x86(_64).
    if {![variant_isset universal]} {
        if {[lsearch ${build_arch} ppc*] != -1} {
            configure.args-append --with-mctx-mth=sjlj --with-mctx-dsp=ssjlj --with-mctx-stk=sas
        }
    }

    variant universal {
        if {[lsearch ${universal_archs} ppc*] != -1} {
            configure.args-append --with-mctx-mth=sjlj --with-mctx-dsp=ssjlj --with-mctx-stk=sas
        }
    }
}

post-destroot {
    reinplace -E {s|-arch [a-z0-9_]+||g} \
        ${destroot}${prefix}/bin/pth-config

    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} ANNOUNCE AUTHORS ChangeLog COPYING \
        HACKING HISTORY INSTALL NEWS PORTING README SUPPORT TESTS THANKS \
        USERS ${destroot}${prefix}/share/doc/${name}
}