# -*- 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
PortGroup               openssl 1.0

github.setup            uniconproject unicon 13.2
github.tarball_from     archive
revision                2
categories              lang
license                 GPL-2
maintainers             nomaintainer
conflicts               icon

description             Extended dialect of icon
long_description        {*}${description}. ${name} is a very high level, goal-directed, \
                        object-oriented, general purpose application language supporting \
                        many operating systems and architectures.

homepage                https://unicon.sourceforge.io/

checksums               rmd160  d2ac2cafbdb6355edc4d752f1df9566a09df7659 \
                        sha256  0d0be976f12e3cc3067a4949d8f8a7e4a95368dfd015c43c2c76bc4f83fd0039 \
                        size    17190887

depends_lib-append      port:freetype \
                        port:ftgl \
                        path:include/turbojpeg.h:libjpeg-turbo \
                        port:libGLU \
                        port:libpng \
                        port:mesa \
                        port:Xft2 \
                        port:xorg-libX11 \
                        port:xpm \
                        port:zlib

# ftgl requires C++11
compiler.cxx_standard   2011

patchfiles              checking-for.patch \
                        codesign.patch \
                        compiler.patch \
                        concurrency.patch \
                        CURTSTATE.patch \
                        CXX.patch \
                        CXXFLAGS.patch \
                        databse.patch \
                        implicit.patch \
                        no-Iprefix.patch \
                        no-Iprefix-gl.patch \
                        plugins.patch \
                        prefix.patch \
                        verbose.patch

post-patch {
    reinplace -W ${worksrcpath} "s|@PREFIX@|${prefix}|g" \
                        configure.ac \
                        src/iconc/ccomp.c \
                        src/common/Makefile
}

# We are patching configure.ac and Makefile.in.
use_autoreconf          yes
autoreconf.args         -fvi
# https://trac.macports.org/wiki/WimplicitFunctionDeclaration#strchr
configure.checks.implicit_function_declaration.whitelist-append strchr

# Disable silent rules.
configure.args-append   --enable-verbosebuild

# Explicitly enable features we want so that the configure script exits with an
# error if they're not found.
configure.args-append   --enable-concurrency \
                        --enable-graphics \
                        --enable-graphics3d \
                        --enable-iconc \
                        --enable-iconcurrency \
                        --enable-multiprograms \
                        --enable-pattern \
                        --enable-plugins \
                        --enable-progs \
                        --enable-ssl

# Disable features we don't want so they're not used opportunistically.
configure.args-append   --disable-database \
                        --disable-voip

# Audio support can't be compiled on macOS:
# https://github.com/uniconproject/unicon/issues/568
configure.args-append   --disable-audio

# Specify where to look for each library so it doesn't go looking elsewhere.
configure.args-append   --with-freetype=${prefix} \
                        --with-ftgl=${prefix} \
                        --with-jpeg=${prefix} \
                        --with-opengl=${prefix} \
                        --with-png=${prefix} \
                        --with-ssl=[openssl::install_area] \
                        --with-Xft=${prefix} \
                        --with-xlib=${prefix} \
                        --with-zlib=${prefix}

# Tell the openssl portgroup not to muck with things; we plug the openssl path
# into the configure args above.
openssl.configure

build.target            default

test.run                yes
test.dir                ${worksrcpath}/tests
test.target             Test Report

post-destroot {
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 ${worksrcpath}/COPYING ${destroot}${prefix}/share/doc/${name}
}
