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

PortSystem          1.0

name                mono
version             2.11.4
revision            0
categories          devel lang mono
license             {GPL-2 LGPL-2 MIT}
maintainers         nomaintainer
description         Implementation of the .NET Development Framework
long_description    Mono is an effort to create an open source \
                    implementation of the .NET Development Framework \
                    including a C# compiler.

homepage            https://www.mono-project.com
master_sites        https://download.mono-project.com/sources/mono/
use_bzip2           yes
universal_variant   no

checksums           rmd160  5fb08bfb2999833e17e283cfacf80d4c5a7ff00d \
                    sha256  d96ae63650ed1bd48fe5e6a4c5cb0a85fbad40675a7418b508005701a4bd6873 \
                    size    41318816

patchfiles          patch-mono-utils-mach-support.diff

depends_build       port:gawk \
                    port:gettext \
                    path:bin/pkg-config:pkgconfig
depends_lib         path:lib/pkgconfig/cairo.pc:cairo \
                    port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:libgdiplus \
                    port:libiconv \
                    port:libxslt \
                    port:sqlite3 \
                    port:xorg-libX11 \
                    port:zlib

# pthread_support.c:210:12: error: static declaration of 'pthread_setspecific' follows non-static declaration
compiler.blacklist  clang

# Do NOT pick up external boehmgc (prefixing CPPFLAGS or CFLAGS does not suffice -- ugly++)
configure.cc-append	"-I${worksrcpath}/libgc/include"

configure.args      --disable-dtrace \
                    --with-gc=included \
                    --with-libgdiplus=${prefix} \
                    --with-preview=yes \
                    --without-sigaltstack

configure.ldflags-append \
                    -lintl -lcharset

platform powerpc {
    # Configure does nonsense: it arbitrarily sets AC_APPLE_UNIVERSAL_BUILD=1, fails to define
    # endianness correctly, and everything breaks down:
    # ./glib.h:920:18: error: operator '==' has no left operand
    configure.args-append \
                    ac_cv_c_bigendian=yes
}

platform darwin 10 {
    # ucontext.h:42:2: error: #error ucontext routines are deprecated, and require _XOPEN_SOURCE to be defined
    configure.cppflags-append \
                    -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
}

platform darwin 9 {
    # is this still needed?
    patchfiles-append   patch-interp.h.diff
}

use_parallel_build  no

test.run            yes
test.target         check

post-patch {
    reinplace "s/-pthread/-lpthread/g" ${worksrcpath}/configure
}

post-destroot {
    set docdir ${prefix}/share/doc/${name}

    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} AUTHORS COPYING.LIB ChangeLog NEWS README \
        ${destroot}${docdir}

    xinstall -m 0644 -W ${worksrcpath}/docs assembly-bundle embedded-api exceptions \
        gc-issues jit-thoughts jit-trampolines object-layout stack-alignment unmanaged-calls \
        ${destroot}${docdir}

    set libgc_docdir ${prefix}/share/doc/ligbc-mono-6.6

    eval move ${destroot}${prefix}/share/libgc-mono \
        ${destroot}${libgc_docdir}

    xinstall -d ${destroot}${libgc_docdir}/html

    eval move [glob ${destroot}${libgc_docdir}/*.html] \
        ${destroot}${libgc_docdir}/html
}

livecheck.type  regex
livecheck.url   ${homepage}mono-downloads/release_data.js
livecheck.regex {stable_version = "(.+)"}
