#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# LLVM 6.0 headers produce lots of class-memaccess warnings
export DEB_CXXFLAGS_MAINT_APPEND = -Wno-class-memaccess

%:
	dh $@

override_dh_auto_install:
	dh_auto_install
	# drop RPATH pointing to the private libdir of LLVM libraryes,
	# i.e. /usr/lib/llvm-$VERSION/lib
	chrpath -d $(CURDIR)/debian/clazy/usr/bin/clazy-standalone $(CURDIR)/debian/clazy/usr/lib/*/*.so
	# drop extra license file
	rm $(CURDIR)/debian/clazy/usr/share/doc/clazy/COPYING-LGPL2.txt

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	chmod +x $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/clazy
	cd tests && env PATH=$(CURDIR)/obj-$(DEB_HOST_GNU_TYPE):$(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/bin:$(PATH) LD_LIBRARY_PATH=$(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/lib ./run_tests.py --verbose
endif

override_dh_compress:
	# do not compress documentation markdown & JSON files
	dh_compress -X.md -X.json
