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