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

github.setup        GrahamDumpleton mod_wsgi 4.9.0
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0
categories          www python
license             Apache
maintainers         nomaintainer

description         Python WSGI adapter module for Apache.
long_description    The mod_wsgi module is written in C code directly \
                    against the internal Apache and Python application \
                    programming interfaces. As such, for hosting WSGI \
                    applications in conjunction with Apache it has \
                    a lower memory overhead and performs better than \
                    existing WSGI adapters for mod_python or \
                    alternative FASTCGI/SCGI/CGI based solutions.
homepage            http://www.modwsgi.org/

checksums           rmd160  e961ddb54a9fc72ad516200ea47896dddb00e869 \
                    sha256  d877248a49fb8b8c9f40bf8d9835a9877dc26517f4bdfb1a6896220e874f1617 \
                    size    699976

set apxs            ${prefix}/bin/apxs
set httpd_conf      ${prefix}/etc/apache2/httpd.conf
set mdir            ${destroot}${prefix}/lib/apache2/modules/

depends_lib         port:apache2

configure.args      --disable-framework \
                    --with-apxs=${apxs}

variant python38 conflicts python39 python310 description {Use Python 3.8} {}
variant python39 conflicts python38 python310 description {Use Python 3.9} {}
variant python310 conflicts python38 python39 description {Use Python 3.10} {}

if {![variant_isset python38]} {
    default_variants +python310
}

foreach pv {310 39 38} {
    if {[variant_isset python${pv}]} {
        depends_lib-append \
                    port:python${pv}

        configure.args-append \
                    --with-python=${prefix}/bin/python[strsed ${pv} {s/3/3./}]

        break
    }
}

post-configure {
    reinplace "s|-isysroot.*sdk||" ${worksrcpath}/Makefile
}

pre-destroot {
    xinstall -d -m 755 ${mdir}
}

notes "
To enable mod_wsgi, add

    LoadModule wsgi_module modules/mod_wsgi.so

to your ${httpd_conf} file.
"
