# $Id: Portfile 117283 2014-02-21 09:01:13Z jeremyhu@macports.org $

PortSystem              1.0

name                    libcxx
categories              lang
platforms               darwin
license                 MIT NCSA
maintainers             jeremyhu openmaintainer
description             libc++ is a new implementation of the C++ standard library, targeting C++11
long_description        ${description}

homepage                http://libcxx.llvm.org/

fetch.type              svn
svn.revision            183506
version                 ${svn.revision}
revision                1
#worksrcdir              release_32
#svn.url                 http://llvm.org/svn/llvm-project/libcxx/branches/release_32
worksrcdir              final
svn.url                 http://llvm.org/svn/llvm-project/libcxx/tags/RELEASE_33/final
#worksrcdir              trunk
#svn.url                 http://llvm.org/svn/llvm-project/libcxx/trunk

variant universal {}
use_configure no

set root_path ${prefix}/var/host/${name}-${version}-${revision}

if {${os.major} >= 11} {
    fetch {}
    build {}
    destroot {
        xinstall -d ${destroot}${prefix}/share/doc/${name}
        system "echo ${name} is an empty port on this OS version because the functionality is already provided by the OS. > ${destroot}${prefix}/share/doc/${name}/README.txt"
    }
} elseif {${os.major} < 10} {
    pre-fetch {
        ui_error "${name} is not supported on Leopard or earlier."
        error "unsupported platform"
    }
} else {
    depends_lib port:libcxxabi

    #configure.compiler macports-clang-3.2
    configure.compiler macports-clang-3.3

    supported_archs i386 x86_64

    build.dir ${worksrcpath}/lib
    build.cmd ./buildit
    build.env-append \
        CC="${configure.cc}" \
        CXX="${configure.cxx}" \
        RC_XBS=1 \
        RC_CFLAGS="[get_canonical_archflags]" \
        TRIPLE="-apple-darwin${os.major}"

    # We want to use the host's libc++ everywhere because we want to ensure
    # that only *ONE* copy of this library is in any process's address space.
    # On newer OS versions (Lion+), this port does not install anything.  On
    # Snow Leopard, this port provide this library in /usr for binary
    # compatibility with Lion and later.

    destroot {
        xinstall -m 755 -d ${destroot}${root_path}/usr/lib
        xinstall -m 755 ${worksrcpath}/lib/libc++.1.dylib ${destroot}${root_path}/usr/lib
        ln -s libc++.1.dylib ${destroot}${root_path}/usr/lib/libc++.dylib
    }

    post-activate {
        system "ditto ${root_path} /"
    }
}

livecheck.type none
