# $Id: Portfile 61956 2009-12-25 20:41:39Z ryandesign@macports.org $

PortSystem          1.0
name                john-devel
version             1.7.3.4
categories          sysutils security
maintainers         nomaintainer
license             GPLv2
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://www.openwall.com/john/f/ \
                    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     2f2310c49961c3edea6f92b8dcd45ff4 \
                    sha1    3919cac037360512e6d72d04d72d492ee9673ded \
                    rmd160  a3a27c24eb71af8797bc02621ed02a8c9edd6b1d

distname            john-${version}
build.dir           ${worksrcpath}/src

patchfiles          patch-params.h
patch.dir           ${build.dir}
post-patch {
    reinplace "s|@@PREFIX@@|${prefix}|g" ${patch.dir}/params.h
    delete ${worksrcpath}/doc/INSTALL
}

use_configure       no

pre-build {
    system "cd ${build.dir} && make clean"
}
build.args          CC=${configure.cc}
build.target        generic

platform darwin {
    switch ${configure.build_arch} {
        ppc         { build.target macosx-ppc32    }
        ppc64       { build.target macosx-ppc64    }
        i386        { build.target macosx-x86-sse2 }
        x86_64      { build.target macosx-x86-64   }
    }
}

variant altivec description {Enable AltiVec support} {
    pre-configure {
        switch ${configure.build_arch} {
            ppc     -
            ppc64   {}
            default {
                ui_error "The +altivec variant can only be used when building for PowerPC."
                return -code error "incompatible architecture"
            }
        }
    }
    pre-build {
        append build.target -altivec
    }
}

destroot {
    file copy ${worksrcpath}/run ${destroot}${prefix}/share/john
    system "chmod -R a+rx ${destroot}${prefix}/share/john"
    ln -s ../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+r ${destroot}${prefix}/share/doc/john"
}

post-install {
    ui_msg  ""
    ui_msg  "You'll find the john files under ${prefix}/share/john/"
    ui_msg  ""
}

