# -*- 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           perl5 1.0

name                amttools
set my_distname     amtterm
version             1.6
revision            2
categories          sysutils
license             GPL-2+
maintainers         {ionic @Ionic} openmaintainer

installs_libs       no

description         Intel AMT® Serial-over-LAN client and tools
long_description    AMT (included in Intel vPro and Centrino Pro) provides \
                    out-of-band (OOB) management for Desktops and Laptops, \
                    using an agent integrated in the network adapter and \
                    in the motherboard. \
                    Serial-over-lan provides a secure way to connect a \
                    remote computer, through a pseudo serial interface. \
                    amtterm and gamt are two terminal tools to connect to \
                    that pseudo serial interface from a remote computer. \
                    amttool is a perl script to gather information about \
                    and remotely control AMT managed computers. \
                    Note that AMT 9.0 dropped support for the old SOAP- \
                    protocol-based communication this package implements. \
                    Newer versions use WS Management implemented starting \
                    with AMT 3.0 and are not supported by this software.

homepage            https://www.kraxel.org/blog/linux/${my_distname}/
master_sites        https://www.kraxel.org/releases/${my_distname}/

distname            ${my_distname}-${version}

checksums           rmd160  9fb55ade1f5ca3015be0794236ea3031fc137367 \
                    sha256  1242cea467827aa1e2e91b41846229ca0a5b3f3e09260b0df9d78dc875075590 \
                    size    40804

perl5.major         5.34
depends_build       path:bin/pkg-config:pkgconfig
depends_run         port:p${perl5.major}-soap-lite

default_variants    +gtk

use_configure       no
variant universal   {}

# Sometimes people are trying to be just a little bit too smart.
# Revert this.
# In a perfect world, everyone would be using trace mode and
# even if GTK+3 and libvte were installed, they couldn't be
# picked up by the build system.
# Sadly, our world is not perfect, so patch out gamt support.
# (And drop this patch in the gtk variant...)
patchfiles          patch-amttool-prepare-hashbang-for-reinplace.diff \
                    patch-mk_Variables.mk-no-special-usr-local-treatment.diff \
                    patch-GNUmakefile-disable-gamt.diff

build.type          gnu
build.env           "CFLAGS=${configure.cppflags} ${configure.cflags} [get_canonical_archflags cc]" \
                    "LDFLAGS=${configure.ldflags} [get_canonical_archflags ld]"
build.args          CC=${configure.cc} \
                    LD=${configure.cc} \
                    verbose=yes

destroot.args       prefix="${prefix}"

post-patch {
    reinplace -W "${worksrcpath}" "s|@@PERL_BINARY@@|${perl5.bin}|" amttool
}

variant gtk description {Enable gamt (GTK3-based AMT terminal)} {
    depends_lib-append  path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                        port:vte

    patchfiles-delete   patch-GNUmakefile-disable-gamt.diff
}

livecheck.name      ${my_distname}
