### this file is sourced not run
PKGVER=4.4
PKGBUILD=18 # patchlevel
PKGARCH=x86_64

# source: CLFS 2017.07 updated with patchlevel 18
TARBALL=bash-${PKGVER}.${PKGBUILD}.tar.gz
MD5SUM=518e2c187cc11a17040f0915dddce54e
BUNDLE=fatdog-base-8.2.tar
SRC_URL=http://distro.ibiblio.org/fatdog/source/800/$BUNDLE

SLACKREQ='libncurses libreadline'
SLACKDESC="bash: bash $PKGVER (Bourne-Again shell)  
bash:  
bash: Bash is the shell, or command language interpreter. Bash is largely 
bash: compatible with sh and incorporates useful features from the Korn shell 
bash: ksh and the C shell csh. It is intended to be a conformant 
bash: implementation of the IEEE POSIX Shell and Tools portion of the IEEE 
bash: POSIX specification (IEEE Standard 1003.1). It offers functional 
bash: improvements over sh for both interactive and programming use.  
bash: 
bash: 
bash:
"


### override download for LFS sources bundle
# $1-src-dir $2-tarball 
pkg_download() {
	echo downloading $BUNDLE for $TARBALL
	wget -P $1 $SRC_URL
	tar -xf $1/$BUNDLE --strip-components=1 -C $1 
	rm $1/$BUNDLE
}

### prepare
pkg_prepare() {
	if pkg_prepare_default; then
		cd tmp/bash*
		
		# upstream fixes
		#patch -Np1 -i $SRC_DIR/bash-4.4-branch_update-1.patch &&
		
		# updated patches - don't have at the moment
		#for p in $(seq 31 42); do
		#	patch -Np0 -i ../pkg/bash44-0$p || return 1
		#done &&
		
		# CLFS 3.0.0 lib64 fix - where to find the readline library
		sed -i "/ac_cv_rl_libdir/s@/lib@&64@" configure
	fi
}

### default pkg_package
### build
pkg_build() {
	cd /tmp/bash*
	
	CC="gcc ${BUILD64}" CXX="g++ ${BUILD64}" \
		./configure --prefix=/usr --bindir=/bin --libdir=/usr/$LIBDIR \
		--without-bash-malloc --with-installed-readline \
		--docdir=/usr/share/doc/bash-$PKGVER &&

    make $MAKEFLAGS && make install &&
    
    # kill the loadable examples
    rm -r /usr/$LIBDIR/bash &&
    
	pkg_build_slackdesc
}


