# -*- 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                libdnsres
version             0.1a
revision            4
categories          net
maintainers         nomaintainer
description         A non-blocking DNS resolver library
long_description    A non-blocking thread-safe API for resolving DNS names.

homepage            https://www.monkey.org/~provos/libdnsres/
master_sites        https://www.monkey.org/~provos/
checksums           rmd160  05a92882d1fc0394792e9f28be4584650b46e323 \
                    sha256  c0b94f27cb537eed42bc32ca9771f0955f717c66d34d1361e0a75600c6589307 \
                    size    360583

supported_archs     i386 ppc ppc64 x86_64

patchfiles          patch-res_comp.c \
                    patch-res_debug.c \
                    patch-res_mkquery.c \
                    patch-res_init.c \
                    patch-res_query.c \
                    patch-res_send.c \
                    patch-gethostnamadr.c \
                    patch-getaddrinfo.c \
                    patch-test-simple_test.c

depends_lib         port:libevent

post-patch {
    reinplace "s|CFLAGS =|CFLAGS = \@CFLAGS\@ |" ${worksrcpath}/Makefile.in
}

platform darwin {
    if {${configure.build_arch} eq "ppc"} {
        configure.args-append \
            --build=powerpc-apple-darwin
    } elseif {${configure.build_arch} eq "ppc64"} {
        configure.args-append \
            --build=powerpc64-apple-darwin
    } elseif {${os.platform} eq "i386"} {
        configure.args-append \
            --build=intel-unknown-darwin
    }
}

# The build uses -O0
configure.optflags

configure.args-append \
                    CPPFLAGS="-I${prefix}/include" \
                    CFLAFS="${configure.cflags} [get_canonical_archflags cc]" \
                    LDFLAGS="-L${prefix}/lib [get_canonical_archflags ld]" \
                    --disable-shared

# Otherwise build may try to link before library gets generated:
# ld: library not found for -ldnsres
# collect2: ld returned 1 exit status
# make[2]: *** [simple_test] Error 1
# ar cru .libs/libdnsres.a
# ranlib .libs/libdnsres.a
use_parallel_build  no
