# Template file for 'zsh'
pkgname=zsh
version=5.9
revision=3
build_style=gnu-configure
make_build_target="all info"
make_install_args="install.info"
configure_args="--enable-etcdir=/etc/zsh --enable-zshenv=/etc/zsh/zshenv
 --enable-zlogin=/etc/zsh/zlogin --enable-zlogout=/etc/zsh/zlogout
 --enable-zprofile=/etc/zsh/zprofile --enable-zshrc=/etc/zsh/zshrc
 --enable-maildir-support --enable-function-subdirs
 --enable-fndir=/usr/share/zsh/functions --with-term-lib=ncursesw
 --enable-scriptdir=/usr/share/zsh/scripts --enable-pcre
 --enable-multibyte --enable-cap --with-tcsetpgrp
 zsh_cv_shared_environ=yes
 zsh_cv_func_dlsym_needs_underscore=no
 zsh_cv_sys_dynamic_execsyms=yes"
hostmakedepends="automake texinfo"
makedepends="gdbm-devel pcre-devel libcap-devel ncurses-devel"
short_desc="Z SHell"
maintainer="Leah Neukirchen <leah@vuxu.org>"
license="MIT, GPL-3.0-or-later"
homepage="http://www.zsh.org"
distfiles="http://www.zsh.org/pub/zsh-${version}.tar.xz"
checksum=9b8d1ecedd5b5e81fbf1918e876752a7dd948e05c1a0dba10ab863842d45acd5
register_shell="/bin/zsh /usr/bin/zsh"
lib32disabled=yes
conf_files="/etc/zsh/*"

post_patch() {
	# Set correct keymap path
	sed -i 's#/usr/share/keymaps#/usr/share/kbd/keymaps#g' \
		Completion/Unix/Command/_loadkeys

	# Remove unneeded and conflicting completion scripts
	for _fpath in AIX BSD Cygwin Darwin Debian Mandriva openSUSE Redhat Solaris; do
		rm -rf Completion/$_fpath
		sed "s#\s*Completion/$_fpath/\*/\*##g" -i Src/Zle/complete.mdd
	done

	rm -f Completion/Linux/Command/_{pkgtool,rpmbuild,yast}
	rm -f Completion/Unix/Command/_{notmuch,osc,systemd}

	vsed -i -e 's,/etc/service,/var/service,g' Completion/Unix/Command/_runit

	vsed -i -e 's,/etc/z,/etc/zsh/z,g' \
		Doc/zsh.texi Doc/{zsh,zshall,zshoptions,zshmodules}.1
}

pre_configure() {
	autoreconf -fi
}

post_install() {
	vlicense LICENCE
	vinstall "${FILESDIR}/zprofile" 644 etc/zsh
}
