# -*- 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           cmake 1.1
PortGroup           github 1.0
PortGroup           legacysupport 1.1

# clock_gettime
legacysupport.newest_darwin_requires_legacy 15

github.setup        jceel libxpc c70dc7d15ae429ae62522e7566aa25772a09b0aa
version             2015.10.04
revision            0
categories          devel
platforms           {darwin >= 10}
license             BSD
maintainers         {@barracuda156 macos-powerpc.org:barracuda}
description         Open-source reimplementation of Apple XPC library
long_description    {*}${description}
checksums           rmd160  d3dc96653ef4d391f10dadabf69184f3755bb8e7 \
                    sha256  0eb0d58c0d0423d961e82d43539339ce8651e0575164817ef0b865dd29f29b0e \
                    size    88707
github.tarball_from archive

patch.pre_args-replace  -p0 -p1
patchfiles          0001-macOS-support.patch

compiler.c_standard 2011

platform darwin {
    configure.args-append \
                    -DMACH=ON
}

# xpc_connection.c:356:14: error: assignment to 'struct xpc_connection *'
# from incompatible pointer type 'xpc_connection_t' {aka 'struct _xpc_connection_s *'}
# transports/unix.c:188:59: error: passing argument 3 of 'xpc_connection_new_peer'
# makes pointer from integer without a cast
configure.cflags-append \
                    -Wno-error=incompatible-pointer-types \
                    -Wno-error=int-conversion

if {[string match *gcc* ${configure.compiler}] && ${configure.build_arch} in [list arm i386 ppc]} {
    configure.ldflags-append \
                    -latomic
}

destroot {
    copy ${worksrcpath}/xpc ${destroot}${prefix}/include/
    copy ${cmake.build_dir}/libxpc.dylib ${destroot}${prefix}/lib/
}
