--- Portfile.orig	2009-09-27 23:37:17.000000000 +0200
+++ Portfile	2009-09-28 00:20:11.000000000 +0200
@@ -3,6 +3,7 @@
 PortSystem          1.0
 name                john
 version             1.7.0.2
+revision            1
 categories          sysutils security
 maintainers         nomaintainer
 description         Featureful Unix password cracker
@@ -32,27 +33,46 @@
 checksums           md5 0a87dca1f149493fc087ea8a8b6ae5d5 \
                     sha1 bc6895c986d65f502366cf93c91f88ba865572b6 \
                     rmd160 9e75f5fd5561595ec2f3a1a290e85605234b8c41
+
 worksrcdir          ${distname}/src
 
+use_parallel_build  no
+
+patchfiles          patch-src-Makefile.diff \
+                    patch-src-john.c.diff
+
+use_configure       no
+
 post-patch {
-    if {[variant_isset powerpc]} {
-    reinplace "s,CFLAGS =,CFLAGS = -DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_EXEC=\\\\\\\\\\\\\"${prefix}/share/john\\\\\\\\\\\\\" -DJOHN_SYSTEMWIDE_HOME=\\\\\\\\\\\\\"${prefix}/share/john\\\\\\\\\\\\\",g" ${worksrcpath}/Makefile
-    reinplace "s,CFLAGS=\",CFLAGS=\"-DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_EXEC=\\\\\\\\\\\\\"${prefix}/share/john\\\\\\\\\\\\\" -DJOHN_SYSTEMWIDE_HOME=\\\\\\\\\\\\\"${prefix}/share/john\\\\\\\\\\\\\" ,g" ${worksrcpath}/Makefile
-    } else {
-        reinplace "s,CFLAGS =,CFLAGS = -DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_EXEC=\\\\\\\"${prefix}/share/john\\\\\\\" -DJOHN_SYSTEMWIDE_HOME=\\\\\\\"${prefix}/share/john\\\\\\\",g" ${worksrcpath}/Makefile
-        reinplace "s,CFLAGS=\",CFLAGS=\"-DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_EXEC=\\\\\\\"${prefix}/share/john\\\\\\\" -DJOHN_SYSTEMWIDE_HOME=\\\\\\\"${prefix}/share/john\\\\\\\" ,g" ${worksrcpath}/Makefile
-    }
+    reinplace "s,\$JOHN,${prefix}/share/john,g" ${workpath}/${distname}/run/john.conf
+    reinplace "s,\$JOHN/john.conf,${prefix}/share/john/john.conf,g" ${workpath}/${distname}/src/params.h
+    reinplace "s,\$JOHN/password.lst,${prefix}/share/john/password.lst,g" ${workpath}/${distname}/src/params.h
+}
+
+if {[variant_isset powerpc]} {
+    build.args-append	CFLAGS=\"-c -Wall -O2 -fomit-frame-pointer -DJOHN_SYSTEMWIDE_EXEC=\\\\\\\\\\\\\"${prefix}/share/john\\\\\\\\\\\\\" -DJOHN_SYSTEMWIDE_HOME=\\\\\\\\\\\\\"${prefix}/share/john\\\\\\\\\\\\\" \"
+} else {
+    build.args-append	CFLAGS=\"-c -Wall -O2 -fomit-frame-pointer -DJOHN_SYSTEMWIDE_EXEC=\\\\\\\"${prefix}/share/john\\\\\\\" -DJOHN_SYSTEMWIDE_HOME=\\\\\\\"${prefix}/share/john\\\\\\\" \"
 }
-use_configure       no
 
-platform powerpc {
+platform powerpc {   
     build.target    "clean macosx-ppc32"
 }
-platform i386 {
+
+variant altivec {
+    build.target    "clean macosx-ppc32-altivec"
+}
+
+platform darwin 9 {
     build.target    "clean macosx-x86-mmx"
 }
-variant altivec conflicts i386 {
-    build.target    "clean macosx-ppc32-altivec"
+
+platform darwin 10 { 
+        if {$build_arch == "x86_64"} {
+                build.target    "clean macosx-x86-64"
+        } else {
+		build.target    "clean macosx-x86-mmx"
+	}
 }
 
 destroot {

