# -*- 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
# $Id: Portfile 115019 2013-12-22 09:29:46Z ryandesign@macports.org $

PortSystem          1.0
PortGroup           kde4 1.1
PortGroup           compiler_blacklist_versions 1.0

name                digikam
version             3.5.0
revision            1
categories          kde kde4
license             GPL-2+
maintainers         hyper-world.de:jan openmaintainer \
                    gmail.com:caulier.gilles
platforms           darwin

description         Photo Management Program
long_description    Digital photo management program to import, organize, enhance, search and export your digital images.

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

checksums           rmd160 99afee6f47818653a5011f5a3416a04fb3a6a70f \
                    sha256 57bd2aa4fdde44333d1362b02b26ebf6c1a70675bf5cb40de5172df02857c42a

use_bzip2           yes

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

# Dependencies of digiKam and Kipi-plugins

depends_lib-append  port:kdelibs4 \
                    port:kdepimlibs4 \
                    port:qt4-mac \
                    port:tiff \
                    port:jpeg \
                    port:libpng \
                    port:opencv \
                    port:marble 

# Dependencies of kipi-plugins

depends_lib-append  port:expat\
                    port:gdk-pixbuf2 \
                    port:libgpod \
                    port:libxml2 \
                    port:libxslt \
                    port:qca \
                    port:qjson \
                    port:ImageMagick \
                    path:include/eigen3/Eigen/Eigen:eigen3

# opencv is not universal

universal_variant   no

# Dependencies of digiKam

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

# RunTime dependencies

depends_run-append  port:kde4-baseapps \
                    port:kde4-runtime \
                    port:oxygen-icons \
                    port:qt4-mac-sqlite3-plugin 
# Following dependencies are needed for Panorama and ExpoBlending tools, 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.
#                   port:hugin-app \
#                   port:enblend

# 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 #####################################

configure.args-append -DCMAKE_C_FLAGS='-D__KDE_HAVE_GCC_VISIBILITY' \
                      -DCMAKE_CXX_FLAGS='-D__KDE_HAVE_GCC_VISIBILITY' \
                      -DCMAKE_SYSTEM_PREFIX_PATH=\"${prefix}\;/usr\" \
                      -DCMAKE_MODULE_PATH=\"${prefix}/share/cmake-2.8/Modules\;${prefix}/share/cmake/modules\" \
                      -DCMAKE_PREFIX_PATH=\"${prefix}/lib/cmake\" \
                      -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
                      -DOpenCV_DIR=${prefix}/lib/cmake \
                      -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 {
    configure.args-append -DCMAKE_BUILD_TYPE=releasewithdebug
}

# 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_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 version 1

variant lcms2 description {Build digiKam with LCMS2 shared libs instead 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 to compile target

variant mysql_check description {Check MySql availability before to build 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
}
