# -*- 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       cmake 1.0
PortGroup       github 1.0

github.setup    jasper-software jasper 4.2.8 version-
categories      graphics
license         JasPer-2
maintainers     {jmr @jmroot} openmaintainer
description     Library for manipulating JPEG-2000 images

long_description \
    The JasPer Project is an open-source initiative to provide a free \
    software-based reference implementation of the codec specified in the \
    JPEG-2000 Part-1 standard (i.e., ISO/IEC 15444-1).

homepage        http://www.ece.uvic.ca/~mdadams/jasper/

github.tarball_from releases
checksums       rmd160 643308b35fcf34bbbf0a19b0665a2156b2851a4c \
                sha256 98058a94fbff57ec6e31dcaec37290589de0ba6f47c966f92654681a56c71fae

depends_lib     path:include/turbojpeg.h:libjpeg-turbo

compiler.c_standard 2011

cmake.out_of_source yes

configure.args-append   -DOPENGL_gl_LIBRARY:FILEPATH=${configure.sdkroot}/System/Library/Frameworks/OpenGL.framework \
                        -DOPENGL_INCLUDE_DIR:PATH=${configure.sdkroot}/System/Library/Frameworks/OpenGL.framework/Headers \
                        -DOPENGL_glu_LIBRARY:FILEPATH=${configure.sdkroot}/System/Library/Frameworks/OpenGL.framework \
                        -DOPENGL_GLU_INCLUDE_DIR:PATH=${configure.sdkroot}/System/Library/Frameworks/OpenGL.framework/Headers \
                        -DGLUT_glut_LIBRARY:FILEPATH=${configure.sdkroot}/System/Library/Frameworks/GLUT.framework \
                        -DJAS_ENABLE_LIBHEIF:BOOL=OFF \
                        -DJAS_ENABLE_DOC:BOOL=OFF \
                        -DJAS_PACKAGING:BOOL=ON

patchfiles              src_app_CMakeLists.txt.patch

if {[vercmp ${configure.sdk_version} <= 10.10]} {
    patchfiles-append   max_align_t.patch
}

test.run        yes

variant docs description {build documentation} {
    depends_build-append                \
        path:bin/doxygen:doxygen                    \
        port:texlive-latex              \
        port:texlive-latex-extra        \
        port:texlive-fonts-recommended  \
        port:texlive-latex-recommended

    configure.args-delete   -DJAS_ENABLE_DOC=OFF
    configure.args-append   -DJAS_ENABLE_DOC=ON
}

variant heif description {Enable the use of the HEIF Library} {
    depends_lib-append  port:libheif
    configure.args-replace  -DJAS_ENABLE_LIBHEIF=OFF \
                            -DJAS_ENABLE_LIBHEIF=ON
}

# Only allow numbers, to avoid pre-release versions
github.livecheck.regex  {([0-9.]+)}
