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

name                msgpack
version             4
revision            0

conflicts           msgpack0 msgpack1 msgpack2 msgpack3

categories          devel
license             Boost-1
maintainers         nomaintainer

description         MessagePack implementation for C and C++
long_description    MessagePack is a binary-based efficient data interchange \
                    format that is focused on high performance. \
                    It is like JSON, but very fast and small.

homepage            https://msgpack.org/

if {${subport} eq ${name}} {
    PortGroup       stub 1.0

    platforms       any
    # since version 4 the C and C++ implementations have been separated in two different packages;
    # msgpack is now a stub port that installs both the msgpack-c and msgpack-cpp ports, so
    # dependents can add this stub port or depend only the required C or C++ implementation
    depends_run     port:msgpack-c \
                    port:msgpack-cpp
}

# except for msgpack and msgpack0, build everything with CMake
if {${subport} ni "${name} ${name}0"} {
    PortGroup       cmake 1.1

    configure.args-append \
                    -DMSGPACK_BUILD_TESTS=OFF
}

subport ${name}0 {
    github.setup    msgpack msgpack-c 0.5.9 cpp-
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    revision        0
    checksums       rmd160  c708651d37d62fa8e1fb18cadbce129fd838b777 \
                    sha256  edfe42e4a9199b9e6c05d421c087a0de8575d045cae88df0873ed9158a9494e0 \
                    size    111682
    conflicts       msgpack1 msgpack2 msgpack3 msgpack
    license         Apache-2

    depends_build   port:autoconf \
                    port:automake \
                    port:libtool

    pre-configure {
        system -W ${worksrcpath} "./bootstrap"
    }
}

subport ${name}1 {
    github.setup    msgpack msgpack-c 1.4.2 cpp-
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    revision        0
    checksums       rmd160  67d03587f5d8e094200bd67bc12d5ebb773bb9f8 \
                    sha256  67f2e45023d954fa1df0749999eb5aaa79b2c76ac940bf453b9f2692aac0b805 \
                    size    409200
    conflicts       msgpack0 msgpack2 msgpack3 msgpack
}

subport ${name}2 {
    github.setup    msgpack msgpack-c 2.1.5 cpp-
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    revision        0
    checksums       rmd160  f23bc02686eb831098275b2c95ab57b147bb5950 \
                    sha256  20b3bdb840b7f6ecff7b87b920b8768904641beb6a5b7c5cf64c7abdd96be208 \
                    size    461199
    conflicts       msgpack0 msgpack1 msgpack3 msgpack
}

subport ${name}3 {
    github.setup    msgpack msgpack-c 3.3.0 cpp-
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    revision        0
    checksums       rmd160  3afbc05b84711399d480199a4e44b7ef5598eff3 \
                    sha256  2d54af3289f1596c4e5fc51b9212ccbbd96a5dc496f3617d72673b326b32fbf7 \
                    size    504706
    conflicts       msgpack0 msgpack1 msgpack2 msgpack
}

if {${subport} ne ${name}} {
    post-destroot {
        set docdir ${prefix}/share/doc/${name}
        xinstall -d ${destroot}${docdir}
        xinstall -m 0644 -W ${worksrcpath} \
            COPYING NOTICE QUICKSTART-C.md QUICKSTART-CPP.md README.md ${destroot}${docdir}

        if {${subport} eq "msgpack0"} {
            xinstall -m 0644 -W ${worksrcpath} AUTHORS ChangeLog LICENSE README_crosslang.md \
                ${destroot}${docdir}
        } else {
            xinstall -m 0644 -W ${worksrcpath} CHANGELOG.md LICENSE_1_0.txt ${destroot}${docdir}
        }
    }
}

livecheck.type  none
