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

openssl.branch          1.0

github.setup            nark libwired df759f4215040cea6c4bd2b67ba86824c144d463
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from     tarball
version                 2020.05.11
revision                1
categories              devel net
maintainers             nomaintainer
license                 BSD
description             libwired is standard C library that implements the Wired 2.0 protocol
long_description        This project is a fork of the Wired library (libwired) created by Axel Andersson at Zanka Software. \
                        It was created and is mainly intended for use by the Wired network suite. It contains collections \
                        and other data structures, and portable abstractions for many OS services, like threads, sockets, files etc.
homepage                https://wired.read-write.fr
checksums               rmd160  ae0bdbd2672268571a2b55cd499dd4149d734037 \
                        sha256  48c17ac87e815183be4adcfa6a60b06871ca2b89119aebe3c153d183ed50e167 \
                        size    244721

depends_build-append    port:autoconf \
                        port:automake \
                        port:libtool \
                        port:pkgconfig
depends_lib-append      port:libiconv \
                        port:libxml2 \
                        port:sqlite3 \
                        port:zlib

configure.checks.implicit_function_declaration.whitelist-append strchr

pre-configure {
    # https://github.com/nark/libwired/issues/9
    delete ${worksrcpath}/config.guess ${worksrcpath}/config.sub ${worksrcpath}/install-sh

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

post-patch {
    reinplace "s,SSL_library_init,SSL_SESSION_new," ${worksrcpath}/config.m4
}

openssl.configure       build_flags

configure.args-append   --enable-iconv \
                        --enable-libxml2 \
                        --enable-p7 \
                        --enable-pthreads \
                        --enable-sqlite3 \
                        --enable-ssl \
                        --enable-termcap

destroot {
    move ${worksrcpath}/run/include/wired ${destroot}${prefix}/include/wired
    move ${worksrcpath}/run/lib/libwired.a ${destroot}${prefix}/lib/libwired.a
}
