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

name                digikam
version             4.9.0
revision            15

# TODO: Remove, if/when this port is fixed
known_fail          yes

categories          kde kde4
license             GPL-2+
maintainers         openmaintainer \
                    gmail.com:caulier.gilles

description         Photo Management Programme
long_description    Digital photo management programme to import, organise, enhance, search and export your digital images.

homepage            http://www.digikam.org/
master_sites        kde:stable/digikam/

checksums           rmd160  72e680f932aca65fe0d59a5c313b1d7950ec29ef \
                    sha256  fa24591d183e1a782e053bfca43bb91149465d0f5e49926c7d6dd16f6321f07f

use_bzip2           yes

# List of whole dependencies ###############################################

# Dependencies of digiKam and Kipi-plugins

boost.version       1.71

set opencv_ver      3

depends_lib-append  port:kdelibs4 \
                    port:kdepimlibs4 \
                    port:qt4-mac \
                    port:tiff \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libpng \
                    path:lib/opencv${opencv_ver}/libopencv_core.dylib:opencv${opencv_ver} \
                    port:marble
depends_lib-append  port:libpgf

# Dependencies of kipi-plugins

depends_lib-append  port:expat\
                    path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2 \
                    port:libgpod \
                    port:libxml2 \
                    port:libxslt \
                    port:qca \
                    port:qjson \
                    port:ImageMagick \
                    path:share/pkgconfig/eigen3.pc:eigen3

# Dependencies of digiKam

depends_lib-append  port:gettext \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:lensfun \
                    port:libgphoto2 \
                    port:liblqr \
                    path:lib/pkgconfig/libusb-1.0.pc:libusb \
                    port:jasper2 \
                    port:shared-desktop-ontologies

# RunTime dependencies

depends_run-append  port:kde4-baseapps \
                    port:kde4-runtime \
                    port:oxygen-icons \
                    port:qt4-mac-sqlite3-plugin
# Following dependency is needed for the Panorama (and ExpoBlending?) tool, but
# cannot be installed on Intel Macs currently as far as I know. Also they need
# wxWidgets which currently cannot be installed with Xcode of OS X 10.7 or
# newer.
# RJVB 20140918: hugin needs wxWidgets 3 nowadays, which introduces a dependency to another GUI framework. Users who
# want the Panorama tool can install hugin-app manually and then build digikam from source
# (or we could add yet another variant)
#                   port:hugin-app \

# kde4-baseapps is not universal
universal_variant   no

# gcc-4.0 is also blacklisted for opencv
# clang stumbles over CV_XADD macro, see #37184
compiler.blacklist  gcc-4.0
compiler.blacklist-append   {clang < 318}

# Configurations rules to compile fine #####################################

# 20140918: do we really need to specify the CMAKE_MODULE_PATH nowadays?
# -DCMAKE_MODULE_PATH=\"${prefix}/share/cmake-2.8/Modules\;${prefix}/share/cmake/modules\" \
# We do need to add ENABLE_KDEPIMLIBSSUPPORT though, otherwise the dependency on kdepimlibs4 is
# there for nothing!
# There also appears to be no (more) need to force-defined __KDE_HAVE_GCC_VISIBILITY
# -DCMAKE_CXX_FLAGS='-D__KDE_HAVE_GCC_VISIBILITY'
#-DCMAKE_SYSTEM_PREFIX_PATH=\"${prefix}\;/usr\"
#-DCMAKE_PREFIX_PATH=\"${prefix}/lib/cmake\"
#-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON

configure.args-append -DENABLE_KDEPIMLIBSSUPPORT:BOOL=ON \
                      -DOpenCV_DIR=${prefix}/libexec/opencv${opencv_ver}/cmake \
                      -DDIGIKAMSC_COMPILE_LIBKGEOMAP:BOOL=ON -DDIGIKAMSC_COMPILE_LIBKVKONTAKTE:BOOL=ON \
                      -DDIGIKAMSC_COMPILE_LIBMEDIAWIKI:BOOL=ON -DDIGIKAMSC_COMPILE_LIBKFACE:BOOL=ON \
                      -Wno-dev \
                      ../${distname}

# Optional compilation options #############################################

# Option to include debug symbols in compiled target

if {[variant_isset debug]} {
    configure.args-append -DCMAKE_BUILD_TYPE=debugfull
} else {
    # RJVB: use RelWithDebInfo instead of releasewithdebug, and prevent stripping
    #configure.args-append -DCMAKE_BUILD_TYPE=releasewithdebug
    configure.args-append -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCMAKE_STRIP:FILEPATH=/bin/echo
}

# Option to compile handbook

if {[variant_isset docs]} {
    configure.args-append -DDIGIKAMSC_COMPILE_DOC=on
} else {
    configure.args-append -DDIGIKAMSC_COMPILE_DOC=off
}

# Option to compile GUI translations

variant translations description {Build digiKam GUI translations} {}

if {[variant_isset translations]} {
    configure.args-append -DDIGIKAMSC_COMPILE_PO=ON
} else {
    configure.args-append -DDIGIKAMSC_CHECKOUT_PO:BOOL=OFF -DDIGIKAMSC_COMPILE_PO=off
}

# Option to compile target using internal implementation of KdeGraphics shared libs maintained by digiKam team

variant use_private_libs description {Build digiKam with internal KDEGraphics libs} {}

if {[variant_isset use_private_libs]} {
    configure.args-append -DDIGIKAMSC_USE_PRIVATE_KDEGRAPHICS=on
} else {
    configure.args-append -DDIGIKAMSC_USE_PRIVATE_KDEGRAPHICS=off

    depends_lib-append port:libkdcraw \
                       port:libkexiv2 \
                       port:libkipi \
                       port:libksane
}

# Option to compile target with LCMS shared lib version 2 instead of version 1

variant lcms2 description {Build digiKam with LCMS2 shared libs instead of LCMS1} {}

if {[variant_isset lcms2]} {
    configure.args-append -DENABLE_LCMS2=on

    depends_lib-append port:lcms2
} else {
    configure.args-append -DENABLE_LCMS2=off

    depends_lib-append port:lcms
}

# Option to check MySQL availability before compiling target

variant mysql_check description {Check MySQL availability before building digiKam} {}

if {[variant_isset mysql_check]} {
    configure.args-append -DENABLE_INTERNALMYSQL=on

    depends_lib-append    path:bin/mysql_config5:mysql5 \
} else {
    configure.args-append -DENABLE_INTERNALMYSQL=off
}

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     "digiKam (\\d+(?:\\.\\d+)*) is released"
