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

# 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='libnspr sqlite3'
SLACKDESC="libnss: libnss $PKGVER (Network Security Services library)  
libnss:  
libnss: The Network Security Services (NSS) package is a set of libraries 
libnss: designed to support cross-platform development of security-enabled 
libnss: client and server applications. Applications built with NSS can 
libnss: support SSL v2 and v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, 
libnss: S/MIME, X.509 v3 certificates, and other security standards. This is 
libnss: useful for implementing SSL and S/MIME or other Internet security 
libnss: standards into an application.  
libnss: 
libnss:
"

### 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
}

### default pkg_package
### 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{,-64} &&
	ln -sfv multiarch_wrapper /usr/bin/nss-config
	
}


