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

name                mod_perl2
version             2.0.13
revision            0
maintainers         nomaintainer
categories          www
license             Apache-2
description         Embeds a Perl interpreter in the Apache2 server
long_description    mod_perl brings together the full power of the Perl programming language \
                    and the Apache HTTP server. You can use Perl to manage Apache, respond to \
                    requests for web pages and much more. \
                    \
                    mod_perl gives you a persistent Perl interpreter embedded in your web \
                    server. This lets you avoid the overhead of starting an external interpreter \
                    and avoids the penalty of Perl start-up time, giving you super-fast \
                    dynamic content. \
                    \
                    As you'd expect from the Perl community, there are hundreds of modules \
                    written for mod_perl, everything from persistent database connections, to \
                    templating sytems, to complete XML content delivery systems. Web sites like \
                    Slashdot and Wired Magazine use mod_perl.
homepage            https://perl.apache.org/
master_sites        apache:perl/
distname            mod_perl-${version}

checksums           rmd160  bb23e41bbfab461abe9e618bf40531268916e261 \
                    sha256  ade3be31c447b8448869fecdfcace258d6d587b8c6c773c5f22735f70d82d6da \
                    size    3848487

perl5.require_variant   yes
perl5.conflict_variants yes
perl5.branches          5.28 5.30 5.32 5.34
perl5.default_branch    5.34
perl5.create_variants   ${perl5.branches}

depends_lib         port:apache2 \
                    port:perl${perl5.major}

worksrcdir          mod_perl-${version}

if {[string match *clang* ${configure.compiler}]} {
    patchfiles-append clang-compatibility_src-modules-perl-modperl_common_util.h.patch
}

set apache_name     apache2
set apachectl       ${prefix}/sbin/apachectl
set apxs            ${prefix}/bin/apxs
set mdir            ${prefix}/lib/apache2/modules/

configure {
    system -W ${worksrcpath} "${perl5.bin} Makefile.PL MP_APXS=${apxs}"
}

post-destroot {
        xinstall -m 755 -d ${destroot}${prefix}/include/${apache_name}/modules/perl \
            ${destroot}${prefix}/libexec
        xinstall -m 755 {*}[glob ${worksrcpath}/src/modules/perl/*.h] \
            ${destroot}${prefix}/include/${apache_name}/modules/perl

        xinstall -m 755 ${worksrcpath}/src/modules/perl/mod_perl.so \
            ${destroot}${mdir}

        fs-traverse f ${destroot}${prefix} {
            if {[file isfile ${f}]} {
                switch [file tail ${f}] {
                    .packlist -
                    perllocal.pod {
                        delete ${f}
                    }
                }
            }
        }
}

notes "
If this is your first install, you might want to enable mod_perl in Apache:

    cd ${mdir}
    sudo ${apxs} -a -e -n \"perl\" mod_perl.so

And then relaunch Apache:

    ${apachectl} restart
"

livecheck.url       https://perl.apache.org/download/index.html
livecheck.type      regex
livecheck.regex     "mod_perl-(\\d+\\.\\d+(\[0-9rc.\]+)?).tar.gz"
