--- _orig/lang/itcl//Portfile	2013-07-15 12:02:57.000000000 -0400
+++ lang/itcl//Portfile	2014-11-30 14:45:43.000000000 -0500
@@ -1,74 +1,118 @@
+# -*- 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 91510 2012-04-03 21:59:59Z jeremyhu@macports.org $
 
 PortSystem 1.0
 
-name			itcl
-version			3.4b1
-categories		lang
-license			Tcl/Tk
-maintainers		nomaintainer
-description		Object oriented extension to Tcl.
-long_description	${description}
-homepage		http://incrtcl.sourceforge.net/
-platforms		darwin
-master_sites		sourceforge:incrtcl:itcl \
-			sourceforge:tcl:tcl
-dist_subdir		tcltk
-distname                ${name}${version}
+name                itcl
+version             4.0.2
+categories          lang
+license             Tcl/Tk
+maintainers         nomaintainer
+description         Object oriented extension to Tcl.
+long_description    ${description}
+homepage            http://incrtcl.sourceforge.net/
+platforms           darwin
+master_sites        sourceforge:incrtcl:itcl \
+                    sourceforge:tcl:tcl
+dist_subdir         tcltk
+distname            ${name}${version}
 # Set tclv and md5 checksum to the current MacPorts Tcl port version, though port doesn't
 # break if they aren't in sync.
 
-set tclv		8.5.9
+set vstub           ${version}
+set tclv            8.6.2
+distfiles           ${distname}.tar.gz:itcl \
+                    tcl${tclv}-src.tar.gz:tcl
+depends_build       port:tcl port:tk
+build.args          CPPFLAGS=-I${prefix}/include
+
+configure.env       TCLROOT=${prefix}
+configure.cflags    "-I${workpath}/tcl${tclv}/generic -I${workpath}/tcl${tclv}/unix"
+#configure.ldflags-append    "-tcl8.5"
+
+## FIXME! Error: org.macports.activate for port itcl returned: Image error: /opt/local/include/itcl.h is being used by the active tcl port. + many other files...
+configure.args      --with-tcl=${prefix}/lib \
+                    --includedir=${prefix}/include/itcl
 
-distfiles		${distname}.tar.gz:itcl \
-				tcl${tclv}-src.tar.gz:tcl
-checksums		${distname}.tar.gz md5 e4c97750c08ab47e960b91911fdd0132 \
-				tcl${tclv}-src.tar.gz md5 8512d8db3233041dd68a81476906012a
-depends_build           port:tcl port:tk
-build.args		CPPFLAGS=-I${prefix}/include
-worksrcdir              ${name}3.4
-
-configure.env		TCLROOT=${prefix}
-configure.cflags	"-I${workpath}/tcl${tclv}/generic -I${workpath}/tcl${tclv}/unix"
-configure.ldflags-append	"-tcl8.5"
-
-configure.args		--with-tcl=${prefix}/lib
-
-configure.universal_args-delete	--disable-dependency-tracking
+configure.universal_args-delete    --disable-dependency-tracking
 
 post-patch {
-	reinplace "s|@itcl_LIB_FILE@|${prefix}/lib/libitcl3.4.dylib|g" \
+    reinplace "s|@itcl_LIB_FILE@|${prefix}/lib/libitcl${version}.dylib|g" \
                ${worksrcpath}/itclConfig.sh.in
-	reinplace "s|@PACKAGE_VERSION@|3.4|g" \
+    reinplace "s|@PACKAGE_VERSION@|${version}|g" \
                 ${worksrcpath}/itclConfig.sh.in
-	reinplace "s|@itcl_BUILD_LIB_SPEC@|-L${prefix}/lib -litcl|g" \
+    reinplace "s|@itcl_BUILD_LIB_SPEC@|-L${prefix}/lib -litcl|g" \
                 ${worksrcpath}/itclConfig.sh.in
-	reinplace "s|@itcl_LIB_SPEC@|-L${prefix}/lib -litcl|g" \
+    reinplace "s|@itcl_LIB_SPEC@|-L${prefix}/lib -litcl|g" \
                 ${worksrcpath}/itclConfig.sh.in
-	reinplace "s|\"@PKG_LIB_FILE@\"|.. @PKG_LIB_FILE@|g" \
-		${worksrcpath}/pkgIndex.tcl.in
+    reinplace "s|\"@PKG_LIB_FILE@\"|.. @PKG_LIB_FILE@|g" \
+        ${worksrcpath}/pkgIndex.tcl.in
 }
 
 post-build {
-                system "ranlib ${worksrcpath}/libitclstub3.4.a"
+    system "ranlib ${worksrcpath}/libitclstub${vstub}.a"
 }
 
 destroot {
-	set _d ${destroot}${prefix}
-	set _w ${worksrcpath}
-	file mkdir ${_d}/lib/itcl3.4
-	xinstall -m 755 ${_w}/itclConfig.sh ${_d}/lib/itcl3.4
-	file copy -force ${_w}/pkgIndex.tcl ${_d}/lib/itcl3.4
-	file copy -force ${_w}/library/itcl.tcl ${_d}/lib/itcl3.4
-	file copy -force ${_w}/libitcl3.4.dylib ${_d}/lib
-	file copy -force ${_w}/libitclstub3.4.a ${_d}/lib
+    set _d ${destroot}${prefix}
+    set _w ${worksrcpath}
+    file mkdir ${_d}/lib/itcl${version}
+    xinstall -m 755 ${_w}/itclConfig.sh ${_d}/lib/itcl${vstub}
+    file copy -force ${_w}/pkgIndex.tcl ${_d}/lib/itcl${vstub}
+    file copy -force ${_w}/library/itcl.tcl ${_d}/lib/itcl${vstub}
+    file copy -force ${_w}/libitcl${vstub}.dylib ${_d}/lib
+    file copy -force ${_w}/libitclstub${vstub}.a ${_d}/lib
 
-	file mkdir ${_d}/include
+    file mkdir ${_d}/include/itcl4
         foreach x {itcl.h itclDecls.h itclInt.h itclIntDecls.h } {
-                file copy -force ${_w}/generic/$x ${_d}/include
+                file copy -force ${_w}/generic/$x ${_d}/include/itcl4/
         }
 
-	foreach x [glob ${_w}/doc/*.n] {
-		file copy -force $x ${_d}/share/man/mann
-	}
+    foreach x [glob ${_w}/doc/*.n] {
+        file copy -force $x ${_d}/share/man/mann
+    }
+}
+
+## FIXME! clang: error: no such file or directory: '{-I/Users/julien/.macports/opt/local/var/macports/build/_Users_julien_tmp_myports_lang_itcl/itcl3/work/tcl8.6.2/generic'
+variant universal {}
+#configure.cflags-append    "${configure.cflags} [get_canonical_archflags cc]"
+
+if {${subport} eq ${name}} {
+    checksums           itcl${version}.tar.gz \
+                        rmd160  acc09f343a57b95e7ce9ba4613963748af0a9cb8 \
+                        sha256  d93f63a52af2b6d10a1995fc03431a4b626c1a5b1a5e7868fb489ce31925e916 \
+                        tcl${tclv}-src.tar.gz \
+                        rmd160  574bffdf3e390cf6460ab4a9d4b59db0e58f2998 \
+                        sha256  86f7ae5f581dd0904d04415637ab3aef5a50986c1b6d04c340e2b1b0258da9c4
+
+    test.run            yes
+    test.target         test
+
+    conflicts ${name}3
+
+    livecheck.type     regex
+    livecheck.url       https://sourceforge.net/projects/incrtcl/files/%5Bincr%20Tcl_Tk%5D-4-source/
+    livecheck.regex     "itcl (\\d+(?:\\.\\d+)*)"
+}
+
+subport ${name}3 {
+    version                3.4.1
+    distname            itcl${version}
+    distfiles           ${distname}.tar.gz:itcl \
+                        tcl${tclv}-src.tar.gz:tcl
+    checksums           itcl${version}.tar.gz \
+                        rmd160  a3293d8e7beeee8cd308a7c56edf7c790a374ef4 \
+                        sha256  5330832ce72da97610497a58eca904287d0ff91f9ec741a4e4810d5b933c8568 \
+                        tcl${tclv}-src.tar.gz \
+                        rmd160  574bffdf3e390cf6460ab4a9d4b59db0e58f2998 \
+                        sha256  86f7ae5f581dd0904d04415637ab3aef5a50986c1b6d04c340e2b1b0258da9c4
+    worksrcdir          ${name}${version}
+
+    set vstub           3.4
+
+    conflicts ${name}
+
+    livecheck.type     regex
+    livecheck.url       https://sourceforge.net/projects/incrtcl/files/%5BIncr%20Tcl_Tk%5D-source/
+    livecheck.regex     "title=\"(\\d+(?:\\.\\d+)*)\""
 }
