# $Id: Portfile 70511 2010-08-11 19:06:02Z ricci@macports.org $

PortSystem          1.0

name                john
conflicts           john-devel
version             1.7.6
revision            0
categories          sysutils security
maintainers         nomaintainer
description         Featureful Unix password cracker
long_description    John the Ripper is a UNIX password cracker, currently available for \
                    UNIX (tested with Linux x86, FreeBSD x86, Solaris 2.x SPARC, OSF/1 \
                    Alpha), DOS, WinNT/Win95.
homepage            http://www.openwall.com/john/
platforms           darwin
master_sites        http://download.openwall.net/pub/projects/john/${version}/ \
                    ftp://ftp2.msk.ru.openwall.com/pub/projects/john/${version}/ \
                    ftp://ftp.ibiblio.org/pub/linux/distributions/openwall/projects/john/${version}/ \
                    ftp://ftp.cert.dfn.de/pub/tools/net/Openwall/projects/john/${version}/ \
                    http://distro.ibiblio.org/pub/linux/distributions/openwall/projects/john/${version}/ \
                    ftp://ftp.mirrorgeek.com/openwall/projects/john/${version}/ \
                    http://mirrorgeek.com/openwall/projects/john/${version}/ \
                    ftp://ftp1.msk.ru.openwall.com/pub/projects/john/${version}/ \
                    ftp://ftp.spb.ru.openwall.com/pub/projects/john/${version}/ \
                    ftp://ftp.man.szczecin.pl/pub/Linux/Owl/projects/john/${version}/ \
                    ftp://ftp.se.openwall.com/pub/projects/john/${version}/ \
                    http://ftp.sunet.se/pub/security/tools/net/Openwall/projects/john/${version}/ \
                    ftp://ftp.sunet.se/pub/security/tools/net/Openwall/projects/john/${version}/ \
                    ftp://ftp.mathematik.uni-marburg.de/pub/mirror/openwall/projects/john/${version}/ \
                    ftp://ftp.wiretapped.net/pub/openwall/projects/john/${version}/ \
                    ftp://ftp.ua.openwall.com/pub/projects/john/${version}/ \
                    ftp://ftp.cz.openwall.com/pub/projects/john/${version}/
use_bzip2           yes

checksums           md5     321ac0793f1aa4f0603b33a393133756 \
                    sha1    a767b65d8387d264238db7c5613986fc88b730aa \
                    rmd160  de0de4970986064f6a8cf99835ff41cef1c2547f

patchfiles          patch-src-params.h.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/src/params.h
}

use_configure       no

use_parallel_build  no

build.dir           ${worksrcpath}/src
build.args          CC=${configure.cc}
build.target        clean
switch ${configure.build_arch} {
    i386 {
        build.target-append macosx-x86-sse2
    }
    x86_64 {
        # x86_64 is only supported on Leopard and up
        if {${os.major} >= 9} {
            build.target-append macosx-x86-64
        } else {
            configure.build_arch i386
            build.target-append macosx-x86-sse2
        }
    }
    ppc {
        # Use altivec if available
        if {[exec sysctl -n hw.vectorunit] == 1} {
            build.target-append macosx-ppc32-altivec
        } else {
            build.target-append macosx-ppc32
        }
    }
    ppc64 {
        build.target-append macosx-ppc64
    }
}

destroot {
    file copy ${worksrcpath}/run ${destroot}${prefix}/share/john
    system "chmod -R a+rX ${destroot}${prefix}/share/john"
    system "ln -s ${prefix}/share/john/john ${destroot}${prefix}/bin/john"
    xinstall -d ${destroot}${prefix}/share/doc
    file copy ${worksrcpath}/doc ${destroot}${prefix}/share/doc/john
    system "chmod -R a+rX ${destroot}${prefix}/share/doc/john"
}

notes "You'll find the john files under ${prefix}/share/john/"

livecheck.type      regex
livecheck.regex     {Ripper ([0-9.]+) \(stable}
