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

github.setup        rentzsch mach_override 919148f94db54fc04d287eb6a42c0c36b166bbfa
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version             20140512
revision            0
categories          devel
license             MIT
maintainers         nomaintainer
description         runtime function overriding for Mac OS X
long_description    {*}${description}

supported_archs     i386 ppc ppc64 x86_64

checksums           rmd160  fc7bcb5c5ba48ac464eaac3d6141d4cd9905703b \
                    sha256  3860002c2c29da3b9a447d3fb9d36c23863e2d1e1d8b8c1505789d527d25e0b4 \
                    size    66287

depends_build       port:libtool \
                    port:udis86

patch.pre_args-replace  -p0 -p1
patchfiles          macports-udis86.diff \
                    relative-call.diff

use_configure       no

build {
    system -W ${worksrcpath} "${configure.cc} ${configure.cflags} [get_canonical_archflags cc] -I ${prefix}/include -c -o mach_override.o mach_override.c"
    system -W ${worksrcpath} "libtool -static -o libmach_override.a mach_override.o ${prefix}/lib/libudis86.a"
}

destroot {
    set include_dir ${destroot}${prefix}/include
    set lib_dir     ${destroot}${prefix}/lib
    set doc_dir     ${destroot}${prefix}/share/doc/${name}

    xinstall -m 0775 -d ${include_dir}
    xinstall -m 0775 -d ${lib_dir}
    xinstall -m 0755 -d ${doc_dir}

    xinstall -m 0644 ${worksrcpath}/mach_override.h ${include_dir}
    xinstall -m 0644 ${worksrcpath}/libmach_override.a ${lib_dir}
    xinstall -m 0644 ${worksrcpath}/README.markdown ${doc_dir}
}

github.livecheck.branch \
                    semver-1.x

test.run            yes

test {
    system -W ${worksrcpath} "${configure.cc} ${configure.cflags} [get_canonical_archflags cc] -framework CoreServices -o test_mach_override test_mach_override.cp libmach_override.a"
    system -W ${worksrcpath} "./test_mach_override"
}
