# -*- 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            netwib
version         5.39.0
categories      net
license         GPL-2
maintainers     {i0ntempest @i0ntempest} openmaintainer

description     A network library oriented towards developers.
long_description \
                Netwib is a network library providing network features \
                such as address conversion, udp/tcp clients/servers, packet \
                encoding/decoding/displaying, spoofing, sniffing, etc., and \
                general features such as data conversion, linked list and \
                hash, portable threads, etc. Using all these functions, a \
                network program can be quickly created.

homepage        http://www.laurentconstantin.com/
master_sites    sourceforge:project/ntwib/${name}/[join [lrange [split ${version} .] 0 1] .]/
extract.suffix  .tgz
distfiles       ${distname}-src${extract.suffix} \
                ${distname}-doc_html${extract.suffix}

checksums       ${distname}-src${extract.suffix} \
                rmd160  7da1d4f870a3eda3f879ebe1da54bd7373605653 \
                sha256  574d72d9bf8b0ed0c25a6b5e902b768727d404c44d570f769b4b1219aa66946f \
                size    641757 \
                ${distname}-doc_html${extract.suffix} \
                rmd160  afba250f1d4027334b6d847a90286693eeb95af8 \
                sha256  983cfc810e1a277b952158d4512c0fba36d3f2a83833213f338952ec0f2fdd18 \
                size    139572

depends_lib     port:libpcap \
                port:libnet

worksrcdir      ${distname}-src/src

pre-configure {
    reinplace "s|/usr/local|${prefix}|g" ${worksrcpath}/config.dat
    reinplace "s|\\(NETWIBDEF_PROGCC_INC=\\)\"\"|\\1-I${prefix}/include|g" ${worksrcpath}/config.dat
    reinplace "s|\\(NETWIBDEF_PROGCC_LIB=\\)\"\"|\\1-L${prefix}/lib|g" ${worksrcpath}/config.dat
    reinplace "s|/man|/share/man|g" ${worksrcpath}/config.dat
    reinplace "s|/share/man3|/man3|g" ${worksrcpath}/config.dat
    reinplace "s|/usr/include/pcap/|${prefix}/include/pcap|g" ${worksrcpath}/genemake
}

configure.pre_args
configure.cmd   ./genemake

post-destroot {
    xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
    file copy ${workpath}/${distname}-doc_html ${destroot}${prefix}/share/doc/${name}/html
    xinstall -m 644 -v -W ${worksrcpath}/../doc/ changelog.txt credits.txt \
    guidestyle.txt todo.txt ${destroot}${prefix}/share/doc/${name}/
}

post-activate {
    ui_msg "\nFull html documentation is installed as part of the port at:\n
    ${prefix}/share/doc/${name}/html/\n"
}
