Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2
3 EMPTY :=
4 SPACE := $(EMPTY) $(EMPTY)
5 DOLLAR := $
6
7 include /usr/share/dpkg/architecture.mk
8
9 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
10
11 archs_that_need_atomic = none
12 ifeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(archs_that_need_atomic)))
13 export DEB_LDFLAGS_MAINT_APPEND = -Wl,--no-as-needed -latomic -Wl,--as-needed
14 TESTS_EXTRA_LIBS += -latomic
15 endif
16
17 # leftover test cases of removed qt6-* checks; these tests need to be excluded
18 # when running run_tests.py in the run-tests autopkgtest
19 TESTS_EXCLUDED += qt6-deprecated-api-fixes qt6-fwd-fixes qt6-header-fixes qt6-qhash-signature qt6-qlatin1stringchar-to-u
20
21 # keep the "++" at the end, to make sure the tool used is the C++ frontend
22 CLANGPP=$(shell realpath $$(env PATH=$$(echo "$$PATH" | sed -r -e 's|/usr/lib/ccache/?:||') which clang++))++
23 CLANG_APPLY_REPLACEMENTS=$(shell realpath $$(which clang-apply-replacements))
24 CLANG_TIDY=$(shell realpath $$(which clang-tidy))
25
26 DPKG_ARCHITECTURE = $(shell dpkg --print-architecture)
27
28 %:
29 dh $@
30
31 execute_after_dh_auto_clean:
32 # cleanup the artifacts of the tests
33 find tests/ \( -name '*.o' -o -name '*.out' -o -name '*.result' -o -name '*.gch' -o -name '*.pch' -o -name '*.fixed' -o -name '*.yaml' \) -delete
34
35 override_dh_auto_configure:
36 dh_auto_configure -- -DCLANGPP_EXECUTABLE="$(CLANGPP)" -DREADLINK_CMD:FILEPATH=/bin/readlink
37
38 override_dh_auto_install:
39 dh_auto_install --destdir=debian/clazy
40 # drop RPATH pointing to the private libdir of LLVM libraries,
41 # i.e. /usr/lib/llvm-$VERSION/lib
42 chrpath -d $(CURDIR)/debian/clazy/usr/bin/clazy-standalone $(CURDIR)/debian/clazy/usr/lib/*/*.so
43 # drop extra license file
44 rm $(CURDIR)/debian/clazy/usr/share/doc/clazy/LGPL-2.0-or-later.txt
45 # create a local shell environment file with the various paths & configurations
46 :> $(CURDIR)/debian/debian.sh
47 echo 'export CLANG="$(CLANGPP)"' >> $(CURDIR)/debian/debian.sh
48 echo 'export CLANG_APPLY_REPLACEMENTS="$(CLANG_APPLY_REPLACEMENTS)"' >> $(CURDIR)/debian/debian.sh
49 echo 'export CLANG_TIDY="$(CLANG_TIDY)"' >> $(CURDIR)/debian/debian.sh
50 echo 'export TESTS_EXCLUDED="$(TESTS_EXCLUDED)"' >> $(CURDIR)/debian/debian.sh
51 echo 'export TESTS_EXTRA_LIBS="$(TESTS_EXTRA_LIBS)"' >> $(CURDIR)/debian/debian.sh
52 mkdir -p $(CURDIR)/debian/clazy-tests/usr/share/clazy
53 mv $(CURDIR)/debian/debian.sh $(CURDIR)/debian/clazy-tests/usr/share/clazy/debian-$(DPKG_ARCHITECTURE).sh
54
55 override_dh_auto_test:
56 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
57 chmod +x $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/clazy
58 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)'")
59 endif
60
61 override_dh_compress:
62 # do not compress documentation markdown & JSON files
63 dh_compress -X.md -X.json
64
65 override_dh_gencontrol:
66 dh_gencontrol -- \
67 -V'clazy:clang=$(shell dpkg -S "$(CLANGPP)" | cut -d: -f1)' \
68 -V'clazy:clang-tidy=$(shell dpkg -S "$(CLANG_TIDY)" | cut -d: -f1)' \
69 -V'clazy:clang-tools=$(shell dpkg -S "$(CLANG_APPLY_REPLACEMENTS)" | cut -d: -f1)'