--- Portfile.orig	2015-02-10 20:02:22.000000000 +0100
+++ Portfile	2015-02-10 20:03:53.000000000 +0100
@@ -1,36 +1,97 @@
 # -*- 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 105138 2013-04-11 21:29:42Z ryandesign@macports.org $
+# $Id$
 
 PortSystem              1.0
+PortGroup               github 1.0
 
-name                    yara
-version                 1.7
+github.setup			plusvic yara 3.3.0 v 
+revision                0
 categories              security
-license                 GPL-2+
 platforms               darwin
+license                 Apache-2.0
 maintainers             yendor.net:a.schuster \
                         openmaintainer
                         
-description             Malware identification and classification tool
+description             The pattern matching swiss knife for malware researchers
 long_description \
     YARA is a tool aimed at helping malware researchers to identify and \
     classify malware samples.
 
-homepage                http://code.google.com/p/yara-project/
-master_sites            googlecode:yara-project
+homepage                http://${github.author}.github.io/${github.project}/
+master_sites            https://github.com/${github.author}/${github.project}/archive/
+distname                v${version}
+checksums				rmd160  330de9de9294953a3a42032ccc5ae849f065ab5e \
+                        sha256  e5f4359082e35ff00ee94af9ee897bb0ab18abf49a2c4fe45968d7a848e5bd83
+
+# specifics for yara library and tools
+
+if {${subport} eq ${name}} {
+
+	worksrcdir				${github.project}-${version}
+	
+	use_configure           yes
+	pre-configure {
+		system -W ${worksrcpath} "/bin/sh bootstrap.sh"
+	}
+
+	depends_build           port:automake \
+	                        port:libtool
+	
+	test.run                no
+	
+	variant cuckoo description {Add support for Cuckoo sandbox} {
+		depends_lib-append			port:jansson
+		configure.args-append		--enable-cuckoo
+	}
+
+	variant hash description {Add md5, sha1, and sha256 hash functions} {
+		depends_lib-append			port:openssl
+		configure.args-append		--enable-hash \
+									--with-crypto
+	}
+
+	variant magic description {Add filetype detection by libmagic} {
+		depends_lib-append			port:libmagic
+		configure.args-append		--enable-magic
+	}	
+	
+	variant math description {Add entropy tests and other helper functions} {
+		configure.args-append		--enable-math
+	}
+}
 
-checksums               rmd160  12ca8b2eb7a8b7de3fae8d97e728d4847299d99a \
-                        sha256  fcee06a2f43ab65c88597de54d630a3beee925e7e84c890a8303f08a3fc85c91
 
-depends_lib             port:pcre
+# specifics for python bindings
 
-post-patch {
-    # fix use of inline for clang compatibility
-    reinplace "s|inline|static inline|g" ${worksrcpath}/libyara/scan.c
-}
+set python.versions {26 27 31 32 33 34}
 
-variant re2 description "uses re2 library instead of pcre for regular expression parsing" {
-    configure.args-append   --with-re2
-    depends_lib-append      port:re2
-    depends_lib-delete      port:pcre
+foreach v ${python.versions} {
+	set python.version			${v}
+	set python.branch			[string range ${python.version} 0 end-1].[string index ${python.version} end]
+	set python.bin				${prefix}/bin/python${python.branch}
+    set python.prefix			${frameworks_dir}/Python.framework/Versions/${python.branch}
+
+    subport py${python.version}-${name} {
+		categories              security python
+		description             ${name} bindings for python ${python.branch}
+		long_description		${long_description}\
+			This subport provides bindings for python ${python.branch}.
+		
+		worksrcdir				${github.project}-${version}/yara-python
+		
+		depends_lib-append      port:${name} \
+                                port:python${python.version}
+
+		use_configure			no
+			
+		build.cmd				${python.bin} setup.py --no-user-cfg
+		build.target			build
+		
+		destroot.cmd			${python.bin} setup.py --no-user-cfg
+		destroot.destdir		--prefix=${python.prefix} --root=${destroot}
+		
+		test.run				yes
+		test.cmd				${python.bin}
+		test.target				tests.py
+    }
 }
