### this file is sourced not run
PKGVER=3.21
PKGBUILD=1
PKGARCH=i686

# source: post BLFS 7.8 2016-01-12
TARBALL=nss-$PKGVER.tar.gz
MD5SUM=3c8b2ed880dd3a8d86c9e0151afe6eba
SRC_URL=http://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/NSS_3_21_RTM/src/$TARBALL
BUNDLE=

SLACKREQ='libnspr32 sqlite3_32'
SLACKDESC="libnss32: libnss32 $PKGVER (Network Security Services library)  
libnss32:  
libnss32: The Network Security Services (NSS) package is a set of libraries 
libnss32: designed to support cross-platform development of security-enabled 
libnss32: client and server applications. Applications built with NSS can 
libnss32: support SSL v2 and v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, 
libnss32: S/MIME, X.509 v3 certificates, and other security standards. This is 
libnss32: useful for implementing SSL and S/MIME or other Internet security 
libnss32: standards into an application.  
libnss32: 
libnss32: This contains 32-bit version of the library.
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/nss* &&
	patch -Np1 -i $CHROOT_DIR/tmp/pkg/nss-3.21-standalone-1.patch
}

### package - only collect the libraries
pkg_package() {
	rm -rf bin sbin usr/bin usr/sbin usr/include usr/share
	mkdir -p usr/bin &&
	mv -v tmp/*-32 usr/bin
}

### build
pkg_build() {
	cd /tmp/nss*/nss
	
	# build
	make BUILD_OPT=1                      \
		NSPR_INCLUDE_DIR=/usr/include/nspr  \
		USE_SYSTEM_ZLIB=1                   \
		ZLIB_LIBS=-lz                       \
		$([ $PKGARCH = x86_64 ] && echo USE_64=1) \
		$([ -f /usr/include/sqlite3.h ] && echo NSS_USE_SYSTEM_SQLITE=1) -j1 &&
		
	# install
	cd ../dist                                                       &&
	install -v -m755 Linux*/lib/*.so              /usr/$LIBDIR       &&
	install -v -m644 Linux*/lib/{*.chk,libcrmf.a} /usr/$LIBDIR       &&
	install -v -m755 -d                           /usr/include/nss   &&
	cp -v -RL {public,private}/nss/*              /usr/include/nss   &&
	chmod -v 644                                  /usr/include/nss/* &&
	install -v -m755 Linux*/bin/{certutil,nss-config,pk12util} /usr/bin   &&
	install -v -m644 Linux*/lib/pkgconfig/nss.pc  /usr/$LIBDIR/pkgconfig  &&
	pkg_build_slackdesc &&
	
	# multilib
	mv -v /usr/bin/nss-config /tmp/nss-config-32
}


