#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

LLVM_VERSION	 = $(shell sed -n -r '/^Build/,/^$$/s/.*llvm-([0-9]+)-dev.*/\1/p' debian/control)

%:
	dh $@ --builddir build/

override_dh_auto_configure:
	dh_auto_configure -- \
		-DCMAKE_BUILD_TYPE=Release \
		-DIGC_OPTION__LLVM_PREFERRED_VERSION=$(LLVM_VERSION).0.0 \
		-DIGC_BUILD__VC_ENABLED=FALSE \
		-Wno-dev

override_dh_install:
	dh_install
	rm -f debian/tmp/usr/lib/*/igc/NOTICES.txt

override_dh_missing:
	dh_missing --fail-missing

override_dh_gencontrol:
	dh_gencontrol -- \
		-V'llvm:Version=$(LLVM_VERSION)'

override_dh_clean:
	dh_clean
	rm -f IGC/GenISAIntrinsics/Intrinsic_definitions.pyc
	rm -rf IGC/GenISAIntrinsics/__pycache__/

gentarball:
	tar --transform 's,^,$(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM)/,' \
		--exclude 'debian' --exclude-vcs \
		-cJf ../$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM).orig.tar.xz .
