Index: files/patch-Makefile.diff
===================================================================
--- files/patch-Makefile.diff	(revision 0)
+++ files/patch-Makefile.diff	(revision 0)
@@ -0,0 +1,14 @@
+--- Makefile.orig	2010-06-11 10:47:00.000000000 +0400
++++ Makefile	2010-06-11 11:25:31.000000000 +0400
+@@ -58,6 +58,11 @@
+ examples: tbb tbbmalloc
+ 	$(MAKE) -C examples -r -f Makefile tbb_root=.. release test
+ 
++install: tbb tbbmalloc
++	$(shell cp $(work_dir)_release/lib*.dylib $(DESTDIR)@PREFIX@/lib)
++	$(shell cp -r $(work_dir)_release/../../include/tbb $(DESTDIR)@PREFIX@/include/tbb)
++	$(shell cp $(work_dir)_release/tbbvars.*sh $(DESTDIR)@PREFIX@/bin)
++
+ .PHONY: clean clean_examples mkdir info
+ 
+ clean: clean_examples
Index: files/patch-build_generate_tbbvars.sh.diff
===================================================================
--- files/patch-build_generate_tbbvars.sh.diff	(revision 0)
+++ files/patch-build_generate_tbbvars.sh.diff	(revision 0)
@@ -0,0 +1,24 @@
+--- build/generate_tbbvars.sh.orig	2010-06-11 11:30:32.000000000 +0400
++++ build/generate_tbbvars.sh	2010-06-11 11:36:20.000000000 +0400
+@@ -34,8 +34,8 @@
+ [ "`uname`" = "Darwin" ] && dll_path="DYLD_LIBRARY_PATH" || dll_path="LD_LIBRARY_PATH" #
+ [ -f ./tbbvars.sh ] || cat >./tbbvars.sh <<EOF
+ #!/bin/bash
+-export TBB30_INSTALL_DIR="${tbb_root}" #
+-tbb_bin="${bin_dir}" #
++export TBB30_INSTALL_DIR="@PREFIX@" #
++tbb_bin="@PREFIX@/lib" #
+ if [ -z "\$CPATH" ]; then #
+     export CPATH="\${TBB30_INSTALL_DIR}/include" #
+ else #
+@@ -55,8 +55,8 @@
+ EOF
+ [ -f ./tbbvars.csh ] || cat >./tbbvars.csh <<EOF
+ #!/bin/csh
+-setenv TBB30_INSTALL_DIR "${tbb_root}" #
+-setenv tbb_bin "${bin_dir}" #
++setenv TBB30_INSTALL_DIR "@PREFIX@" #
++setenv tbb_bin "@PREFIX@/lib" #
+ if (! \$?CPATH) then #
+     setenv CPATH "\${TBB30_INSTALL_DIR}/include" #
+ else #
Index: files/patch-build_macos.inc.diff
===================================================================
--- files/patch-build_macos.inc.diff	(revision 0)
+++ files/patch-build_macos.inc.diff	(revision 0)
@@ -0,0 +1,25 @@
+--- build/macos.inc.orig	2010-06-11 01:45:01.000000000 +0400
++++ build/macos.inc	2010-06-11 01:52:05.000000000 +0400
+@@ -25,21 +25,7 @@
+ # the GNU General Public License.
+ 
+ ####### Detections and Commands ###############################################
+-ifndef arch
+- ifeq ($(shell /usr/sbin/sysctl -n hw.machine),Power Macintosh)
+-   ifeq ($(shell /usr/sbin/sysctl -n hw.optional.64bitops),1)
+-     export arch:=ppc64
+-   else
+-     export arch:=ppc32
+-   endif
+- else
+-   ifeq ($(shell /usr/sbin/sysctl -n hw.optional.x86_64 2>/dev/null),1)
+-     export arch:=intel64
+-   else
+-     export arch:=ia32
+-   endif
+- endif
+-endif
++export arch:=$(if $(findstring x86_64,$(shell pwd)),intel64,ia32)
+ 
+ ifndef runtime
+  #gcc_version:=$(shell gcc -v 2>&1 | grep 'gcc version' | sed -e 's/^gcc version //' | sed -e 's/ .*$$//' )
Index: Portfile
===================================================================
--- Portfile	(revision 68422)
+++ Portfile	(working copy)
@@ -2,12 +2,13 @@
 # $Id$
 
 PortSystem          1.0
+PortGroup           muniversal 1.0
 
 name                tbb
-set rel_date        20090809
-set vers            2.2
+set rel_date        20100406
+set vers            3.0
 version             ${vers}-${rel_date}
-revision            1
+revision            0
 maintainers         mnick openmaintainer
 
 categories          devel
@@ -19,47 +20,53 @@
 platforms           darwin
 
 homepage            http://www.threadingbuildingblocks.org
-master_sites        ${homepage}/uploads/77/142/${vers}/
-worksrcdir          ${name}22_${rel_date}oss
+master_sites        ${homepage}/uploads/77/151/${vers}/
+worksrcdir          ${name}30_${rel_date}oss
 distname            ${worksrcdir}_src
 extract.suffix      .tgz
 
-checksums           md5     c621053887c7ee86932da43e2deb3bff \
-                    sha1    12af8e2bdddb51aa62312523a70ebf2a0f6de8d6 \
-                    rmd160  2c0fac8c9ef3648dcf3d1f2b03a56672ab4eaab2
+checksums           md5     645aeaa5473e7a8986cd629c5f7262bb \
+                    sha1    0c10aaa7f60762a4a2c2c907a2fee552eba4132c \
+                    rmd160  52882e20b0753b669bda60bce7f61f20f3245a86
 
-universal_variant   no
 build.target        tbb tbbmalloc
 
-configure {
-    if {${build_arch} eq "i386"} {
-        set arch_flag intel32
-    } elseif {${build_arch} eq "x86_64"} {
-        set arch_flag intel64
-    }
-    build.env-append    arch=${arch_flag}
-    test.env-append     arch=${arch_flag}
+patchfiles          patch-Makefile.diff \
+                    patch-build_macos.inc.diff \
+                    patch-build_generate_tbbvars.sh.diff
+
+if {![variant_isset universal]} {
+    patchfiles-delete patch-build_macos.inc.diff
 }
 
-destroot {
-    set build_dir [exec sh -c "cd ${worksrcpath} && ${build.env} make info | grep build_prefix | cut -f2 -d'='"]
-    set build_dir "${worksrcpath}/build/${build_dir}_release"
-    
-    # fix paths
-    reinplace "s|\\(TBB22_INSTALL_DIR.\\)\".*\"|\\1\"${prefix}\"|g" \
-        ${build_dir}/tbbvars.sh ${build_dir}/tbbvars.csh
-    reinplace "s|\\(tbb_bin.\\)\".*\"|\\1\"${prefix}/lib\"|g" \
-        ${build_dir}/tbbvars.sh ${build_dir}/tbbvars.csh
+post-patch {
+    reinplace "s|@PREFIX@|${prefix}|g" \
+        ${worksrcpath}/Makefile ${worksrcpath}/build/generate_tbbvars.sh
 
-    # copy lib, include & bin
-    eval file copy [glob ${build_dir}/lib*.dylib] ${destroot}${prefix}/lib
-    eval file copy [glob ${build_dir}/tbbvars.*sh] ${destroot}${prefix}/bin
-    file copy ${worksrcpath}/include/tbb ${destroot}${prefix}/include/tbb
-    
+    # create fake configure for muniversal variant
+    touch ${worksrcpath}/configure
+    system "chmod 755 ${worksrcpath}/configure"
+
+    # delete unnecessary files
+    file delete -force ${worksrcpath}/include/tbb/index.html
+}
+
+
+if {${build_arch} eq "i386"} {
+    set arch_flag ia32
+} elseif {${build_arch} eq "x86_64"} {
+    set arch_flag intel64
+}
+
+build.env-append    arch=${arch_flag}
+destroot.env-append arch=${arch_flag}
+test.env-append     arch=${arch_flag}
+
+post-destroot {
     # fix install_name paths
     system "install_name_tool -id ${prefix}/lib/libtbb.dylib ${destroot}${prefix}/lib/libtbb.dylib"
     system "install_name_tool -id ${prefix}/lib/libtbbmalloc.dylib ${destroot}${prefix}/lib/libtbbmalloc.dylib"
-    
+
     # copy examples & docs
     file mkdir ${destroot}${prefix}/share/${name}
     file copy ${worksrcpath}/doc ${destroot}${prefix}/share/${name}/doc
