--- Portfile.orig	2010-08-03 15:16:36.000000000 +0200
+++ Portfile	2010-08-05 09:09:32.000000000 +0200
@@ -1,10 +1,11 @@
+# -*- 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 66756 2010-04-22 04:18:46Z ryandesign@macports.org $
 
 PortSystem                      1.0
+PortGroup                       cmake 1.0
 
 name                            opencv
-version                         2.0.0
-revision                        1
+version                         2.1.0
 categories                      graphics science
 platforms                       darwin
 maintainers                     gmail.com:stante
@@ -24,40 +25,68 @@
 use_bzip2                       yes
 distname                        OpenCV-${version}
 
-checksums                       md5     ed27520514baacc5edad7b06ad24130e \
-                                sha1    2090c2aaff77c3b0cc669c2ee81bea389db0a366 \
-                                rmd160  f46b993ded3d579dc52175131e5485476ac1f569
+checksums                       md5     1d71584fb4e04214c0085108f95e24c8 \
+                                sha1    8e2d6b653296364ab2ca0fa5a5e6b0edfca114a7 \
+                                rmd160  e31cdbd30e7925e3725f5957616ffc59c58db247
 
 depends_build-append            port:pkgconfig
 
-depends_lib-append              port:gtk2 port:zlib port:jpeg \
-                                port:libpng port:tiff path:lib/libavcodec.dylib:ffmpeg
+depends_lib-append              port:zlib \
+                                path:lib/libavcodec.dylib:ffmpeg \
+                                port:bzip2 \
+                                port:dirac \
+                                port:faac \
+                                port:faad2 \
+                                port:lame \
+                                port:schroedinger \
+                                port:liboil \
+                                port:libtheora \
+                                port:libvorbis \
+                                port:libogg \
+                                port:x264 \
+                                port:libdc1394 \
+                                port:orc
+
+patchfiles                      patch-CMakeLists.txt.diff
+if {[variant_isset universal]} {
+    patchfiles-append           patch-pch-CMakeLists.txt.diff
+}
 
-# ffmpeg is not universal.
-# If universal support is to be added to opencv, careful consideration has
-# to be given to the 64-bit issues with QuickTime and Carbon.
-universal_variant               no
-
-configure.args                  --without-python
-
-switch ${build_arch} {
-    ppc64 -
-    x86_64 {
-        configure.args-append   --without-quicktime \
-                                --without-carbon
+post-patch {
+    if {[variant_isset python26]} {
+        reinplace "s|@@PYTHON_PKGD@@|${frameworks_dir}/Python.framework/Versions/2.6/lib/python2.6/site-packages|g" ${worksrcpath}/CMakeLists.txt
     }
-    ppc {
-        patchfiles-append       patch-G4.diff
+}
+
+configure.args-append           -DBUILD_NEW_PYTHON_SUPPORT=OFF \
+                                -DBUILD_EXAMPLES=ON \
+                                -DINSTALL_C_EXAMPLES=ON \
+                                -DBZIP2_LIBRARIES=${prefix}/lib/libbz2.dylib
+
+# use macros in /usr/include/stdint.h with C++ compiler; see <https://roundup.ffmpeg.org/issue2093>
+platform darwin {
+    if {${os.major} <= 9} {
+        configure.args-append   -DCMAKE_CXX_FLAGS=-D__STDC_CONSTANT_MACROS
     }
 }
 
-# For some reason the highgui module forgets to link against libavutil
-configure.ldflags-append        -lavutil
+variant python26 description {Add Python 2.6 bindings} {
+    depends_lib-append          port:python26
+    configure.args-delete       -DBUILD_NEW_PYTHON_SUPPORT=OFF
+    configure.args-append       -DINSTALL_PYTHON_EXAMPLES=ON \
+                                -DPYTHON_LIBRARY=${prefix}/lib/libpython2.6.dylib \
+                                -DPYTHON_INCLUDE_DIR=${frameworks_dir}/Python.framework/Versions/2.6/Headers
+}
 
-post-destroot {
-    xinstall -m 644 ${worksrcpath}/cvconfig.h ${destroot}${prefix}/include/${name}
+variant tbb description {Use Intel TBB} {
+    depends_lib-append          port:tbb
+    configure.args-append       -DWITH_TBB=ON \
+                                -DHAVE_TBB=ON \
+                                -DTBB_INCLUDE_DIRS=${prefix}/include \
+                                -DTBB_LIBRARY_DIRS=${prefix}/lib \
+                                -DOPENCV_LINKER_LIBS="-ltbb -ltbbmalloc"
 }
 
 livecheck.type                  regex
 livecheck.url                   http://sourceforge.net/projects/opencvlibrary/files/
-livecheck.regex                 {OpenCV-([0-9.]+)\.tar}
+livecheck.regex                 "OpenCV-(\\d+(?:\\.\\d+)*)${extract.suffix}/download"
