]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - debian/rules
UBUNTU: [Packaging] update helper scripts
[mirror_ubuntu-hirsute-kernel.git] / debian / rules
1 #!/usr/bin/make -f
2 #
3 # $(DEBIAN)/rules for Ubuntu linux
4 #
5 # Use this however you want, just give credit where credit is due.
6 #
7 # Copyright (c) 2007 Ben Collins <bcollins@ubuntu.com>
8 #
9
10 DEBIAN=$(shell awk -F= '($$1 == "DEBIAN") { print $$2 }' <debian/debian.env)
11
12 # dpkg-buildpackage passes options that are incomptatible
13 # with the kernel build.
14 unexport CFLAGS
15 unexport LDFLAGS
16
17 export LC_ALL=C
18 export SHELL=/bin/bash -e
19
20 # Where do we find the common configuration.
21 export DROOT=debian
22
23 # Common variables for all architectures
24 include $(DROOT)/rules.d/0-common-vars.mk
25
26 # Pull in some arch specific stuff
27 -include $(DEBIAN)/rules.d/$(arch).mk
28
29 # Pull in some branch specific stuff. Used by LTS backport
30 # branches to override master branch settings such as do_tools_common.
31 -include $(DEBIAN)/rules.d/hooks.mk
32
33 # Maintainer targets
34 include $(DROOT)/rules.d/1-maintainer.mk
35
36 do_linux_tools=$(sort $(filter-out false,$(do_tools_usbip) $(do_tools_cpupower) $(do_tools_perf) $(do_tools_bpftool) $(do_tools_x86)))
37 do_cloud_tools=$(sort $(filter-out false,$(do_tools_hyperv)))
38 do_tools_common?=true
39 do_tools_host?=false
40 do_tools_perf_jvmti?=false
41 do_enforce_all?=false
42 ifneq ($(filter noudeb,$(DEB_BUILD_PROFILES)),)
43 disable_d_i=true
44 endif
45
46 # Don't build udebs if $(DEBIAN)/d-i/ doesn't exist
47 ifeq ($(wildcard $(DEBIAN)/d-i/.),)
48 disable_d_i=true
49 endif
50
51 # Don't build tools or udebs in a cross compile environment.
52 ifneq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH))
53 do_tools=false
54 disable_d_i=true
55 do_zfs=false
56 do_dkms_nvidia=false
57 do_dkms_nvidia_server=false
58 endif
59
60 # Are any of the kernel signing options enabled.
61 any_signed=$(sort $(filter-out false,$(uefi_signed) $(opal_signed) $(sipl_signed)))
62 ifeq ($(any_signed),true)
63 bin_pkg_name=$(bin_pkg_name_unsigned)
64 else
65 bin_pkg_name=$(bin_pkg_name_signed)
66 endif
67
68 # Stages -- support both DEB_STAGE=stage1 and DEB_BUILD_PROFILE=bootstrap
69 ifeq ($(DEB_STAGE),stage1)
70 DEB_BUILD_PROFILES=stage1
71 endif
72 ifneq ($(DEB_BUILD_PROFILE),)
73 DEB_BUILD_PROFILES=$(DEB_BUILD_PROFILE)
74 endif
75 ifneq ($(filter stage1,$(DEB_BUILD_PROFILES)),)
76 do_tools=false
77 do_doc_package=false
78 do_source_package=false
79 do_flavour_image_package=false
80 do_flavour_header_package=false
81 endif
82
83 # autopkgtest -- rebuild support
84 # - only build the first flavour on the assumption it is representative
85 # - disable dkms builds as the versions used may have been deleted
86 ifneq ($(filter autopkgtest,$(DEB_BUILD_PROFILES)),)
87 flavours := $(firstword $(flavours))
88 disable_d_i=true
89 do_zfs=false
90 do_dkms_nvidia=false
91 do_dkms_nvidia_server=false
92 endif
93
94 # Being used to build a mainline build -- turn off things which do not work.
95 ifeq ($(do_mainline_build),true)
96 do_extras_package=false
97 do_tools=false
98 no_dumpfile=1
99 do_zfs=false
100 do_dkms_nvidia=false
101 do_dkms_nvidia_server=false
102 skipabi=true
103 skipmodule=true
104 skipretpoline=true
105 endif
106
107 # Disable tools build and packaging if do_tools != true
108 ifneq ($(do_tools),true)
109 do_linux_tools=
110 do_cloud_tools=
111 do_tools_common=
112 do_tools_host=
113 endif
114
115 ifeq ($(do_zfs),false)
116 do_zfs_disable:=$(shell for m in $$(cat $(DROOT)/zfs-modules.ignore); do grep -qxF $$m $(prev_abidir)/../modules.ignore 2>/dev/null || echo $$m >> $(prev_abidir)/../modules.ignore; done)
117 endif
118
119 ifeq ($(do_dkms_wireguard),false)
120 do_wireguard_disable:=$(shell for m in $$(cat $(DROOT)/wireguard-modules.ignore); do grep -qxF $$m $(prev_abidir)/../modules.ignore 2>/dev/null || echo $$m >> $(prev_abidir)/../modules.ignore; done)
121 endif
122
123 # Either tools package needs the common source preparation
124 do_any_tools=$(sort $(filter-out false,$(do_linux_tools) $(do_cloud_tools)))
125
126 # Versions of dkms packages.
127 dkms_zfs_linux_version=$(shell gawk '/^zfs-linux / { print $$2; }' debian/dkms-versions)
128
129 # NVIDIA DKMS package gross series split into desktop and server.
130 nvidia_desktop_series=$(shell sed -n -e 's/^nvidia-graphics-drivers-\([0-9][0-9]*\) .*/\1/p' debian/dkms-versions)
131 nvidia_server_series=$(shell sed -n -e 's/^nvidia-graphics-drivers-\([0-9][0-9]*-server\) .*/\1/p' debian/dkms-versions)
132
133 # Debian Build System targets
134 binary: binary-indep binary-arch
135
136 build: build-arch build-indep
137
138 clean: debian/control debian/canonical-certs.pem
139 dh_testdir
140 dh_testroot
141 dh_clean
142
143 ifeq ($(disable_d_i),)
144 # d-i stuff
145 rm -rf $(DEBIAN)/d-i-$(arch)
146 # Generated on the fly.
147 rm -f $(DEBIAN)/d-i/firmware/$(arch)/kernel-image
148 endif
149
150 # normal build junk
151 rm -rf $(DEBIAN)/abi/$(release)-$(revision)
152 rm -rf $(builddir)
153 rm -f $(stampdir)/stamp-*
154 rm -rf $(DEBIAN)/linux-*
155
156 # This gets rid of the d-i packages in control
157 cp -f $(DEBIAN)/control.stub $(DROOT)/control
158 cp $(DEBIAN)/changelog debian/changelog
159
160 # Install the copyright information.
161 cp $(DEBIAN)/copyright debian/copyright
162
163 # Install the retpoline extractor.
164 cp $(DROOT)/scripts/retpoline-extract-one scripts/ubuntu-retpoline-extract-one
165
166 # If we have a reconstruct script use it.
167 [ -f $(DEBIAN)/reconstruct ] && bash $(DEBIAN)/reconstruct || true
168
169 # Remove generated intermediate files
170 rm -f $(DROOT)/control.stub $(DEBIAN)/control.stub
171 rm -f $(DROOT)/scripts/fix-filenames
172
173 distclean: clean
174 rm -rf $(DROOT)/control debian/changelog \
175 debian/control debian/control.stub debian/copyright \
176 scripts/ubuntu-retpoline-extract-one
177
178 # Builds the image, arch headers and debug packages
179 include $(DROOT)/rules.d/2-binary-arch.mk
180
181 # Rules for building the udebs ($(DEBIAN)-installer)
182 include $(DROOT)/rules.d/5-udebs.mk
183
184 # Builds the source, doc and linux-headers indep packages
185 include $(DROOT)/rules.d/3-binary-indep.mk
186
187 # Various checks to be performed on builds
188 include $(DROOT)/rules.d/4-checks.mk
189
190 control_files := $(DEBIAN)/control.stub.in
191 ifeq ($(do_libc_dev_package),true)
192 ifneq (,$(wildcard $(DEBIAN)/control.d/linux-libc-dev.stub))
193 control_files += $(DEBIAN)/control.d/linux-libc-dev.stub
194 endif
195 endif
196 ifeq ($(do_doc_package),true)
197 ifneq (,$(wildcard $(DEBIAN)/control.d/linux-doc.stub))
198 control_files += $(DEBIAN)/control.d/linux-doc.stub
199 endif
200 endif
201
202 # Misc stuff
203 .PHONY: $(DEBIAN)/control.stub
204 $(DEBIAN)/control.stub: \
205 $(DROOT)/scripts/control-create \
206 $(control_files) \
207 $(DEBIAN)/changelog \
208 $(wildcard $(DEBIAN)/control.d/* $(DEBIAN)/sub-flavours/*.vars)
209 for i in $(control_files); do \
210 cat $$i; \
211 echo ""; \
212 done | sed -e 's/PKGVER/$(release)/g' \
213 -e 's/ABINUM/$(abinum)/g' \
214 -e 's/SRCPKGNAME/$(src_pkg_name)/g' \
215 -e 's/=HUMAN=/$(human_arch)/g' \
216 -e 's/=SERIES=/$(series)/g' \
217 > $(DEBIAN)/control.stub;
218 flavours="$(sort $(wildcard $(DEBIAN)/control.d/vars.* $(DEBIAN)/sub-flavours/*.vars))";\
219 for i in $$flavours; do \
220 $(SHELL) $(DROOT)/scripts/control-create $$i "$(any_signed)" | \
221 sed -e 's/PKGVER/$(release)/g' \
222 -e 's/ABINUM/$(abinum)/g' \
223 -e 's/SRCPKGNAME/$(src_pkg_name)/g' \
224 -e 's/=HUMAN=/$(human_arch)/g' \
225 -e 's/=SERIES=/$(series)/g' \
226 >> $(DEBIAN)/control.stub; \
227 done
228
229 .PHONY: debian/control
230 debian/control: $(DEBIAN)/control.stub
231 echo "# placebo control.stub for kernel-wedge flow change" >debian/control.stub
232 cp $(DEBIAN)/control.stub debian/control
233 ifeq ($(disable_d_i),)
234 # start new paragraph in debian/control
235 echo >> debian/control
236 # append udeb packages
237 export KW_DEFCONFIG_DIR=$(DEBIAN)/d-i && \
238 export KW_CONFIG_DIR=$(DEBIAN)/d-i && \
239 LANG=C kernel-wedge gen-control $(release)-$(abinum) | \
240 grep-dctrl -FArchitecture $(arch) \
241 >>$(CURDIR)/debian/control
242 endif
243
244 debian/canonical-certs.pem: $(wildcard $(DROOT)/certs/*-all.pem) $(wildcard $(DROOT)/certs/*-$(arch).pem) $(wildcard $(DEBIAN)/certs/*-all.pem) $(wildcard $(DEBIAN)/certs/*-$(arch).pem)
245 for cert in $(sort $(notdir $^)); \
246 do \
247 for dir in $(DEBIAN) $(DROOT); \
248 do \
249 if [ -f "$$dir/certs/$$cert" ]; then \
250 cat "$$dir/certs/$$cert"; \
251 break; \
252 fi; \
253 done; \
254 done >"$@"