# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 115621 2014-01-07 03:16:16Z larryv@macports.org $

PortSystem              1.0

name                    zsh
version                 5.0.5
categories              shells
platforms               darwin
license                 Permissive
maintainers             larryv

description             Zsh is a UNIX command interpreter (shell)
long_description        Zsh is a UNIX command interpreter (shell) which \
                        of the standard shells most resembles the Korn \
                        shell (ksh), although it is not completely \
                        compatible. It includes enhancements of many \
                        types, notably in the command-line editor, \
                        options for customising its behaviour, filename \
                        globbing, features to make C-shell (csh) users \
                        feel more at home and extra features drawn from \
                        tcsh (another 'custom' shell).
homepage                http://www.zsh.org/

depends_build           bin:makeinfo:texinfo
depends_skip_archcheck-append texinfo

depends_lib             port:libiconv \
                        port:ncurses \
                        port:gdbm \
                        port:pcre

master_sites            sourceforge:project/zsh/zsh/${version}:src \
                        sourceforge:project/zsh/zsh-doc/${version}:doc \
                        http://www.zsh.org/pub/:src \
                        http://www.zsh.org/pub/:doc \
                        ftp://ftp.zsh.org/pub/:src \
                        ftp://ftp.zsh.org/pub/:doc \
                        ftp://ftp.fu-berlin.de/unix/shells/zsh/:src \
                        ftp://ftp.fu-berlin.de/unix/shells/zsh/:doc \
                        ftp://ftp.icm.edu.pl/vol/rzm1/zsh/:src \
                        ftp://ftp.icm.edu.pl/vol/rzm1/zsh/:doc

use_bzip2               yes
distfiles               ${distname}${extract.suffix}:src \
                        ${distname}-doc${extract.suffix}:doc

checksums               ${distname}${extract.suffix} \
                            rmd160  4299f33ba0de2542f7567ae4f16a4de16ba560a0 \
                            sha256  6624d2fb6c8fa4e044d2b009f86ed1617fe8583c83acfceba7ec82826cfa8eaf \
                        ${distname}-doc${extract.suffix} \
                            rmd160  a70632be38f4ee182f5b04226f6a7af6e39ea9f3 \
                            sha256  e4f22bafaa8410bbc2d83f2d748ca4764365752c46f7e1099be54f2a62c492f2

set doc ${prefix}/share/doc/${name}

configure.args          --enable-cap \
                        --enable-pcre \
                        --htmldir=${doc}/html \
                        --with-tcsetpgrp \
                        DL_EXT=bundle

test.run                yes
test.target             check

destroot.target-append  install.html install.info

post-destroot {
    # zshall(1) just includes every other zsh manpage, but its .so groff
    # directives fail because MacPorts gzips manpages.
    set man ${destroot}${prefix}/share/man
    system -W ${man} "soelim man1/zshall.1 > zshall.1.soelim"
    move -force ${man}/zshall.1.soelim ${man}/man1/zshall.1

    # Install any straggling documentation.
    xinstall -m 0644 -W ${worksrcpath} \
        ChangeLog FEATURES LICENCE META-FAQ NEWS README ${destroot}${doc}
    xinstall -d ${destroot}${doc}/pdf
    xinstall -m 0644 -W ${worksrcpath}/Doc \
        intro.a4.pdf intro.us.pdf zsh.pdf ${destroot}${doc}/pdf
}

notes "
To set MacPorts' ${name} as default login shell, run:

    sudo chpass -s ${prefix}/bin/${name} \${USER}

To be able to switch default shells to or from ${name} without superuser\
privileges, add it to /etc/shells:

    sudo sh -c 'echo ${prefix}/bin/${name} >> /etc/shells'
"
