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

github.setup        m3sserschmitt enigma4 e53879f73b439d318f0171cffd4c63719aa270d5
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version             2022.07.02
revision            0
categories          security net
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
license             MIT
description         Onion Routing App
long_description    {*}${description}

fetch.type          git

post-fetch {
    system -W ${worksrcpath} "git submodule update --init --recursive"
}

# Ensure correct path for dylibs:
configure.args-append   -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON

# GCC can build this as-is, but Clang needs C++17 specified explicitly.
# https://github.com/m3sserschmitt/enigma4/issues/6
# Can be set for both though.
compiler.cxx_standard   2017

configure.cxxflags-append \
                        -std=c++17

notes "
To test functionality please refer to the README:\
https://github.com/m3sserschmitt/enigma4/blob/master/README.md
"

destroot {
    foreach ebin {circuit_example eclient enigma4} {
        copy ${cmake.build_dir}/${ebin} ${destroot}${prefix}/bin
    }
    set docdir ${prefix}/share/${name}/doc
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} LICENSE README.md ${destroot}${docdir}
    foreach dir {example test_conf test_keys test_scripts} {
        copy ${worksrcpath}/${dir} ${destroot}${prefix}/share/${name}
    }
    fs-traverse elib ${cmake.build_dir} {
        if {[file isfile ${elib}] && ([file extension ${elib}] == ".dylib" \
            || [file extension ${elib}] == ".a")} {
                copy ${elib} ${destroot}${prefix}/lib
        }
    }
}