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

name                            php-mongodb
categories-append               databases devel
maintainers                     {ryandesign @ryandesign} {mathiesen.info:macintosh @BjarneDMat} openmaintainer
license                         Apache-2

php.branches                    5.4 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 8.5 8.6
php.pecl                        yes

# https://www.mongodb.com/docs/drivers/compatibility/?driver-language=php&php-driver-framework=php-driver
# https://pecl.php.net/package/mongodb
if {[vercmp ${php.branch} >= 8.1]} {
    version                     2.4.0
    revision                    0
    checksums                   rmd160  e8d1e56be88a84506b890be2135ab4b37b741d23 \
                                sha256  08d0d298f0e4c6190a4f8c1f1e23cfbf5d64a1063370b35368bd53012025afa8 \
                                size    2253094
} elseif {[vercmp ${php.branch} >= 7.4]} {
    version                     1.20.1
    revision                    0
    checksums                   rmd160  83fcdfe9792a77e5d199ab721ea017abdee39ba8 \
                                sha256  614e57594918feb621f525e6516d59ce09b78f5172355ba8afb6c2207c1ce900 \
                                size    2106641
} elseif {[vercmp ${php.branch} >= 7.2]} {
    version                     1.16.2
    revision                    0
    checksums                   rmd160  5e23773ac2b29012c969e25a3522e4e939615e4c \
                                sha256  d630cf32a73b6e5e05d2806782d35e06d24b7d5c83cfec08239549e6b6a600b2 \
                                size    1907341
} elseif {[vercmp ${php.branch} >= 7.1]} {
    version                     1.11.1
    revision                    0
    checksums                   rmd160  254a0f9c087c3070fb7efc3c5fda47dfaea4a0d7 \
                                sha256  838a5050de50d51f959026bd8cec7349d8af37058c0fe07295a0bc960a82d7ef \
                                size    1351921
} elseif {[vercmp ${php.branch} >= 7.0]} {
    version                     1.9.2
    revision                    0
    checksums                   rmd160  4ab435591be395818429e72d41129d905d1b5ec6 \
                                sha256  95e832c5d48ae6e947bdc79f35a9f8f0bbd518f4aa00f1cef6c9eafbae02187d \
                                size    1287095
} elseif {[vercmp ${php.branch} >= 5.6]} {
    version                     1.7.5
    revision                    1
    checksums                   rmd160  203855f0fb97d1aaaacced740440de656a1c6be0 \
                                sha256  e48a07618c0ae8be628299991b5f481861c891a22544a2365a63361cc181c379 \
                                size    1223892
} elseif {[vercmp ${php.branch} >= 5.5]} {
    version                     1.5.5
    revision                    1
    checksums                   rmd160  43fff1f5ea24b52767aba7627ff4dfd1915171dd \
                                sha256  a6da3985dd772e3b6c8dde38aa18f3480fba973aaaa41bd4ceb2c6c9c7e4fe3e \
                                size    1060017
} elseif {[vercmp ${php.branch} >= 5.4]} {
    version                     1.2.11
    revision                    2
    checksums                   rmd160  dc35e448324877d8c56be9c6bb1a3f8fa8b9ccc7 \
                                sha256  bac347be2277dd64b1b6f414234a6057eccf2d208409ce60973107a41267df49 \
                                size    786669
}

description                     MongoDB Database Driver

long_description \
    This package provides a PHP interface for communicating with MongoDB database servers.

if {${name} ne ${subport}} {
    depends_build-append        path:bin/pkg-config:pkgconfig

    configure.args-append       --enable-mongodb

    if {[vercmp ${version} >= 1.20]} {
        configure.args-append   --with-system-libs
    } else {
        depends_lib-append      port:libbson \
                                port:mongo-c-driver

        configure.args-append   --with-libbson \
                                --with-libmongoc
    } 

    if {[vercmp ${version} < 1.3]} {
        depends_lib-append      port:cyrus-sasl2

        configure.args-append   --with-mongodb-sasl=${prefix}
    }
}
