# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../bash/bash.conf
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2003 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---

bash_which=1

pkg_bash_postmake() {
	if [ "$bash_which" = "1" ]; then
		echo "Creating 'usr/bin/which' and 'bin/sh' ..."
		echo -e '#!/bin/bash\ntype -p "$@"' > $root/usr/bin/which
		chmod +x $root/usr/bin/which
	else
		echo "Creating 'bin/sh' ..."
	fi
	[ -f $root/usr/bin/bash ] && \
		mv -v $root/usr/bin/bash $root/bin/bash
	ln -sfv bash $root/bin/sh

	if [ "$SDECFG_CREATE_DOCS" != 0 ] ; then
		echo "Unpacking bash documentation ..."
		tar $taropt `match_source_file -p bash-doc`
	fi
}

pkg_bash_preconf() {
	# historic hack - still needed? -ReneR
	touch lib/malloc/malloc.c
	for x in `match_source_file -p 'bash3.*-.*'` ; do
		echo "Applying patch ${x##*/} ..."
		patch -p0 < $x
	done
}

pkg_bash_docver=$ver

var_append confopt " " "--without-bash-malloc"

[ "$SDECFG_PKG_BASH_PROGCOMP" = 0 ] &&
	var_append confopt " " "--disable-progcomp"
[ "$SDECFG_PKG_BASH_HELP_CMD" = 0 ] &&
	var_append confopt " " "--disable-help-builtin"

hook_add preconf 5 "pkg_bash_preconf"
hook_add premake 5 "eval $MAKE $makeopt builtins/builtext.h" # parallel make
hook_add postmake 5 "pkg_bash_postmake"