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