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

github.setup    jasper-software jasper 4.2.9 version-
revision        0
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
checksums       rmd160  09473be2e4a483c3e9eca0ad1276614c0caca418 \
                sha256  f71cf643937a5fcaedcfeb30a22ba406912948ad4413148214df280afc425454 \
                size    2127186
github.tarball_from releases

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

compiler.c_standard     2011

configure.args-append   -DJAS_ENABLE_DOC:BOOL=OFF \
                        -DJAS_ENABLE_HEIC_CODEC:BOOL=OFF \
                        -DJAS_ENABLE_LIBHEIF:BOOL=OFF \
                        -DJAS_PACKAGING:BOOL=ON

platform darwin {
    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
}

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-fonts-recommended \
        port:texlive-latex \
        port:texlive-latex-extra \
        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_HEIC_CODEC:BOOL=OFF \
                            -DJAS_ENABLE_HEIC_CODEC:BOOL=ON \
                            -DJAS_ENABLE_LIBHEIF:BOOL=OFF \
                            -DJAS_ENABLE_LIBHEIF:BOOL=ON
}

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