--- Portfile.orig	2013-04-25 18:03:32.000000000 +0200
+++ Portfile	2013-06-23 15:21:08.000000000 +0200
@@ -6,75 +6,161 @@
 PortGroup           compiler_blacklist_versions 1.0
 
 name                digikam
-version             3.1.0
+version             3.2.0
 revision            0
 categories          kde kde4
 license             GPL-2+
-maintainers         hyper-world.de:jan openmaintainer
+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        http://download.kde.org/stable/digikam
+master_sites        kde:stable/digikam/
 
-checksums \
-    rmd160  511550a7ee37aac958a0d2e5afaa0a07aa1eab0e \
-    sha256  f70fc84f3a680a855642fcc4664710116406bbe4068b0ad4d2cfb4127684c2aa
+checksums           rmd160 9bec9eff889a9bf90e898ad52dfb1cfd50d1d548 \
+                    sha256 bd7204d42c4ef73f22e757ba5daa334073bd02ccc054c31780786d2b1a2a481a
 
 use_bzip2           yes
 
-patchfiles          extra_kipi-plugins_CMakeLists.txt.patch
+# List of whole dependencies ###############################################
+
+# Dependencies of digiKam and Kipi-plugins
 
-# Dependencies of Digikam and kipi-plugins.
 depends_lib-append  port:kdelibs4 \
-                    port:libkdcraw \
-                    port:libkexiv2 \
-                    port:libkipi \
-                    port:libpng \
-                    port:qt4-mac \
                     port:kdepimlibs4 \
-                    port:tiff
+                    port:qt4-mac \
+                    port:tiff \
+                    port:jpeg \
+                    port:libpng \
+                    port:opencv \
+                    port:marble 
+
+# Dependencies of kipi-plugins
 
-# Dependencies of kipi-plugins.
 depends_lib-append  port:expat\
                     port:gdk-pixbuf2 \
-                    port:jpeg \
                     port:libgpod \
-                    port:libksane \
                     port:libxml2 \
                     port:libxslt \
-                    port:marble \
-                    port:opencv \
                     port:qca \
-                    port:qjson
+                    port:qjson \
+                    port:ImageMagick \
+                    port:eigen3
 
 # opencv is not universal
+
 universal_variant   no
 
-# Dependencies of Digikam.
+# Dependencies of digiKam
+
 depends_lib-append  port:boost \
                     port:gettext \
                     path:lib/pkgconfig/glib-2.0.pc:glib2 \
-                    port:lcms \
                     port:lensfun \
                     port:libgphoto2 \
                     port:liblqr \
                     port:libusb \
                     port:jasper \
-                    path:bin/mysql_config5:mysql5 \
                     port:shared-desktop-ontologies
 
-depends_run-append  port:oxygen-icons port:qt4-mac-sqlite3-plugin
+# 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}
 
-configure.args-append \
-    -DOpenCV_DIR=${prefix}/lib/cmake \
-    -DDIGIKAMSC_USE_PRIVATE_KDEGRAPHICS=off \
-    -DCMAKE_BUILD_TYPE=release \
-    ../${distname}
+# 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
+}
