3 # $(DEBIAN)/rules for Ubuntu linux
5 # Use this however you want, just give credit where credit is due.
7 # Copyright (c) 2007 Ben Collins <bcollins@ubuntu.com>
10 # Do not use make's built-in rules and variables
11 # (this increases performance and avoids hard-to-debug behaviour)
14 DEBIAN
=$(shell awk
-F
= '($$1 == "DEBIAN") { print $$2 }' <debian
/debian.env
)
16 # dpkg-buildpackage passes options that are incomptatible
17 # with the kernel build.
22 export SHELL
=/bin
/bash
-e
24 # Where do we find the common configuration.
27 # Temporary workaround to fix build issues if only python2 runtime is installed
28 # (without python3-dev).
31 # Common variables for all architectures
32 include $(DROOT
)/rules.d
/0-common-vars.mk
34 # Pull in some arch specific stuff
35 -include $(DEBIAN
)/rules.d
/$(arch
).mk
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
42 include $(DROOT
)/rules.d
/1-maintainer.mk
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
)))
48 do_tools_perf_jvmti?
=false
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
)) \
56 # Don't build tools in a cross compile environment.
57 ifneq ($(DEB_HOST_ARCH
),$(DEB_BUILD_ARCH
))
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
)
66 bin_pkg_name
=$(bin_pkg_name_signed
)
69 # Stages -- support both DEB_STAGE=stage1 and DEB_BUILD_PROFILE=bootstrap
70 ifeq ($(DEB_STAGE
),stage1
)
71 DEB_BUILD_PROFILES
=stage1
73 ifneq ($(DEB_BUILD_PROFILE
),)
74 DEB_BUILD_PROFILES
=$(DEB_BUILD_PROFILE
)
76 ifneq ($(filter stage1
,$(DEB_BUILD_PROFILES
)),)
79 do_source_package
=false
80 do_flavour_image_package
=false
81 do_flavour_header_package
=false
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
))
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
97 $(foreach _m
,$(all_dkms_modules
),$(eval do_
$(_m
) = false
))
103 # Disable tools build and packaging if do_tools != true
104 ifneq ($(do_tools
),true
)
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
)) \
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
)
121 # Either tools package needs the common source preparation
122 do_any_tools
=$(sort $(filter-out false
,$(do_linux_tools
) $(do_cloud_tools
)))
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
)
128 # Debian Build System targets
130 binary
: binary-indep binary-arch
133 build
: build-arch build-indep
136 clean: debian
/control debian
/canonical-certs.pem debian
/canonical-revoked-certs.pem
142 rm -rf
$(DEBIAN
)/abi
/$(release
)-$(revision
)
144 rm -f
$(stampdir
)/stamp-
*
145 rm -rf
$(DEBIAN
)/linux-
*
147 cp
$(DEBIAN
)/changelog debian
/changelog
149 # Install the copyright information.
150 cp
$(DEBIAN
)/copyright debian
/copyright
152 # Install the retpoline extractor.
153 cp
$(DROOT
)/scripts
/retpoline-extract-one scripts
/ubuntu-retpoline-extract-one
155 # If we have a reconstruct script use it.
156 [ -f
$(DEBIAN
)/reconstruct
] && bash
$(DEBIAN
)/reconstruct || true
158 # Remove generated intermediate files
159 rm -f
$(DROOT
)/control.stub
$(DEBIAN
)/control.stub
160 rm -f
$(DROOT
)/scripts
/fix-filenames
164 rm -rf
$(DROOT
)/control debian
/changelog \
165 debian
/control debian
/control.stub debian
/copyright \
166 scripts
/ubuntu-retpoline-extract-one
168 # Builds the image, arch headers and debug packages
169 include $(DROOT
)/rules.d
/2-binary-arch.mk
171 # Builds the source, doc and linux-headers indep packages
172 include $(DROOT
)/rules.d
/3-binary-indep.mk
174 # Various checks to be performed on builds
175 include $(DROOT
)/rules.d
/4-checks.mk
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
183 ifeq ($(do_doc_package
),true
)
184 ifneq (,$(wildcard $(DEBIAN
)/control.d
/linux-doc.stub
))
185 control_files
+= $(DEBIAN
)/control.d
/linux-doc.stub
190 .PHONY
: $(DEBIAN
)/control.stub
191 $(DEBIAN
)/control.stub
: \
192 $(DROOT
)/scripts
/control-create \
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 \
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
; \
218 .PHONY
: debian
/control
219 debian
/control
: $(DEBIAN
)/control.stub
220 cp
$(DEBIAN
)/control.stub debian
/control
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 $^
)); \
225 for
dir in
$(DEBIAN
) $(DROOT
); \
227 if
[ -f
"$$dir/certs/$$cert" ]; then \
228 cat
"$$dir/certs/$$cert"; \
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 $^
)); \
237 for
dir in
$(DEBIAN
) $(DROOT
); \
239 if
[ -f
"$$dir/revoked-certs/$$cert" ]; then \
240 cat
"$$dir/revoked-certs/$$cert"; \