#!/usr/bin/make -f

export DEB_CFLAGS_MAINT_APPEND += -I../nss/dist/private/nss
export DEB_LDFLAGS_MAINT_APPEND += -L../nss/dist/lib/

%:
	dh $@ --builddirectory=build/

override_dh_auto_configure:
	mkdir build
	cd build && cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
		-DLIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
		../src

override_dh_auto_build:
	(cd nss; QUILT_PATCHES=debian/patches quilt push -a; debian/rules build)
	dh_auto_build

override_dh_clean:
	(cd nss; debian/rules clean)
	dh_clean

gentarball: SOURCE=nss-pem
gentarball: UV=$(shell dpkg-parsechangelog|awk '/^Version:/ {print $$2}'|sed 's/-.*$$//')
gentarball:
	tar --transform 's,^,$(SOURCE)-$(UV)/,' \
		--exclude './debian' --exclude-vcs \
		-cJf ../$(SOURCE)_$(UV).orig.tar.xz .
