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