#!/usr/bin/make -f

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# main packaging script based on dh7 syntax
%:
	dh $@ --with quilt --builddirectory=build/

override_dh_clean:
	dh_clean
	rm -rf __pycache__

override_dh_auto_configure:
	dh_auto_configure -- \
	-DCMAKE_INSTALL_LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
	-DGLSLANG_SPIRV_INCLUDE_DIR=$(CURDIR)/debian

override_dh_auto_install:
	dh_auto_install --destdir=debian/tmp

	mkdir -p debian/tmp/usr/include
	cp -rp include/vulkan debian/tmp/usr/include

#	mkdir -p debian/tmp/usr/share/vulkan/explicit_layer.d \
#		 debian/tmp/usr/share/vulkan/implicit_layer.d
#	for i in $(shell cd layers/linux/; ls *.json) ; do \
#		sed 's@./@@' layers/linux/$$i > \
#		debian/tmp/usr/share/vulkan/explicit_layer.d/$$i \
#	; done

override_dh_install:
	dh_install --fail-missing

gentarball: SOURCE=vulkan
gentarball: UV=$(shell dpkg-parsechangelog|awk '/^Version:/ {print $$2}'|sed 's/-.*$$//')
gentarball:
	git archive --format=tar upstream-unstable-trim --prefix=$(SOURCE)-$(UV)/ | gzip -9 > ../$(SOURCE)_$(UV).orig.tar.gz

