# -*- 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.5.0
checksums           rmd160  f9078722b07904b370675ea9705846575dfe42a7 \
                    sha256  77e4f7f98f3d86bf8788b53e6832fb96279956e1c3961988ea3d4b7ca41ddc27 \
                    size    19468172

name                harfbuzz
conflicts           harfbuzz-devel
set my_name         harfbuzz
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 {
    revision        0

    conflicts       harfbuzz-icu-devel

    description     HarfBuzz ICU support library

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

    depends_lib-append \
                    path:lib/pkgconfig/harfbuzz.pc:harfbuzz \
                    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
}
