### this file is sourced not run
PKGVER=4.6.1debian11
PKGBUILD=1
PKGARCH=x86_64

# source: BLFS 6.1 updated to wvstreams 4.6.1 with debian + arch patches
TARBALL=wvstreams_4.6.1.orig.tar.gz
MD5SUM=2760dac31a43d452a19a3147bfde571c
SRC_URL=http://ftp.de.debian.org/debian/pool/main/w/wvstreams/$TARBALL
BUNDLE=

SLACKREQ='openssl libreadline'
SLACKDESC="libwvstreams: libwvstreams $PKGVER (Networking library)  
libwvstreams:  
libwvstreams: WvStreams is a library suite containing platform-independent C++ 
libwvstreams: networking and utilities libraries for rapid application 
libwvstreams: development.  
libwvstreams: 
libwvstreams: 
libwvstreams: 
libwvstreams: 
libwvstreams: 
libwvstreams:
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/wvstreams* &&
	tar -xf $CHROOT_DIR/tmp/pkg/wvstreams_4.6.1-11.debian.tar.xz &&
	
	#for p in $(cat debian/patches/series); do
	#	patch -Np1 -i debian/patches/$p || return 1
	#done &&
	#patch -Np1 -i $CHROOT_DIR/tmp/pkg/wvstreams-07_magic_number.diff
	
	# use debian patch 01, 02, 03, 04, 07 and gcc-6
	for p in $(cat debian/patches/series); do
		case $p in
			01*|02*|03*|04*|07*|08*|gcc-6*) patch -Np1 -i debian/patches/$p || return 1 ;;
		esac
	done &&
	
	# and then use arch patches (FTFBS and segfaults patches)
	patch -Np0 -i ../pkg/wvstreams-4.6.1-glibc212.patch &&
	patch -Np0 -i ../pkg/wvstreams-4.6.1-gcc47.patch &&

	# additional (uncommitted) debian patch
	patch -Np1 -i ../pkg/wvstreams_openssl1.1.patch
}

### default pkg_package
### build
pkg_build() {
	cd /tmp/wvstreams*
	
	./configure $CONFFLAGS \
	    --with-openssl --without-dbus --without-tcl --without-qt &&

	make COPTS="$CFLAGS -fPIC" \
	     CXXOPTS="$CXXFLAGS -fPIC -fpermissive -fno-tree-dce -fno-optimize-sibling-calls" \
	     VERBOSE=1 all install && # note: no parallel build.
	
	pkg_build_slackdesc &&
	rm -f /usr/lib/libwvstatic.a && # don't want this huge static lib &&
	
	# according to arch, these files still get installed, so remove them
	rm -f /usr/$LIBDIR/pkgconfig/libwvdbus.pc && # dbus support which we don't build
	rm -f /usr/$LIBDIR/pkgconfig/libwvqt.pc	   # qt support which we don't build too
}


