# -*- 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           cxx11 1.1
PortGroup           github 1.0
PortGroup           snowleopard_fixes 1.0

github.setup        tatsuhiro-t nghttp2 1.31.0 v
categories          www
platforms           darwin
maintainers         {mps @Schamschula} openmaintainer
license             MIT

description         nghttp2 is an implementation of HTTP/2 in C.

long_description    ${description} Included are a HTTP/2 client, server and proxy. The \
                    package also provides a load test and benchmarking tool for HTTP/2.

github.tarball_from releases
use_xz              yes

checksums           rmd160 fd620488c6ab61a41db3e76108779a7a8e39dee2 \
                    sha256 36573c2dc74f0da872b02a3ccf1f1419d6b992dd4703dc866e5a289d36397ac7

if {![variant_isset python34] && ![variant_isset python35] && ![variant_isset python36] } { default_variants +python27 }

if {![variant_isset python27] && ![variant_isset python34] && ![variant_isset python35] && ![variant_isset python36] } {
    error "You must select one of the python variants."
}

if {[variant_isset python27]} { set PythonVersion   2.7 }
if {[variant_isset python34]} { set PythonVersion   3.4 }
if {[variant_isset python35]} { set PythonVersion   3.5 }
if {[variant_isset python36]} { set PythonVersion   3.6 }
set PythonBranch    [join [lrange [split ${PythonVersion} .] 0 1] ""]

depends_build       port:pkgconfig

depends_lib         port:c-ares \
                    port:jansson \
                    port:libev \
                    port:libevent \
                    port:libxml2 \
                    path:lib/libssl.dylib:openssl \
                    port:py${PythonBranch}-cython \
                    port:py${PythonBranch}-setuptools \
                    port:python${PythonBranch} \
                    port:zlib

patchfiles-append   src-shrpx_config.diff

configure.args      --disable-silent-rules \
                    --disable-threads \
                    --enable-app \
                    ac_cv_prog_AWK=/usr/bin/awk

configure.env       CYTHON=${prefix}/bin/cython-${PythonVersion} \
                    JANSSON_CFLAGS=-I${prefix}/include JANSSON_LIBS="-L${prefix}/lib -ljansson" \
                    LIBEVENT_OPENSSL_CFLAGS=-I${prefix}/include/event2 \
                    LIBEVENT_OPENSSL_LIBS="-L${prefix}/lib -levent -levent_openssl" \
                    OPENSSL_CFLAGS=-I${prefix}/include/openssl \
                    OPENSSL_LIBS="-L${prefix}/lib -lcrypto -lssl" \
                    PYTHON=${prefix}/bin/python${PythonVersion}

destroot.env        PYTHONPATH=${destroot}${prefix}/lib/python${PythonVersion}/site-packages/

pre-destroot {
    xinstall -d ${destroot}${prefix}/lib/python${PythonVersion}/site-packages/
}

variant python27 conflicts python34 python35 python36 description {Build using Python 2.7} {
    configure.env-append   PYTHON_EXTRA_LDFLAGS="-u _PyMac_Error ${frameworks_dir}/Python.framework/Versions/${PythonVersion}/Python"
}

variant python34 conflicts python27 python35 python36 description {Build using Python 3.4} {}

variant python35 conflicts python27 python34 python36 description {Build using Python 3.5} {}

variant python36 conflicts python27 python34 python35 description {Build using Python 3.6} {}