# -*- 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
PortGroup           meson 1.0
PortGroup           muniversal 1.1

name                orc
version             0.4.44
revision            0
maintainers         nomaintainer
categories          devel
license             BSD
description         Orc - The Oil Runtime Compiler
long_description    Orc is a library and set of tools for compiling \
                    and executing very simple programs that operate on arrays of data.
homepage            https://gstreamer.freedesktop.org/modules/orc.html
master_sites        https://gstreamer.freedesktop.org/src/orc/
checksums           rmd160  8b95715e7fbb11a28d7bad39abf73e3bf2a49a57 \
                    sha256  4aeb97aea2b58224029dc2b23d7d064cfa990cb4fb8c4da440bcbe9c95bc5d2d \
                    size    317600
use_xz              yes

# https://trac.macports.org/ticket/70658
compiler.c_standard 2011

# Undefined symbols for architecture x86_64: "__xgetbv"
# uses newer assembly features on Intel
compiler.blacklist-append \
                    {clang < 1100}

test.run            yes

platform darwin 8 {
    # meson on Tiger cannot use rpaths, so we workaround with this to find dylib
    build.env-append       "DYLD_LIBRARY_PATH=${build_dir}/${name}"
    test.env-append        "DYLD_LIBRARY_PATH=${build_dir}/${name}:${build_dir}/${name}-test"
    destroot.env-append    "DYLD_LIBRARY_PATH=${build_dir}/${name}"
    patchfiles-append \
        orc_orccompiler.c_tiger.diff

    # Header not introduced until leopard.
    # orcprogram-x86.c:16:11: fatal error: libkern/OSCacheControl.h: No such
    # file or directory
    if {${configure.build_arch} eq "i386"} {
        patchfiles-append \
            orc_orcprogram-x86.c_tiger.diff
    } elseif {${configure.build_arch} eq "ppc" || ${configure.build_arch} eq "ppc64"} {
        # To work around not having sys_dcache_flush an intel specific builtin
        # is used. Don't have a comparable one for ppc, so just avoid building
        # the intel specific files by setting target to altivec for G4/G5, or
        # an empty value for G3.
        if {[catch {sysctl hw.vectorunit} result] || $result == 0} {
            configure.args-append -Dorc-target=
        } else {
            configure.args-append -Dorc-target=altivec
        }
    }
}

if {${configure.build_arch} eq "i386"} {
    # It is not enough to disable the optimizations as it still tries to use
    # instructions too new to identify them when detecting anything intel.
    # orccpu-x86.c {standard input}:15:no such instruction: `xgetbv'
    patchfiles-append \
        orc_orccpu-x86.c_i386.diff
}
