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

# posix_memalign
legacysupport.newest_darwin_requires_legacy 9

github.setup        zuzuf freeocl 6d1d5c909d40a1c203e6d56e8a5c0707118caf30
version             0.3.6-20180107
revision            1
categories          devel graphics
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
license             LGPL-3
description         implementation of OpenCL 1.2 specifications targeting CPUs.
long_description    FreeOCL is an {*}${description}.
checksums           rmd160  6f99efeba4d17b0966238ca0e9120f14a414139a \
                    sha256  907a721daada0cfb683e9517c68d6e41c5b7b0ad768309bf03f0fae0f2254fb2 \
                    size    269474
github.tarball_from archive

# Temporary solution:
conflicts_build     opencl-headers
conflicts           ocl-icd

patch.pre_args-replace  -p0 -p1
patchfiles          0001-CMakeLists.txt-fix-finding-threads.patch \
                    0002-CMakeLists.txt-Darwin-needs-_XOPEN_SOURCE-for-uconte.patch \
                    0003-icd_loader.h-add-missing-macros.patch \
                    0004-Allow-build-on-Apple-with-generic-CL.patch

platform darwin {
    patchfiles-append \
                    0005-macOS-specific-adjustments.patch \
                    0006-cl_platform.h-fix-availability.patch \
                    0007-cl_platform.h-fix-vector-types.patch \
                    0008-darwin-ppc-sysctl.patch \
                    0009-preprocessor-stringification.patch \
                    0010-stdlib-includes.patch

    post-patch {
        reinplace "s,@PREFIX@,${prefix}," ${worksrcpath}/src/icd/icd_loader.cpp
    }
}

compiler.cxx_standard   2011
compiler.openmp_version 2.5

# TODO: may need runtime dep on C++ compiler.
depends_run-append      port:libatomic_ops

# C++11 is optional but enabled by default.
configure.args-append   -DFREEOCL_USE_CXX0X=ON

# https://github.com/zuzuf/freeocl/issues/25
configure.cppflags-append \
                        -DUSE_KHR_CL
