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

set realname        proj
name                ${realname}6
version             6.3.2
set datumgrid_ver   1.8
revision            0
categories-append   gis
platforms           darwin
license             MIT

maintainers         {stromnov @stromnov} openmaintainer

description         PROJ is a generic coordinate transformation software

long_description    PROJ is a generic coordinate transformation software \
                    that transforms geospatial coordinates from one \
                    coordinate reference system (CRS) to another. This \
                    includes cartographic projections as well as \
                    geodetic transformations.

homepage            https://proj4.org/
master_sites        http://download.osgeo.org/proj/

distname            ${realname}-${version}

distfiles-append    ${realname}-datumgrid-${datumgrid_ver}.zip

checksums           ${realname}-${version}.tar.gz \
                    rmd160  921b822868362fd1a81158542d540fd34a0c44c7 \
                    sha256  cb776a70f40c35579ae4ba04fb4a388c1d1ce025a1df6171350dc19f25b80311 \
                    size    2827685 \
                    ${realname}-datumgrid-${datumgrid_ver}.zip \
                    rmd160  f84c374f85c1314c7e357fd50683b67767cea358 \
                    sha256  b9838ae7e5f27ee732fb0bfed618f85b36e8bb56d7afb287d506338e9f33861e \
                    size    6601640

extract.only        ${realname}-${version}.tar.gz

depends_build-append \
                    port:pkgconfig

depends_extract-append \
                    port:unzip

depends_lib-append  port:sqlite3

post-extract {
    set datumgrid ${distpath}/${realname}-datumgrid-${datumgrid_ver}.zip
    system "${prefix}/bin/unzip -o '$datumgrid' -d '${worksrcpath}/data'"
}

compiler.cxx_standard 2011

configure.pre_args  --prefix=${prefix}/lib/proj6
configure.args      --mandir=${prefix}/lib/proj6/share/man

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     "${realname}-(6(?:\\.\\d+)*)${extract.suffix}"

# Without this, the build fails with Xcode clang on 10.8/5.1.1 and 10.9/6.2.
# This is due to an upstream bug requiring a forgiving compiler.
compiler.blacklist-append {clang < 700}
