--- Portfile.orig	2013-07-15 09:03:18.000000000 -0700
+++ Portfile	2016-01-31 09:25:34.000000000 -0700
@@ -1,9 +1,10 @@
+# -*- 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 96951 2012-08-22 18:22:18Z blair@macports.org $
 
 PortSystem 1.0
-                
+
 name            openexr
-version         1.7.0
+version         2.2.0
 categories      graphics
 license         BSD
 maintainers     blair
@@ -11,24 +12,83 @@
 long_description \
     OpenEXR is a high dynamic-range (HDR) image file format developed \
     by Industrial Light & Magic for use in computer imaging applications.
-homepage        http://www.openexr.org
+homepage        http://www.openexr.com
 platforms       darwin
 master_sites    http://savannah.nongnu.org/download/openexr
-checksums       md5     27113284f7d26a58f853c346e0851d7a \
-                sha1    91d0d4e69f06de956ec7e0710fc58ec0d4c4dc2b \
-                rmd160  410ae4490988067cc80324e776b52ae6a261f157
+checksums       rmd160  a825ed42e731da3bc39f25ce2a310712a5b0f956 \
+                sha256  36a012f6c43213f840ce29a8b182700f6cf6b214bea0d5735594136b44914231
+
+if {${subport} ne "ilmbase"} {
+    depends_build   port:pkgconfig
+}
+
+if {${subport} eq ${name}} {
+    # ImfCompressor.h is included in other header files
+    # see #49965
+    # see also https://lists.nongnu.org/archive/html/openexr-devel/2013-06/msg00001.html
+    patchfiles \
+        patch-IlmImf-Makefile.am.diff \
+        patch-IlmImf-Makefile.in.diff
+}
 
-depends_build   port:libtool
-depends_lib     port:ilmbase
+subport ilmbase {
+    distname    ilmbase-${version}
+    checksums   \
+        rmd160  b1adb0c96eff6b3554ddaf8f8bafe2cba8c114e3 \
+        sha256  ecf815b60695555c1fbc73679e84c7c9902f4e8faa6e8000d2f905b8b86cedc7
+}
 
-patchfiles      patch-configure
+set python_versions {27 34 35}
 
-configure.args  --mandir=${prefix}/share/man \
-                --infodir=${prefix}/share/info
+foreach pver ${python_versions} {
+    subport py${pver}-pyilmbase {
+        PortGroup   active_variants 1.1
+        distname    pyilmbase-${version}
+        checksums                \
+            rmd160  9a6b711a2842b1e0124a43fc1c2148a2e7802710 \
+            sha256  68c968fec5c40930a2c692ccc88990faa50320ed74b88553a3632d7d02c87e1a
+
+        # so long as boost can only be installed with one version of python at a time,
+        #    conflict with all other pyilmbase ports
+        foreach over ${python_versions} {
+            if {${over} ne ${pver}} {
+                conflicts-append py${over}-pyilmbase
+            }
+        }
+
+        configure.args-append   \
+            --with-boost-python-libname=boost_python-mt
+
+        set pbranch [string range ${pver} 0 end-1].[string index ${pver} end]
+        configure.python ${prefix}/bin/python${pbranch}
+
+        depends_lib-append     \
+            port:ilmbase       \
+            port:python${pver} \
+            port:boost         \
+            port:py${pver}-numpy
 
-post-configure {
-    copy -force ${prefix}/bin/glibtool ${worksrcpath}/libtool
+        require_active_variants boost python${pver}
+    }
+}
+
+subport openexr_viewers {
+    distname    openexr_viewers-${version}
+    checksums   rmd160  5f3edc7a0c706faa75a9cd205c0ac85e988c6e09 \
+                sha256  f73fe2e4d19e8fc9317d6c34f156598ad43497bb9549f03feacb8ba095dd04e9
+
+    depends_lib-append  \
+        port:openexr                \
+        path:lib/libfltk.dylib:fltk \
+        port:ctlang
+
+    # do not attempt to build application bundle
+    patchfiles-append   patch-fltk.diff
 }
 
 test.run        yes
 test.target     check
+
+livecheck.type  regex
+livecheck.url   ${homepage}/downloads.html
+livecheck.regex ${name}-(\\d+(?:\\.\\d+)*)
