]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - debian/rules.d/0-common-vars.mk
UBUNTU: [Packaging] initial packaging import from linux-unstable-5.12
[mirror_ubuntu-jammy-kernel.git] / debian / rules.d / 0-common-vars.mk
1 # Used when you need to 'escape' a comma.
2 comma = ,
3
4 #
5 # The source package name will be the first token from $(DEBIAN)/changelog
6 #
7 src_pkg_name=$(shell sed -n '1s/^\(.*\) (.*).*$$/\1/p' $(DEBIAN)/changelog)
8
9 # Get the series
10 series=$(shell dpkg-parsechangelog -l$(DEBIAN)/changelog | sed -ne 's/^Distribution: *//p' | sed -e 's/-\(security\|updates\|proposed\)$$//')
11
12 # Get some version info
13 release := $(shell sed -n '1s/^$(src_pkg_name).*(\(.*\)-.*).*$$/\1/p' $(DEBIAN)/changelog)
14 revisions := $(shell sed -n 's/^$(src_pkg_name)\ .*($(release)-\(.*\)).*$$/\1/p' $(DEBIAN)/changelog | tac)
15 revision ?= $(word $(words $(revisions)),$(revisions))
16 prev_revisions := $(filter-out $(revision),0.0 $(revisions))
17 prev_revision := $(word $(words $(prev_revisions)),$(prev_revisions))
18
19 prev_fullver ?= $(shell dpkg-parsechangelog -l$(DEBIAN)/changelog -o1 -c1 | sed -ne 's/^Version: *//p')
20
21 # Get variants. Assume primary if debian/variants is not present.
22 variants = --
23 ifneq (,$(wildcard $(DEBIAN)/variants))
24 variants := $(shell cat $(DEBIAN)/variants)
25 endif
26
27 # Get upstream version info
28 upstream_version := $(shell sed -n 's/^VERSION = \(.*\)$$/\1/p' Makefile)
29 upstream_patchlevel := $(shell sed -n 's/^PATCHLEVEL = \(.*\)$$/\1/p' Makefile)
30 upstream_tag := "v$(upstream_version).$(upstream_patchlevel)"
31
32 family=ubuntu
33
34 # This is an internally used mechanism for the daily kernel builds. It
35 # creates packages whose ABI is suffixed with a minimal representation of
36 # the current git HEAD sha. If .git/HEAD is not present, then it uses the
37 # uuidgen program,
38 #
39 # AUTOBUILD can also be used by anyone wanting to build a custom kernel
40 # image, or rebuild the entire set of Ubuntu packages using custom patches
41 # or configs.
42 AUTOBUILD=
43
44 ifneq ($(AUTOBUILD),)
45 skipabi = true
46 skipmodule = true
47 skipretpoline = true
48 skipdbg = true
49 gitver=$(shell if test -f .git/HEAD; then cat .git/HEAD; else uuidgen; fi)
50 gitverpre=$(shell echo $(gitver) | cut -b -3)
51 gitverpost=$(shell echo $(gitver) | cut -b 38-40)
52 abi_suffix = -$(gitverpre)$(gitverpost)
53 endif
54
55 ifneq ($(NOKERNLOG),)
56 ubuntu_log_opts += --no-kern-log
57 endif
58 ifneq ($(PRINTSHAS),)
59 ubuntu_log_opts += --print-shas
60 endif
61
62 # Get the kernels own extra version to be added to the release signature.
63 raw_kernelversion=$(shell make kernelversion)
64
65 #
66 # full_build -- are we doing a full buildd style build
67 #
68 ifeq ($(wildcard /CurrentlyBuilding),)
69 full_build?=false
70 else
71 full_build?=true
72 endif
73
74 #
75 # The debug packages are ginormous, so you probably want to skip
76 # building them (as a developer).
77 #
78 ifeq ($(full_build),false)
79 skipdbg=true
80 endif
81
82 abinum := $(shell echo $(revision) | sed -r -e 's/([^\+~]*)\.[^\.]+(~.*)?(\+.*)?$$/\1/')$(abi_suffix)
83 prev_abinum := $(shell echo $(prev_revision) | sed -r -e 's/([^\+~]*)\.[^\.]+(~.*)?(\+.*)?$$/\1/')$(abi_suffix)
84 abi_release := $(release)-$(abinum)
85
86 uploadnum := $(shell echo $(revision) | sed -r -e 's/[^\+~]*\.([^\.~]+(~.*)?(\+.*)?$$)/\1/')
87 ifneq ($(full_build),false)
88 uploadnum := $(uploadnum)-Ubuntu
89 endif
90
91 # XXX: linux-libc-dev got bumped to -803.N inadvertantly by a ti-omap4 upload
92 # shift our version higher for this package only. Ensure this only
93 # occurs for the v2.6.35 kernel so that we do not propogate this into
94 # any other series.
95 raw_uploadnum := $(shell echo $(revision) | sed -e 's/.*\.//')
96 libc_dev_version :=
97 ifeq ($(DEBIAN),debian.master)
98 ifeq ($(release),2.6.35)
99 libc_dev_version := -v$(release)-$(shell expr "$(abinum)" + 1000).$(raw_uploadnum)
100 endif
101 endif
102
103 DEB_HOST_MULTIARCH = $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
104 DEB_HOST_GNU_TYPE = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
105 DEB_BUILD_GNU_TYPE = $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
106 DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
107 DEB_BUILD_ARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH)
108
109 #
110 # Detect invocations of the form 'fakeroot debian/rules binary arch=armhf'
111 # within an x86'en schroot. This only gets you part of the way since the
112 # packaging phase fails, but you can at least compile the kernel quickly.
113 #
114 arch := $(DEB_HOST_ARCH)
115 ifneq ($(arch),$(DEB_HOST_ARCH))
116 CROSS_COMPILE ?= $(shell dpkg-architecture -a$(arch) -qDEB_HOST_GNU_TYPE -f 2>/dev/null)-
117 endif
118
119 #
120 # Detect invocations of the form 'dpkg-buildpackage -B -aarmhf' within
121 # an x86'en schroot. This is the only way to build all of the packages
122 # (except for tools).
123 #
124 ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
125 CROSS_COMPILE ?= $(DEB_HOST_GNU_TYPE)-
126 endif
127
128 abidir := $(CURDIR)/$(DEBIAN)/abi/current/$(arch)
129 prev_abidir := $(CURDIR)/$(DEBIAN)/abi/previous/$(arch)
130 commonconfdir := $(CURDIR)/$(DEBIAN)/config
131 archconfdir := $(CURDIR)/$(DEBIAN)/config/$(arch)
132 sharedconfdir := $(CURDIR)/debian.master/config
133 builddir := $(CURDIR)/debian/build
134 stampdir := $(CURDIR)/debian/stamps
135
136 #
137 # The binary package name always starts with linux-image-$KVER-$ABI.$UPLOAD_NUM. There
138 # are places that you'll find linux-image hard coded, but I guess thats OK since the
139 # assumption that the binary package always starts with linux-image will never change.
140 #
141 bin_pkg_name_signed=linux-image-$(abi_release)
142 bin_pkg_name_unsigned=linux-image-unsigned-$(abi_release)
143 mods_pkg_name=linux-modules-$(abi_release)
144 mods_extra_pkg_name=linux-modules-extra-$(abi_release)
145 bldinfo_pkg_name=linux-buildinfo-$(abi_release)
146 hdrs_pkg_name=linux-headers-$(abi_release)
147 indep_hdrs_pkg_name=$(src_pkg_name)-headers-$(abi_release)
148
149 #
150 # The generation of content in the doc package depends on both 'AUTOBUILD=' and
151 # 'do_doc_package_content=true'. There are usually build errors during the development
152 # cycle, so its OK to leave 'do_doc_package_content=false' until those build
153 # failures get sorted out. Finally, the doc package doesn't really need to be built
154 # for developer testing (its kind of slow), so only do it if on a buildd.
155 ifneq ($(filter --,$(variants)),)
156 do_doc_package=true
157 else
158 do_doc_package=false
159 endif
160 do_doc_package_content=false
161 ifeq ($(full_build),false)
162 do_doc_package_content=false
163 endif
164 doc_pkg_name=$(src_pkg_name)-doc
165
166 #
167 # Similarly with the linux-source package, you need not build it as a developer. Its
168 # somewhat I/O intensive and utterly useless.
169 #
170 do_source_package=true
171 do_source_package_content=true
172 ifeq ($(full_build),false)
173 do_source_package_content=false
174 endif
175
176 # linux-libc-dev may not be needed, default to building it only for the
177 # primary variant
178 ifneq ($(filter --,$(variants)),)
179 do_libc_dev_package=true
180 else
181 do_libc_dev_package=false
182 endif
183
184 # common headers normally is built as an indep package, but may be arch
185 do_common_headers_indep=true
186
187 # add a 'full source' mode
188 do_full_source=false
189
190 # build tools
191 ifneq ($(wildcard $(CURDIR)/tools),)
192 ifeq ($(do_tools),)
193 ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
194 do_tools=false
195 endif
196 endif
197 do_tools?=true
198 else
199 do_tools?=false
200 endif
201 tools_pkg_name=$(src_pkg_name)-tools-$(abi_release)
202 tools_common_pkg_name=$(src_pkg_name)-tools-common
203 tools_flavour_pkg_name=linux-tools-$(abi_release)
204 cloud_pkg_name=$(src_pkg_name)-cloud-tools-$(abi_release)
205 cloud_common_pkg_name=$(src_pkg_name)-cloud-tools-common
206 cloud_flavour_pkg_name=linux-cloud-tools-$(abi_release)
207 hosttools_pkg_name=$(src_pkg_name)-tools-host
208
209 # The general flavour specific image package.
210 do_flavour_image_package=true
211
212 # The general flavour specific header package.
213 do_flavour_header_package=true
214
215 # DTBs
216 do_dtbs=false
217
218 # Support parallel=<n> in DEB_BUILD_OPTIONS (see #209008)
219 #
220 # These 2 environment variables set the -j value of the kernel build. For example,
221 # CONCURRENCY_LEVEL=16 fakeroot $(DEBIAN)/rules binary-debs
222 # or
223 # DEB_BUILD_OPTIONS=parallel=16 fakeroot $(DEBIAN)/rules binary-debs
224 #
225 # The default is to use the number of CPUs.
226 #
227 COMMA=,
228 DEB_BUILD_OPTIONS_PARA = $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
229 ifneq (,$(DEB_BUILD_OPTIONS_PARA))
230 CONCURRENCY_LEVEL := $(DEB_BUILD_OPTIONS_PARA)
231 endif
232
233 ifeq ($(CONCURRENCY_LEVEL),)
234 # Check the environment
235 CONCURRENCY_LEVEL := $(shell echo $$CONCURRENCY_LEVEL)
236 # No? Then build with the number of CPUs on the host.
237 ifeq ($(CONCURRENCY_LEVEL),)
238 CONCURRENCY_LEVEL := $(shell expr `getconf _NPROCESSORS_ONLN` \* 1)
239 endif
240 # Oh hell, give 'em one
241 ifeq ($(CONCURRENCY_LEVEL),)
242 CONCURRENCY_LEVEL := 1
243 endif
244 endif
245
246 conc_level = -j$(CONCURRENCY_LEVEL)
247
248 PYTHON ?= $(firstword $(wildcard /usr/bin/python3) $(wildcard /usr/bin/python2) $(wildcard /usr/bin/python))
249
250 # target_flavour is filled in for each step
251 kmake = make ARCH=$(build_arch) \
252 CROSS_COMPILE=$(CROSS_COMPILE) \
253 KERNELVERSION=$(abi_release)-$(target_flavour) \
254 CONFIG_DEBUG_SECTION_MISMATCH=y \
255 KBUILD_BUILD_VERSION="$(uploadnum)" \
256 LOCALVERSION= localver-extra= \
257 CFLAGS_MODULE="-DPKG_ABI=$(abinum)" \
258 PYTHON=$(PYTHON)
259 ifneq ($(LOCAL_ENV_CC),)
260 kmake += CC="$(LOCAL_ENV_CC)" DISTCC_HOSTS="$(LOCAL_ENV_DISTCC_HOSTS)"
261 endif
262
263 # Locking is required in parallel builds to prevent loss of contents
264 # of the debian/files.
265 lockme_file = $(CURDIR)/debian/.LOCK
266 lockme_cmd = flock -w 60
267 lockme = $(lockme_cmd) $(lockme_file)
268
269 # Don't fail if a link already exists.
270 LN = ln -sf
271
272 # Checks if a var is overriden by the custom rules. Called with var and
273 # flavour as arguments.
274 custom_override = \
275 $(shell if [ -n "$($(1)_$(2))" ]; then echo "$($(1)_$(2))"; else echo "$($(1))"; fi)
276
277 # selftests that Ubuntu cares about
278 ubuntu_selftests = breakpoints cpu-hotplug efivarfs memfd memory-hotplug mount net ptrace seccomp timers powerpc user ftrace