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

name                libcryptopp
version             8.9.0
revision            2
categories          devel security
maintainers         {raphael @raphael-st} openmaintainer
description         C++ class library of cryptographic schemes
long_description    Crypto++ Library is a free C++ class library of \
                    cryptographic schemes.

homepage            https://www.cryptopp.com/
license             Boost-1

master_sites        ${homepage} \
                    https://raw.githubusercontent.com/weidai11/website/master
distname            cryptopp[strsed ${version} {g/\.//}]

use_zip             yes

checksums           rmd160  59cef763407ca6a0c6314f9a545be0a51c51f684 \
                    sha256  4cc0ccc324625b80b695fcd3dee63a66f1a460d3e51b71640cdbfc4cd1a3779c \
                    size    9288053

extract.mkdir       yes

patchfiles          patch-GNUmakefile.diff

use_configure       no

variant universal   {}

proc _get_cryptopp_init_priority_flag {compiler} {
    if {[string match "macports-gcc*" $compiler]} {
        return " -DMACPORTS_GCC_COMPILER"
    }
    return ""
}

# https://trac.macports.org/ticket/69597
if {${configure.cxx_stdlib} eq "libc++"} {
    configure.cxxflags-append \
                    -stdlib=libc++
}

build.type          gnu
build.target        dynamic static libcryptopp.pc cryptest.exe
build.env-append    "CXXFLAGS=[get_canonical_archflags cxx] ${configure.cxxflags} -DNDEBUG [_get_cryptopp_init_priority_flag ${configure.compiler}]"
build.args-append   CXX=${configure.cxx} PREFIX=${prefix}

test.run            yes
test.cmd            ./cryptest.exe
test.target         v

destroot {
    xinstall -m 755 -d ${destroot}${prefix}/include/cryptopp \
        ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 ${worksrcpath}/libcryptopp.a \
        ${worksrcpath}/libcryptopp.dylib \
        ${destroot}${prefix}/lib
    xinstall -m 644 ${worksrcpath}/libcryptopp.pc \
        ${destroot}${prefix}/lib/pkgconfig
    xinstall -m 644 {*}[glob ${worksrcpath}/*.h] \
        ${destroot}${prefix}/include/cryptopp/
    xinstall -m 644 -W ${worksrcpath} Readme.txt License.txt \
        ${destroot}${prefix}/share/doc/${name}/
}

livecheck.type      regex
livecheck.regex     "Crypto\\+\\+ (\\d+(?:\\.\\d+)*)"
