# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           gobject_introspection 1.0
PortGroup           cmake 1.1
PortGroup           qt4 1.0

name                poppler-qt4-mac
conflicts           xpdf-tools

# git URL: https://gitlab.freedesktop.org/poppler/poppler
# approximate commit faeb48920d64a776911a259bcf1bb6231ac1d24c
# Sun Nov 12 19:14:32 2017 +0100
# listing of poppler CVEs: https://www.opencve.io/cve?vendor=freedesktop&product=poppler

version             0.61.1
revision            3
license             GPL-2+
maintainers         nomaintainer
categories          graphics
platforms           darwin
homepage            https://poppler.freedesktop.org/

description         Poppler is a PDF rendering library. This version is pegged to the last version \
                    to support qt4.
long_description    ${description}

master_sites        ${homepage}
distname            poppler-${version}

use_xz              yes

checksums           rmd160  62fa0f917e31e0c733228ea9289b4493a0fc29a8 \
                    sha256  1266096343f5163c1a585124e9a6d44474e1345de5cdfe55dc7b47357bcfcda9 \
                    size    1433696

depends_lib-append  port:bzip2 \
                    port:curl \
                    port:expat \
                    port:fontconfig \
                    port:freetype \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/cairo.pc:cairo \
                    port:lcms2 \
                    port:libpng \
                    port:openjpeg \
                    port:poppler-data \
                    port:tiff \
                    port:zlib

configure.ldflags-append -liconv
compiler.cxx_standard   2011
configure.cxxflags-append -std=c++11

gobject_introspection yes
configure.env-append  MOCQT4=${qt_bins_dir}/moc

cmake.install_prefix ${prefix}/libexec/${name}
cmake.install_rpath  ${destroot}${prefix}/libexec/${name}/lib
cmake_share_module_dir ${prefix}/libexec/${name}/share/cmake/Modules

configure.args-append \
                    -DENABLE_XPDF_HEADERS=ON \
                    -DENABLE_QT4=ON \
                    -DENABLE_QT5=OFF \
                    -DBUILD_GTK_TESTS=OFF \
                    -DBUILD_QT5_TESTS=OFF \
                    -DBUILD_CPP_TESTS=OFF \
                    -DWITH_NSS3=OFF


patchfiles-append    patch-CVE-2017-18267.diff

# fix library not found during gir introspection
# https://bugs.freedesktop.org/show_bug.cgi?id=106417
patchfiles-append   patch-bug106417.diff

# https://gitlab.freedesktop.org/poppler/poppler/-/issues/1060
patchfiles-append   poppler-qt4-boxed-type.diff

notes {
This port is based on the last version of poppler (0.61.1) that supported qt4.\
It will be kept as up-to-date as possible with security updates, but is not\
expected to be as up-to-date as the official poppler port (that no longer\
supports qt4). You should consider this when deciding when and whether it is\
appropriate to use this port.

To use this port to build poppler-based ports that require qt4, you will need\
to pass in the directories to the pkgconfig files or otherwise direct the build\
to find these headers and libraries. For example, these lines may be useful:

configure.pkg_config_path-append ${prefix}/libexec/poppler-qt4-mac/lib/pkgconfig ${prefix}/lib/pkgconfig
}

livecheck.type none
