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 DEBIAN
=$(shell awk
-F
= '($$1 == "DEBIAN") { print $$2 }' <debian
/debian.env
)
12 # dpkg-buildpackage passes options that are incomptatible
13 # with the kernel build.
18 export SHELL
=/bin
/bash
-e
20 # Where do we find the common configuration.
23 # Common variables for all architectures
24 include $(DROOT
)/rules.d
/0-common-vars.mk
26 # Pull in some arch specific stuff
27 -include $(DEBIAN
)/rules.d
/$(arch
).mk
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
34 include $(DROOT
)/rules.d
/1-maintainer.mk
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
)))
40 do_tools_perf_jvmti?
=false
43 # Default settings for DKMS modules.
44 $(foreach _m
,$(all_dkms_modules
), \
45 $(eval do_
$(_m
) ?
= $(if
$(filter $(_m
),$(filter-out $(dkms_exclude
),$(dkms_include
) $(subst any
,$(_m
),$(subst $(arch
),$(_m
),$(dkms_
$(_m
)_archs
))))),true
,false
)) \
48 # Don't build tools in a cross compile environment.
49 ifneq ($(DEB_HOST_ARCH
),$(DEB_BUILD_ARCH
))
51 $(foreach _m
,$(all_dkms_modules
),$(eval do_
$(_m
) = false
))
54 # Are any of the kernel signing options enabled.
55 any_signed
=$(sort $(filter-out false
,$(uefi_signed
) $(opal_signed
) $(sipl_signed
)))
56 ifeq ($(any_signed
),true
)
57 bin_pkg_name
=$(bin_pkg_name_unsigned
)
59 bin_pkg_name
=$(bin_pkg_name_signed
)
62 # Stages -- support both DEB_STAGE=stage1 and DEB_BUILD_PROFILE=bootstrap
63 ifeq ($(DEB_STAGE
),stage1
)
64 DEB_BUILD_PROFILES
=stage1
66 ifneq ($(DEB_BUILD_PROFILE
),)
67 DEB_BUILD_PROFILES
=$(DEB_BUILD_PROFILE
)
69 ifneq ($(filter stage1
,$(DEB_BUILD_PROFILES
)),)
72 do_source_package
=false
73 do_flavour_image_package
=false
74 do_flavour_header_package
=false
77 # autopkgtest -- rebuild support
78 # - only build the first flavour on the assumption it is representative
79 # - disable dkms builds as the versions used may have been deleted
80 ifneq ($(filter autopkgtest
,$(DEB_BUILD_PROFILES
)),)
81 flavours
:= $(firstword $(flavours
))
82 $(foreach _m
,$(all_dkms_modules
),$(eval do_
$(_m
) = false
))
85 # Being used to build a mainline build -- turn off things which do not work.
86 ifeq ($(do_mainline_build
),true
)
87 do_extras_package
=false
90 $(foreach _m
,$(all_dkms_modules
),$(eval do_
$(_m
) = false
))
96 # Disable tools build and packaging if do_tools != true
97 ifneq ($(do_tools
),true
)
104 $(foreach _m
,$(all_built-in_dkms_modules
), \
105 $(if
$(filter true
,$(do_
$(_m
))),, \
106 $(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
)) \
110 ifeq ($(do_dkms_wireguard
),false
)
111 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
)
114 # Either tools package needs the common source preparation
115 do_any_tools
=$(sort $(filter-out false
,$(do_linux_tools
) $(do_cloud_tools
)))
117 # NVIDIA DKMS package gross series split into desktop and server.
118 nvidia_desktop_series
=$(shell sed
-n
-e
's/^nvidia-graphics-drivers-\([0-9][0-9]*\) .*/\1/p' debian
/dkms-versions
)
119 nvidia_server_series
=$(shell sed
-n
-e
's/^nvidia-graphics-drivers-\([0-9][0-9]*-server\) .*/\1/p' debian
/dkms-versions
)
121 # Debian Build System targets
122 binary
: binary-indep binary-arch
124 build
: build-arch build-indep
126 clean: debian
/control debian
/canonical-certs.pem debian
/canonical-revoked-certs.pem
132 rm -rf
$(DEBIAN
)/abi
/$(release
)-$(revision
)
134 rm -f
$(stampdir
)/stamp-
*
135 rm -rf
$(DEBIAN
)/linux-
*
137 cp
$(DEBIAN
)/changelog debian
/changelog
139 # Install the copyright information.
140 cp
$(DEBIAN
)/copyright debian
/copyright
142 # Install the retpoline extractor.
143 cp
$(DROOT
)/scripts
/retpoline-extract-one scripts
/ubuntu-retpoline-extract-one
145 # If we have a reconstruct script use it.
146 [ -f
$(DEBIAN
)/reconstruct
] && bash
$(DEBIAN
)/reconstruct || true
148 # Remove generated intermediate files
149 rm -f
$(DROOT
)/control.stub
$(DEBIAN
)/control.stub
150 rm -f
$(DROOT
)/scripts
/fix-filenames
153 rm -rf
$(DROOT
)/control debian
/changelog \
154 debian
/control debian
/control.stub debian
/copyright \
155 scripts
/ubuntu-retpoline-extract-one
157 # Builds the image, arch headers and debug packages
158 include $(DROOT
)/rules.d
/2-binary-arch.mk
160 # Builds the source, doc and linux-headers indep packages
161 include $(DROOT
)/rules.d
/3-binary-indep.mk
163 # Various checks to be performed on builds
164 include $(DROOT
)/rules.d
/4-checks.mk
166 control_files
:= $(DEBIAN
)/control.stub.in
167 ifeq ($(do_libc_dev_package
),true
)
168 ifneq (,$(wildcard $(DEBIAN
)/control.d
/linux-libc-dev.stub
))
169 control_files
+= $(DEBIAN
)/control.d
/linux-libc-dev.stub
172 ifeq ($(do_doc_package
),true
)
173 ifneq (,$(wildcard $(DEBIAN
)/control.d
/linux-doc.stub
))
174 control_files
+= $(DEBIAN
)/control.d
/linux-doc.stub
179 .PHONY
: $(DEBIAN
)/control.stub
180 $(DEBIAN
)/control.stub
: \
181 $(DROOT
)/scripts
/control-create \
183 $(DROOT
)/control.d
/flavour-module.stub \
184 $(DEBIAN
)/changelog \
185 $(wildcard $(DEBIAN
)/control.d
/* $(DEBIAN
)/sub-flavours
/*.vars
)
186 for i in
$(control_files
); do \
189 done | sed
-e
's/PKGVER/$(release)/g' \
190 -e
's/ABINUM/$(abinum)/g' \
191 -e
's/SRCPKGNAME/$(src_pkg_name)/g' \
192 -e
's/=HUMAN=/$(human_arch)/g' \
193 -e
's/=SERIES=/$(series)/g' \
194 > $(DEBIAN
)/control.stub
;
195 flavours
="$(sort $(wildcard $(DEBIAN)/control.d/vars.* $(DEBIAN)/sub-flavours/*.vars))";\
196 for i in
$$flavours; do \
197 $(SHELL
) $(DROOT
)/scripts
/control-create
$$i "$(any_signed)" | \
198 sed
-e
's/PKGVER/$(release)/g' \
199 -e
's/ABINUM/$(abinum)/g' \
200 -e
's/SRCPKGNAME/$(src_pkg_name)/g' \
201 -e
's/=HUMAN=/$(human_arch)/g' \
202 -e
's/=SERIES=/$(series)/g' \
203 >> $(DEBIAN
)/control.stub
; \
206 .PHONY
: debian
/control
207 debian
/control
: $(DEBIAN
)/control.stub
208 cp
$(DEBIAN
)/control.stub debian
/control
210 debian
/canonical-certs.pem
: $(wildcard $(DROOT
)/certs
/*-all.pem
) $(wildcard $(DROOT
)/certs
/*-$(arch
).pem
) $(wildcard $(DEBIAN
)/certs
/*-all.pem
) $(wildcard $(DEBIAN
)/certs
/*-$(arch
).pem
)
211 for cert in
$(sort $(notdir $^
)); \
213 for
dir in
$(DEBIAN
) $(DROOT
); \
215 if
[ -f
"$$dir/certs/$$cert" ]; then \
216 cat
"$$dir/certs/$$cert"; \
222 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
)
223 for cert in
$(sort $(notdir $^
)); \
225 for
dir in
$(DEBIAN
) $(DROOT
); \
227 if
[ -f
"$$dir/revoked-certs/$$cert" ]; then \
228 cat
"$$dir/revoked-certs/$$cert"; \