# -*- 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           boost 1.0
PortGroup           cmake 1.1
PortGroup           qt4 1.0

boost.version       1.81

name                scribus
epoch               1
version             1.4.8
revision            9
categories          print
license             GPL-2+
maintainers         nomaintainer

description         qt4-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.

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

checksums           rmd160  b145de40f078d37a32861791289c185e9582f00b \
                    sha256  22253bb5994023f39608b37c57c7cd0280059fd97d2a4d71d4011aeeeb18042f \
                    size    73114760

set py_ver          2.7
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 \
                    path:lib/pkgconfig/fontconfig.pc:fontconfig \
                    port:ghostscript \
                    port:hunspell \
                    port:hyphen \
                    port:lcms2 \
                    port:libart_lgpl \
                    port:libiconv \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libpng \
                    port:libxml2 \
                    port:podofo \
                    port:python${py_ver_nodot} \
                    port:tiff \
                    port:zlib

patchfiles          arch-and-deployment-target.patch \
                    lib2geom.patch \
                    libxml2.patch \
                    ordered-comparison.patch

# https://trac.macports.org/ticket/73898
# Untested, but compiles now and the app appears working.
patchfiles-append   podofo-1.0.x.patch

# podofo requires C++17 with TLS
compiler.cxx_standard 2017
compiler.thread_local_storage yes
configure.cxxflags-append -std=c++17

# scribus/unzip.c:1177:24: error: assignment to 'const long unsigned int *' from incompatible pointer type 'const z_crc_t *' {aka 'const unsigned int *'} [-Wincompatible-pointer-types]
configure.cflags-append -Wno-error=incompatible-pointer-types

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

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

configure.args-append \
                    -DPYTHON_LIBRARY="${prefix}/lib/libpython${py_ver}.dylib" \
                    -DPYTHON_INCLUDE_DIR="${PyFRM}/${py_ver}/include/python${py_ver}" \
                    -DWITH_PODOFO=YES

livecheck.regex     "${name}-(\\d+\\.\\d*\[02468\](?:\\.\\d+)*)${extract.suffix}"
