# -*- 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           qt5 1.0
PortGroup           boost 1.0

qt5.depends_component qttools qttranslations
qt5.min_version     5.14.0

# 1.7.x and newer requires Qt 6.
# 1.5.x development continues on the Version15x branch.
name                scribus-devel
epoch               1
version             1.5.8
revision            9
checksums           rmd160  74aa3579efa5bc8733a95a47be6cf341b0bbdcec \
                    sha256  47816e8fcf6d05788ff16aa4499f97ff22431c777a7789149b0a88b451e16b74 \
                    size    74543476

categories          print
license             LGPL-2+ BSD MIT
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
set branch          [join [lrange [split ${version} .] 0 1] .]

description         qt5-based WYSIWYG desktop publishing application

long_description    Scribus is an open source desktop publishing program. It \
                    provides true WYSIWYG editing, excellent PDF export \
                    facilities, and a wide range of other input and output \
                    options. This port tracks the development branch, \
                    currently ${branch}.x.

homepage            https://www.scribus.net/
master_sites        sourceforge:project/scribus/scribus-devel/${version}
use_xz              yes
distname            scribus-${version}
dist_subdir         scribus

set py_ver          3.11
set py_ver_nodot    [string map {. {}} ${py_ver}]

depends_build-append \
                    path:bin/perl:perl5

depends_lib-append \
                    path:lib/pkgconfig/cairo.pc:cairo \
                    port:expat \
                    port:fontconfig \
                    port:ghostscript \
                    path:lib/pkgconfig/harfbuzz.pc:harfbuzz \
                    path:lib/pkgconfig/harfbuzz-icu.pc:harfbuzz-icu \
                    port:hunspell \
                    path:lib/pkgconfig/icu-uc.pc:icu \
                    port:lcms2 \
                    port:libart_lgpl \
                    port:libiconv \
                    port:libcdr-0.1 \
                    port:libfreehand \
                    port:libmspub \
                    port:libpagemaker \
                    port:libqxp \
                    port:librevenge \
                    port:libvisio-0.1 \
                    port:libxml2 \
                    port:libzmf \
                    port:podofo \
                    path:lib/pkgconfig/poppler.pc:poppler \
                    port:python${py_ver_nodot} \
                    port:tiff \
                    port:zlib

post-extract {
    # DOS to UNIX line endings so we can patch.
    reinplace -W ${worksrcpath}/scribus/plugins/import/pdf "s|\r||g" \
                    importpdf.cpp \
                    slaoutput.cpp \
                    slaoutput.h
}

patchfiles          arch-and-deployment-target.patch \
                    authors.patch \
                    poppler.patch \
                    QFunctionPointer.patch \
                    unary_function.patch

compiler.c_standard   2011
compiler.cxx_standard 2017

set PyFRM           ${frameworks_dir}/Python.framework/Versions

cmake.install_prefix \
                    "${applications_dir}/[string toupper ${name} 0].app"

configure.args-append \
                    -DWITH_PODOFO=YES \
                    -DWANT_DISTROBUILD=YES \
                    -DWITH_BOOST=YES \
                    -DWANT_CPP17=YES \
                    -DWANT_GRAPHICSMAGICK=NO \
                    -DWANT_NOOSG=YES \
                    -DPython3_EXECUTABLE=${prefix}/bin/python${py_ver} \
                    -DPython3_LIBRARIES=${PyFRM}/${py_ver}/Python \
                    -DPython3_INCLUDE_DIR=${PyFRM}/${py_ver}/include/python${py_ver}

variant bitmap description {Input filters for most GraphicsMagick bitmap formats} {
    configure.args-delete   -DWANT_GRAPHICSMAGICK=NO
    configure.args-append   -DWANT_GRAPHICSMAGICK=YES
    depends_lib-append      port:GraphicsMagick
}

livecheck.url       ${homepage}downloads/unstable-branch/
livecheck.regex     /scribus-devel/(\[a-z0-9\]+(\\.\[a-z0-9\]+)+)/