--- /Users/mfeiri/Desktop/macports_patches/llvmCompare.txt	2010-03-15 02:08:36.000000000 +0100
+++ /Users/mfeiri/Desktop/macports_patches/llvm/Portfile	2010-03-18 02:53:00.000000000 +0100
@@ -8,7 +8,8 @@
 categories              lang
 platforms               darwin
 use_parallel_build      yes
-maintainers             erickt openmaintainer
+maintainers             feiri.de:macports erickt openmaintainer
+license                 University of Illinois/NCSA Open Source License
 description             llvm is a next generation compiler infrastructure
 long_description        llvm brings tools to work on the llvm intermediate \
                         language incl. a C and C++ frontend.
@@ -16,12 +17,18 @@
 homepage                http://llvm.org/
 master_sites            ${homepage}releases/${version}/
 
-checksums               md5     34a11e807add0f4555f691944e1a404a \
-                        sha1    547471147cbf6d3e49539e01196ffada2c79c250 \
-                        rmd160  24d58cb052ab5879aae59eaf4885ec41186ee22a
+checksums               ${distname}${extract.suffix} \
+                            md5     34a11e807add0f4555f691944e1a404a \
+                            sha1    547471147cbf6d3e49539e01196ffada2c79c250 \
+                            rmd160  24d58cb052ab5879aae59eaf4885ec41186ee22a \
+                        clang-${version}${extract.suffix} \
+                            md5     09d696bf23bb4a3cf6af3c7341cdd946 \
+                            sha1    188f29ad3b2c64fcdc791aa34b323ed06452d7ae \
+                            rmd160  b7e44abbf28902ff8e3fd4578a5ff9dd34f40817
 
-depends_lib             path:bin/perl:perl5
+depends_run             bin:perl:perl5
 
+default_variants        +clang +checker
 universal_variant       no
 
 configure.dir           ${workpath}/build
@@ -43,7 +50,11 @@
                         --disable-assertions
 
 if {[info exists build_arch] && ${os.platform} == "darwin"} {
-    configure.args-append --build=${build_arch}-apple-darwin${os.major}
+    if {${build_arch} == "i386" } {
+        configure.pre_args-append --build=$i686-apple-darwin${os.major}
+    } else {
+        configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
+    }
 }
 
 post-destroot {
@@ -59,12 +70,6 @@
                                                                 ${destroot}${prefix}/lib/llvm/obj/Release-Asserts/bin/llvm-config
     reinplace "s|${configure.dir}|${prefix}/lib/llvm/obj|g"     ${destroot}${prefix}/bin/llvm-config \
                                                                 ${destroot}${prefix}/lib/llvm/obj/Release-Asserts/bin/llvm-config
-
-    fs-traverse item ${destroot} {
-        if {[file isfile ${item}] && ".dir" == [file tail ${item}]} {
-            delete ${item}
-        }
-    }
 }
 
 variant ocaml description {Enable generation of OCaml binding} {
@@ -85,6 +90,52 @@
     configure.args-append --enable-targets=host-only
 }
 
+variant clang description {Install clang frontend} {
+    distfiles-append    clang-${version}${extract.suffix}
+    post-extract {
+        move ${workpath}/clang-${version} ${worksrcpath}/tools/clang
+    }
+}
+
+variant checker requires clang description {Install checker tools} {
+    depends_run-append  bin:python:python26
+    post-destroot {
+        reinplace "s|/usr/bin/env perl|${prefix}/bin/perl|g" ${worksrcpath}/tools/clang/utils/ccc-analyzer
+        reinplace "s|/usr/bin/env perl|${prefix}/bin/perl|g" ${worksrcpath}/tools/clang/utils/scan-build
+        reinplace "s|/usr/bin/env python|${prefix}/bin/python|g" ${worksrcpath}/tools/clang/tools/scan-view/scan-view
+        xinstall -W ${worksrcpath}/tools/clang/utils \
+            scanview.css \
+            ccc-analyzer \
+            scan-build \
+            sorttable.js \
+            ${destroot}${prefix}/bin
+        xinstall -W ${worksrcpath}/tools/clang/tools/scan-view \
+            Reporter.py \
+            ScanView.py \
+            scan-view \
+            startfile.py \
+            ${destroot}${prefix}/bin
+        file mkdir ${destroot}${prefix}/bin/Resources
+        xinstall -W ${worksrcpath}/tools/clang/tools/scan-view/Resources \
+            FileRadar.scpt \
+            GetRadarVersion.scpt \
+            bugcatcher.ico \
+            ${destroot}${prefix}/bin/Resources
+    }
+}
+
+# installing libLTO globally is a viable workaround on darwin 9 and 10
+# a proper solution would depend on updated odcctools or a port of ld64
+# see http://trac.macports.org/ticket/19679 for more information
+variant lto description {Enable link time optimizations} {
+    #depends_run-append  port:odcctools
+    #depends_run-append  port:ld64
+    post-destroot {
+        file mkdir ${destroot}/usr/lib
+        ln -s ${prefix}/lib/libLTO.dylib ${destroot}/usr/lib/libLTO.dylib
+    }
+}
+
 livecheck.type  regex
 livecheck.url   ${homepage}releases/
-livecheck.regex {'(\d+(?:\.\d+)*)'}
+livecheck.regex {'(\d+\.\d+)'}
