--- Portfile.orig	2012-09-22 03:24:29.000000000 +0700
+++ Portfile	2013-03-23 02:33:29.000000000 +0700
@@ -3,12 +3,11 @@
 PortSystem              1.0
 
 name                    hydra
-version                 5.4
-revision                3
-distname                ${name}-${version}-src
+version                 7.4.2
 categories              security net
 platforms               darwin
 maintainers             nomaintainer
+license                 GPL-3 OpenSSL SSLeay
 
 description \
     A very fast network logon cracker which support many services
@@ -19,41 +18,90 @@
     NNTP, VNC, ICQ, Socks5, PCNFS and more services within SSL \
     support.
 
-homepage                http://www.thc.org/thc-hydra
-master_sites            http://freeworld.thc.org/releases
-checksums               md5 fa08b465d19321e77b1a0ef912eeecc1
-
-depends_lib             port:openssl port:libssh01
+homepage                https://www.thc.org/thc-hydra
+master_sites            https://www.thc.org/releases
+fetch.ignore_sslcert    yes
+
+checksums               rmd160 8b085872e96fd7ecd4c43a8bc5c3075d2ebb1806 \
+                        sha256 bdf670f8d197e1e7e03fb1bca9156ac34cd961496f1a4c3a3b7d79706d4d19df
+
+depends_lib             port:openssl \
+                        port:libssh \
+                        port:libidn \
+                        port:ncurses \
+                        port:pcre
 
+# place cut-markers and fix xhydra_support setting in line 957
 patchfiles              patch-configure.diff
 
+set incdir "${prefix}/include"
+set libdir "${prefix}/lib"
+
 post-patch {
-    reinplace "s|SSL_PATH=\"\"|SSL_PATH=\"${prefix}/lib\"|" ${worksrcpath}/configure
-    reinplace "s|SSL_IPATH=\"\"|SSL_IPATH=\"${prefix}/include\"|" ${worksrcpath}/configure
-    reinplace "s|CRYPTO_PATH=\"\"|CRYPTO_PATH=\"${prefix}/lib\"|" ${worksrcpath}/configure
-    reinplace "s|SSH_PATH=\"\"|SSH_PATH=\"${prefix}/lib/libssh01\"|" ${worksrcpath}/configure
-    reinplace "s|SSH_IPATH=\"\"|SSH_IPATH=\"${prefix}/include/libssh01\"|" ${worksrcpath}/configure
+    # Look only in Macports directories
+    reinplace "s|^INCDIRS=.*$|INCDIRS=\"${incdir}\"|g" ${worksrcpath}/configure
+    reinplace "s|^LIBDIRS=.*$|LIBDIRS=\"${libdir}\"|g" ${worksrcpath}/configure
+    reinplace "s|XLIBPATHS=\"-L/usr/lib -L/usr/local/lib -L/lib\"|XLIBPATHS=\"\"|g" ${worksrcpath}/configure
+
+    # Disable searching for libs/headers for any module NOT set as variant
+    if {![variant_isset postgresql80] && ![variant_isset postgresql81] && \
+        ![variant_isset postgresql82] && ![variant_isset postgresql83] && \
+        ![variant_isset postgresql84] && ![variant_isset postgresql90] && \
+        ![variant_isset postgresql91] && ![variant_isset postgresql92]} {
+        reinplace -E "/#@@CUT_POSTGRES/,/#CUT_POSTGRES@@/d" ${worksrcpath}/configure
+    }
+
+    if {![variant_isset mysql5] && ![variant_isset mysql51] && [variant_isset mysql55] && \
+        ![variant_isset mariadb] && ![variant_isset percona]} {
+        reinplace -E "/#@@CUT_MYSQLA/,/#CUT_MYSQLA@@/d" ${worksrcpath}/configure
+        reinplace -E "/#@@CUT_MYSQLB/,/#CUT_MYSQLB@@/d" ${worksrcpath}/configure
+    } else {
+        # Fix include path
+        reinplace "s|MYSQL_IPATH=\"\$i/mysql\"|MYSQL_IPATH=\"\$i\"|" ${worksrcpath}/configure
+    }
+
+    if {![variant_isset oracle]} {
+        reinplace -E "/#@@CUT_ORACLE/,/#CUT_ORACLE@@/d" ${worksrcpath}/configure
+    } else {
+        # Async I/O is compiled into libSystem.B.dylib
+        reinplace "s|LIBAIO=\"\"|LIBAIO=\"YES_WE_HAVE\"|g" ${worksrcpath}/configure
+    }
+
+    if {![variant_isset subversion]} {
+        reinplace -E "/#@@CUT_SVN/,/#CUT_SVN@@/d" ${worksrcpath}/configure
+    }
+    
+    # These are not in variants, because they do not exist as ports (yet)
+    reinplace -E "/#@@CUT_FB/,/#CUT_FB@@/d" ${worksrcpath}/configure
+    reinplace -E "/#@@CUT_AFP/,/#CUT_AFP@@/d" ${worksrcpath}/configure
+    reinplace -E "/#@@CUT_NCP/,/#CUT_NCP@@/d" ${worksrcpath}/configure
+    reinplace -E "/#@@CUT_SAP/,/#CUT_SAP@@/d" ${worksrcpath}/configure
+        
+    # This one is very strange, it adds /usr/kerberos/include to the path
+    # but I cannot find that it's being used anywhere. At the same time,
+    # krb5.h is in /opt/local/include, so it's found from the default search path
+    # if installed. We delete it here, because it we do not want anything from /usr,
+    # but I don't know how to otherwise disable kerberos, or that it even matters.
+    reinplace -E "/#@@CUT_KRB/,/CUT_KRB@@/d" ${worksrcpath}/configure
 }
 
 configure.args          --disable-xhydra
 
 post-configure {
     reinplace "s|CC=gcc|CC=${configure.cc}|" ${worksrcpath}/Makefile
+    reinplace "s|^OPTS=.*$|OPTS=-I. -Wall ${configure.cflags}|" ${worksrcpath}/Makefile
 }
 
-build.args              XIPATHS="-I${prefix}/include/libssh01 -I${prefix}/include" \
-                        XLIBPATHS="-L${prefix}/lib/libssh01 -L${prefix}/lib"
-
 pre-destroot {
     reinplace "s|PREFIX=${prefix}|PREFIX=${destroot}${prefix}|" ${worksrcpath}/Makefile
+    reinplace "s|/man/man1|/share/man/man1|g" ${worksrcpath}/Makefile
     set docdir ${destroot}${prefix}/share/doc/${name}-${version}
     xinstall -d ${docdir}
     xinstall -m 644 -W ${worksrcpath} \
         CHANGES \
-        LICENCE.HYDRA \
-        LICENSE.GNU \
+        LICENSE \
+        LICENSE.OPENSSL \
         README \
-        TODO \
         ${docdir}
 }
 
@@ -62,6 +110,122 @@
     configure.args-delete   --disable-xhydra
 }
 
+variant postgresql80 \
+conflicts postgresql81 postgresql82 postgresql83 postgresql84 postgresql90 postgresql91 postgresql92 \
+description {Add support for PostgreSQL 8.0} {
+    depends_lib-append    port:postgresql80
+    set incdir "${incdir} ${prefix}/include/postgresql80"
+    set libdir "${libdir} ${prefix}/lib/postgresql80"
+}
+
+variant postgresql81 \
+conflicts postgresql80 postgresql82 postgresql83 postgresql84 postgresql90 postgresql91 postgresql92 \
+description {Add support for PostgreSQL 8.1} {
+    depends_lib-append    port:postgresql81
+    set incdir "${incdir} ${prefix}/include/postgresql81"
+    set libdir "${libdir} ${prefix}/lib/postgresql81"
+}
+
+variant postgresql82 \
+conflicts postgresql80 postgresql81 postgresql83 postgresql84 postgresql90 postgresql91 postgresql92 \
+description {Add support for PostgreSQL 8.2} {
+    depends_lib-append    port:postgresql82
+    set incdir "${incdir} ${prefix}/include/postgresql82"
+    set libdir "${libdir} ${prefix}/lib/postgresql82"
+}
+
+variant postgresql83 \
+conflicts postgresql80 postgresql81 postgresql82 postgresql84 postgresql90 postgresql91 postgresql92 \
+description {Add support for PostgreSQL 8.3} {
+    depends_lib-append    port:postgresql83
+    set incdir "${incdir} ${prefix}/include/postgresql83"
+    set libdir "${libdir} ${prefix}/lib/postgresql83"
+}
+
+variant postgresql84 \
+conflicts postgresql80 postgresql81 postgresql82 postgresql83 postgresql90 postgresql91 postgresql92 \
+description {Add support for PostgreSQL 8.4} {
+    depends_lib-append    port:postgresql84
+    set incdir "${incdir} ${prefix}/include/postgresql84"
+    set libdir "${libdir} ${prefix}/lib/postgresql84"
+}
+
+variant postgresql90 \
+conflicts postgresql80 postgresql81 postgresql82 postgresql83 postgresql84 postgresql91 postgresql92 \
+description {Add support for PostgreSQL 9.0} {
+    depends_lib-append    port:postgresql90
+    set incdir "${incdir} ${prefix}/include/postgresql90"
+    set libdir "${libdir} ${prefix}/lib/postgresql90"
+}
+
+variant postgresql91 \
+conflicts postgresql80 postgresql81 postgresql82 postgresql83 postgresql84 postgresql90 postgresql92 \
+description {Add support for PostgreSQL 9.1} {
+    depends_lib-append    port:postgresql91
+    set incdir "${incdir} ${prefix}/include/postgresql91"
+    set libdir "${libdir} ${prefix}/lib/postgresql91"
+}
+
+variant postgresql92 \
+conflicts postgresql80 postgresql81 postgresql82 postgresql83 postgresql84 postgresql90 postgresql91 \
+description {Add support for PostgreSQL 9.2} {
+    depends_lib-append    port:postgresql92
+    set incdir "${incdir} ${prefix}/include/postgresql92"
+    set libdir "${libdir} ${prefix}/lib/postgresql92"
+}
+
+variant mysql5 conflicts mysql51 mysql55 mariadb percona description {Add support for MySQL5} {
+    depends_lib-append    port:mysql5
+    set incdir "${incdir} ${prefix}/include/mysql5"
+    set libdir "${incdir} ${prefix}/lib/mysql5/mysql"
+}
+
+variant mysql51 conflicts mysql5 mysql55 mariadb percona description {Add support for MySQL 5.1} {
+    depends_lib-append    port:mysql51
+    set incdir "${incdir} ${prefix}/include/mysql51"
+    set libdir "${libdir} ${prefix}/lib/mysql51/mysql"
+}
+
+variant mysql55 conflicts mysql5 mysql51 mariadb percona description {Add support for MySQL 5.5} {
+    depends_lib-append    port:mysql55
+    set incdir "${incdir} ${prefix}/include/mysql55"
+    set libdir "${libdir} ${prefix}/lib/mysql55/mysql"
+}
+
+variant mariadb conflicts mysql5 mysql51 mysql55 percona description {Add support for MariaDB} {
+    depends_lib-append    port:mariadb
+    set incdir "${incdir} ${prefix}/include/mariadb"
+    set libdir "${libdir} ${prefix}/lib/mariadb/mysql"
+}
+
+variant percona conflicts mysql5 mysql51 mysql55 mariadb description {Add support for Percona} {
+    depends_lib-append    port:percona
+    set incdir "${incdir} ${prefix}/include/percona"
+    set libdir "${libdir} ${prefix}/lib/percona/mysql"
+}
+
+variant oracle description {Add support for Oracle} {
+    depends_lib-append    port:oracle-instantclient
+    configure.args-append --with-oracle=${prefix}/lib/oracle/sdk/include \
+                          --with-oracle-lib=${prefix}/lib/oracle
+}
+
+variant subversion description {Add support for Subversion} {
+    depends_lib-append    port:subversion
+}
+
+# Add this variant once someone creates a port for FirebirdSQL.
+# See: http://www.firebirdsql.org/
+# variant firebird description {Add support for FirebirdSQL} {}
+
+# Add this variant once someone creates a port for AFP-fs, the FUSE filesystem for Apple Filing Protocol
+# See: https://sites.google.com/site/alexthepuffin/
+# variant afp description {Add support for Apple Filing Protocol} {}
+
+# Add this variant once someone creates a port for ncpfs, an implementation of the Netware Core Protocol
+# See: http://prope.insa-lyon.fr/~ppollet/ncpfs/
+# variant ncp description {Add support for Netware Core Protocol} {}
+
 livecheck.type          regex
 livecheck.url           ${homepage}
-livecheck.regex         "${name}-(.*?)-src"
+livecheck.regex         "Current Version: (.*)"
