#!/usr/bin/make -f EMPTY := SPACE := $(EMPTY) $(EMPTY) DOLLAR := $ include /usr/share/dpkg/architecture.mk export DEB_BUILD_MAINT_OPTIONS = hardening=+all archs_that_need_atomic = none ifeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(archs_that_need_atomic))) export DEB_LDFLAGS_MAINT_APPEND = -Wl,--no-as-needed -latomic -Wl,--as-needed TESTS_EXTRA_LIBS += -latomic endif # leftover test cases of removed qt6-* checks; these tests need to be excluded # when running run_tests.py in the run-tests autopkgtest TESTS_EXCLUDED += qt6-deprecated-api-fixes qt6-fwd-fixes qt6-header-fixes qt6-qhash-signature qt6-qlatin1stringchar-to-u # keep the "++" at the end, to make sure the tool used is the C++ frontend CLANGPP=$(shell realpath $$(env PATH=$$(echo "$$PATH" | sed -r -e 's|/usr/lib/ccache/?:||') which clang++))++ CLANG_APPLY_REPLACEMENTS=$(shell realpath $$(which clang-apply-replacements)) CLANG_TIDY=$(shell realpath $$(which clang-tidy)) DPKG_ARCHITECTURE = $(shell dpkg --print-architecture) %: dh $@ execute_after_dh_auto_clean: # cleanup the artifacts of the tests find tests/ \( -name '*.o' -o -name '*.out' -o -name '*.result' -o -name '*.gch' -o -name '*.pch' -o -name '*.fixed' -o -name '*.yaml' \) -delete override_dh_auto_configure: dh_auto_configure -- -DCLANGPP_EXECUTABLE="$(CLANGPP)" -DREADLINK_CMD:FILEPATH=/bin/readlink override_dh_auto_install: dh_auto_install --destdir=debian/clazy # drop RPATH pointing to the private libdir of LLVM libraries, # 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/LGPL-2.0-or-later.txt # create a local shell environment file with the various paths & configurations :> $(CURDIR)/debian/debian.sh echo 'export CLANG="$(CLANGPP)"' >> $(CURDIR)/debian/debian.sh echo 'export CLANG_APPLY_REPLACEMENTS="$(CLANG_APPLY_REPLACEMENTS)"' >> $(CURDIR)/debian/debian.sh echo 'export CLANG_TIDY="$(CLANG_TIDY)"' >> $(CURDIR)/debian/debian.sh echo 'export TESTS_EXCLUDED="$(TESTS_EXCLUDED)"' >> $(CURDIR)/debian/debian.sh echo 'export TESTS_EXTRA_LIBS="$(TESTS_EXTRA_LIBS)"' >> $(CURDIR)/debian/debian.sh mkdir -p $(CURDIR)/debian/clazy-tests/usr/share/clazy mv $(CURDIR)/debian/debian.sh $(CURDIR)/debian/clazy-tests/usr/share/clazy/debian-$(DPKG_ARCHITECTURE).sh override_dh_auto_test: ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) chmod +x $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/clazy env PATH=$(CURDIR)/obj-$(DEB_HOST_GNU_TYPE):$(PATH) DEBIAN_EXTRA_LIBS="$(TESTS_EXTRA_LIBS)" CCACHE_DISABLE=1 dh_auto_test -- $(and $(TESTS_EXCLUDED),ARGS+=-E) $(and $(TESTS_EXCLUDED),ARGS+="'^($(subst $(SPACE),|,$(TESTS_EXCLUDED)))\$(DOLLAR)$(DOLLAR)'") endif override_dh_compress: # do not compress documentation markdown & JSON files dh_compress -X.md -X.json override_dh_gencontrol: dh_gencontrol -- \ -V'clazy:clang=$(shell dpkg -S "$(CLANGPP)" | cut -d: -f1)' \ -V'clazy:clang-tidy=$(shell dpkg -S "$(CLANG_TIDY)" | cut -d: -f1)' \ -V'clazy:clang-tools=$(shell dpkg -S "$(CLANG_APPLY_REPLACEMENTS)" | cut -d: -f1)'