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

# Please keep the harfbuzz and harfbuzz-devel ports as similar as possible.

github.setup        harfbuzz harfbuzz 8.2.2
name                harfbuzz-devel
conflicts           harfbuzz
set my_name         harfbuzz
checksums           rmd160  fec94e63597fcb960fcaa09e30ea323744e6a99c \
                    sha256  e433ad85fbdf57f680be29479b3f964577379aaf319f557eb76569f0ecbc90f3 \
                    size    18905228

categories          graphics
maintainers         {ryandesign @ryandesign} {mascguy @mascguy} openmaintainer
license             MIT

description         OpenType text shaping engine

long_description    HarfBuzz is an {*}${description}.

homepage            https://harfbuzz.github.io
github.tarball_from releases
dist_subdir         ${my_name}
use_xz              yes

depends_build       path:bin/pkg-config:pkgconfig

# https://github.com/harfbuzz/harfbuzz/issues/1642
compiler.cxx_standard \
                    2011

# error: invalid operands to binary expression
# https://github.com/harfbuzz/harfbuzz/issues/4371
compiler.blacklist-append {clang < 700}

# Upstream recommends switching to meson but I'm not ready to tackle
# that yet.

configure.args      --disable-silent-rules \
                    --without-chafa \
                    ac_cv_prog_AWK=/usr/bin/awk

# Do not use -Werror. New compilers may have new warnings; we don't want users
# to encounter build failures because of that.
configure.cflags-append     -DHB_NO_PRAGMA_GCC_DIAGNOSTIC_ERROR
configure.cxxflags-append   -DHB_NO_PRAGMA_GCC_DIAGNOSTIC_ERROR

if {${name} eq ${subport}} {
    revision        0

    depends_lib-append \
                    path:lib/pkgconfig/cairo.pc:cairo \
                    port:freetype \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:graphite2

    configure.args-append \
                    --with-cairo \
                    --with-freetype \
                    --with-glib \
                    --with-graphite2 \
                    --with-gobject \
                    --without-icu

    gobject_introspection   yes

    test.run        yes
    test.target     check

    post-destroot {
        set docdir ${prefix}/share/doc/${name}
        xinstall -d ${destroot}${docdir}
        xinstall -m 0644 -W ${worksrcpath} \
                    AUTHORS \
                    COPYING \
                    NEWS \
                    README.md \
                    THANKS \
                    ${destroot}${docdir}
    }

    if {${os.platform} eq "darwin" && ${os.major} >= 9} {
        configure.args-append \
                    --with-coretext
    } else {
        configure.args-append \
                    --without-coretext
    }

    if {${os.platform} eq "darwin" && ${os.major} < 10} {
        depends_test-append \
                    port:python27
        test.env-append \
                    PATH=${frameworks_dir}/Python.framework/Versions/2.7/bin:$env(PATH)
    }
} else {
    livecheck.type  none
}

subport harfbuzz-icu-devel {
    revision        0

    conflicts       harfbuzz-icu

    description     HarfBuzz ICU support library

    long_description This library adds support for ICU (the International Components for Unicode) to HarfBuzz.

    depends_lib-append \
                    port:harfbuzz-devel \
                    path:lib/pkgconfig/icu-uc.pc:icu

    configure.args-append \
                    --without-cairo \
                    --without-freetype \
                    --without-glib \
                    --without-graphite2 \
                    --with-icu

    destroot.dir    ${worksrcpath}/src
    destroot.args   cmake_DATA= \
                    lib_LTLIBRARIES=libharfbuzz-icu.la \
                    nodist_pkginclude_HEADERS= \
                    pkgconfig_DATA=harfbuzz-icu.pc \
                    pkginclude_HEADERS=hb-icu.h
}
