#!/usr/bin/make -f

export PYBUILD_NAME=google-compute-engine
export PYBUILD_TEST_PYTEST=1
export PYBUILD_TEST_ARGS={dir}/google_compute_engine/
export PYBUILD_SYSTEM=distutils

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

OSLOGIN_DIR=google_compute_engine_oslogin

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build
	$(MAKE) -C $(OSLOGIN_DIR) all

override_dh_auto_install:
	dh_auto_install
	
	$(MAKE) -C $(OSLOGIN_DIR) \
		DESTDIR=$(CURDIR)/debian/tmp \
		NSS_INSTALL_PATH=/lib/$(DEB_HOST_MULTIARCH) \
		PAM_INSTALL_PATH=/lib/$(DEB_HOST_MULTIARCH)/security \
		BIN_INSTALL_PATH=/usr/bin install
	
	cd $(CURDIR)/debian/tmp/lib/$(DEB_HOST_MULTIARCH) && \
               ln -s libnss_cache_google-compute-engine-oslogin-*.so libnss_cache_oslogin.so.2 && \
               ln -s libnss_google-compute-engine-oslogin-*.so libnss_oslogin.so.2

override_dh_clean:
	dh_clean
	rm -rf google_compute_engine.egg-info
