Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2
3 include /usr/share/dpkg/architecture.mk
4 include /usr/share/dpkg/pkg-info.mk
5
6 DEB_VERSION_SOURCE = $(shell echo '$(DEB_VERSION)' | sed -re 's/\+b([0-9]+)$$//')
7
8 SHELL := sh -e
9
10 include debian/rules.defs
11
12 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
13 DEBIAN_KERNEL_JOBS := $(subst parallel=,,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
14 endif
15 ifdef DEBIAN_KERNEL_JOBS
16 MAKEFLAGS += -j$(DEBIAN_KERNEL_JOBS)
17 endif
18
19 # dpkg-buildpackage passes the -s option if DEB_BUILD_OPTIONS contains
20 # terse, but that triggers Kbuild to turn off progress messages
21 # completely, which we don't want.
22 override MAKEFLAGS := $(subst s,,$(filter-out -%,$(MAKEFLAGS))) $(filter -%,$(MAKEFLAGS))
23
24 .NOTPARALLEL:
25
26 source: debian/control
27 dh_testdir
28 $(MAKE) -f debian/rules.gen source
29
30 setup: debian/control
31 dh_testdir
32 $(MAKE) -f debian/rules.gen setup_$(DEB_HOST_ARCH)
33
34 build: build-arch build-indep
35
36 build-arch: debian/control
37 dh_testdir
38
39 # The perf-read-vdso* programs are built for different architectures,
40 # without standard flags, but are not exposed to untrusted input.
41 @printf '%s\n' 'blhc: ignore-line-regexp: .* -o *[^ ]*/perf-read-vdso.*'
42
43 # Kernel code needs different hardening options that blhc doesn't know
44 # about.
45 @printf '%s\n' 'blhc: ignore-line-regexp: .* -D__KERNEL__ .*'
46
47 # The tools/perf/tests/workloads/.* programs are deliberately compiled
48 # without -O2, so instruct blhc to ignore those
49 @printf '%s\n' 'blhc: ignore-line-regexp: .* -o .*tools/perf/tests/workloads/.*'
50
51 # fixdep is not always built with the right flags but is also not packaged
52 @printf '%s\n' 'blhc: ignore-line-regexp: .* -o .*/tools/.*/fixdep.*'
53
54 # blhc gets confused by our putting compiler flags in the CC variable,
55 # which we do as a workaround for broken upstream makefiles
56 @printf '%s\n' 'blhc: ignore-line-regexp: /usr/bin/make .*'
57 @printf '%s\n' 'blhc: ignore-line-regexp: .*/tools/perf/trace/beauty/arch_errno_names\.sh.*'
58
59 # We need to use terse builds in CI due to the log size limit. This
60 # mostly affects the output for builds of kernel code, which need
61 # different options for hardening anyway.
62 ifneq ($(filter terse,$(DEB_BUILD_OPTIONS)),)
63 @printf '%s\n' 'blhc: ignore-line-regexp: \s*(CC(LD)?|LD|LINK)\b.*'
64 endif
65
66 $(MAKE) -f debian/rules.gen build-arch_$(DEB_HOST_ARCH)
67
68 build-indep: debian/control
69 dh_testdir
70 $(MAKE) -f debian/rules.gen build-indep
71
72 binary: binary-indep binary-arch
73
74 binary-arch: build-arch
75 dh_testdir
76 $(MAKE) -f debian/rules.gen binary-arch_$(DEB_HOST_ARCH)
77
78 binary-indep: build-indep
79 dh_testdir
80 $(MAKE) -f debian/rules.gen binary-indep
81
82 DIR_ORIG = ../orig/$(DEB_SOURCE)-$(DEB_VERSION_EPOCH_UPSTREAM)
83 TAR_ORIG = ../$(DEB_SOURCE)_$(DEB_VERSION_EPOCH_UPSTREAM).orig.tar.*
84
85 orig: $(DIR_ORIG)
86 rsync --delete --exclude /debian --exclude .git --link-dest=$</ -a $</ .
87 QUILT_PATCHES='$(CURDIR)/debian/patches' QUILT_PC=.pc quilt push --quiltrc - -a -q --fuzz=0
88 @$(MAKE) -f debian/rules debian/control-real
89
90 $(DIR_ORIG):
91 mkdir -p ../orig
92 tar -C ../orig -xaf $(TAR_ORIG)
93
94 CLEAN_PATTERNS := $(BUILD_DIR) $(STAMPS_DIR) debian/lib/python/debian_linux/*.pyc debian/lib/python/debian_linux/__pycache__ $$(find debian -maxdepth 1 -type d -name 'linux-*') debian/*-modules-*-di* debian/*-tmp debian/*.substvars
95
96 clean-generated:
97 rm -rf $(CLEAN_PATTERNS)
98 # We cannot use dh_clean here because it requires debian/control to exist
99 rm -rf debian/.debhelper debian/*.debhelper* debian/files debian/generated.*
100 rm -f \
101 debian/control \
102 debian/control.md5sum \
103 debian/linux-doc.maintscript \
104 debian/linux-headers-*.maintscript \
105 debian/linux-headers-*.postinst \
106 debian/linux-image-*.NEWS \
107 debian/linux-image-*.bug-presubj \
108 debian/linux-image-*.lintian-overrides \
109 debian/linux-image-*.maintscript \
110 debian/linux-image-*.postinst \
111 debian/linux-image-*.postrm \
112 debian/linux-image-*.preinst \
113 debian/linux-image-*.prerm \
114 debian/linux-source.maintscript \
115 debian/rules.gen \
116 debian/tests/control
117
118 maintainerclean: clean-generated
119 rm -rf $(filter-out debian .git, $(wildcard * .[^.]*))
120
121 clean: debian/control
122 dh_testdir
123 rm -rf $(CLEAN_PATTERNS)
124 dh_clean
125
126 CONTROL_FILES = $(BUILD_DIR)/version-info $(wildcard debian/templates/*.in)
127 CONTROL_FILES += debian/config/defines.toml $(wildcard debian/config/*/defines.toml)
128 CONTROL_FILES += debian/installer/package-list
129
130 # debian/bin/gencontrol.py uses debian/changelog as input, but the
131 # output only depends on the source name, version, and suite. To avoid
132 # frequent changes to debian/control.md5sum, include only those fields
133 # in the checksum.
134 $(BUILD_DIR)/version-info: debian/changelog
135 mkdir -p $(@D)
136 # Use DEB_VERSION_SOURCE to allow binNMU
137 printf >$@ 'Source: %s\nVersion: %s\nDistribution: %s\n' $(DEB_SOURCE) $(DEB_VERSION) $(DEB_DISTRIBUTION)
138
139 debian/control debian/rules.gen: debian/bin/gencontrol.py $(CONTROL_FILES)
140 ifeq ($(wildcard debian/control.md5sum),)
141 $(MAKE) -f debian/rules debian/control-real-fail
142 else
143 md5sum --check debian/control.md5sum --status || \
144 $(MAKE) -f debian/rules debian/control-real-fail
145 endif
146
147 debian/control-real: debian/bin/gencontrol.py $(CONTROL_FILES)
148 # Hash randomisation makes the pickled config unreproducible
149 PYTHONHASHSEED=0 $<
150 md5sum $(sort $^) > debian/control.md5sum
151
152 debian/control-real-fail:
153 @$(MAKE) -f debian/rules debian/control-real
154 @echo
155 @echo This target is made to fail intentionally, to make sure
156 @echo that it is NEVER run during the automated build. Please
157 @echo ignore the following error, the debian/control file has
158 @echo been generated SUCCESSFULLY.
159 @echo
160 exit 1
161
162 .PHONY: binary binary-% build build-% clean debian/control-real orig setup source clean-generated