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