# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem      1.0
PortGroup       openssl 1.0

openssl.branch  1.1

name            mhxd
version         0.4.11
revision        0
maintainers     {@barracuda156 gmail.com:vital.had} openmaintainer
license         GPL-2
description     GTK+ Hotline client and server
long_description \
                {*}${description}

categories      net www hotline
homepage        https://hotline.fandom.com/wiki/Clients

master_sites    https://download.nus.edu.sg/mirror/gentoo/distfiles/a3/ \
                http://ftp.klid.dk/ftp/gentoo/distfiles/a3/
checksums       rmd160  6b9d54c9fa872771f4d90d0441d06929d58b6822 \
                sha256  54906798fd9155cf3f53c171f0d839ed1e5a329fa89e56bbcdfda4ce8dda0b91 \
                size    970664

use_bzip2       yes

use_autoreconf  yes
autoreconf.cmd  ./autogen.sh

depends_build-append \
                port:autoconf \
                port:automake \
                port:libtool
depends_lib-append \
                port:libiconv \
                port:readline

patchfiles      patch-broken-comments.diff \
                patch-fix-for-newer-macos.diff

# FIXME: GTK and IRC need fixes. KDX missing its target?
configure.args-append \
                --disable-gtk \
                --disable-irc \
                --disable-kdx \
                --enable-hotline \
                --enable-hx \
                --enable-hxd \
                --enable-hxtrackd \
                --enable-iconv \
                --with-libiconv=${prefix}
   
if {[string match *clang* ${configure.compiler}]} {
    configure.cflags-append \
                -Wno-error=implicit-function-declaration
}

destroot {
    set rundir ${destroot}${prefix}/share
    foreach dir [glob ${worksrcpath}/run/*] {
        copy ${dir} ${rundir}
    }
    set srcdir ${worksrcpath}/src
    foreach bin [list ${srcdir}/acctedit/acctedit ${srcdir}/conf/genconf ${srcdir}/hxd/hxd] {
        if {[file exists ${bin}]} {
            copy ${bin} ${rundir}/hxd/bin
        }
    }
    foreach lib [list ${srcdir}/apple/libapple.a ${srcdir}/common/libcommon.a ${srcdir}/conf/libconf.a ${srcdir}/lib/liblib.a ${srcdir}/protocol/libprotocol.a] {
        if {[file exists ${lib}]} {
            copy ${lib} ${rundir}/hxd/lib
        }
    }
    ln -sf ${rundir}/hxd/bin/hxd ${destroot}${prefix}/sbin/hxd
    copy ${srcdir}/hx/hx ${destroot}${prefix}/bin
    copy ${worksrcpath}/doc/hxd ${destroot}${prefix}/share/doc
    xinstall -m 0644 -W ${worksrcpath} AUTHORS COPYING INSTALL NEWS PROBLEMS README ${destroot}${prefix}/share/doc/hxd
}

startupitem.create      yes
startupitem.executable  ${prefix}/sbin/hxd
