]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - debian/rules
UBUNTU: [Debian] module blacklists -- add support for manual blacklists
[mirror_ubuntu-zesty-kernel.git] / debian / rules
CommitLineData
356bd1e1
LO
1#!/usr/bin/make -f
2#
3# $(DEBIAN)/rules for Ubuntu linux
4#
5# Use this however you want, just give credit where credit is due.
6#
7# Copyright (c) 2007 Ben Collins <bcollins@ubuntu.com>
8#
9
10DEBIAN=$(shell awk -F= '($$1 == "DEBIAN") { print $$2 }' <debian/debian.env)
11
12# dpkg-buildpackage passes options that are incomptatible
13# with the kernel build.
14unexport CFLAGS
15unexport LDFLAGS
16
17export LC_ALL=C
18export SHELL=/bin/bash -e
19
20# Where do we find the common configuration.
21export DROOT=debian
22
23# Common variables for all architectures
24include $(DROOT)/rules.d/0-common-vars.mk
25
26# Pull in some arch specific stuff
27-include $(DEBIAN)/rules.d/$(arch).mk
28
ed3e21fd
AW
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
32
356bd1e1
LO
33# Maintainer targets
34include $(DROOT)/rules.d/1-maintainer.mk
35
e66f5b2a 36do_linux_tools=$(sort $(filter-out false,$(do_tools_usbip) $(do_tools_cpupower) $(do_tools_perf) $(do_tools_x86)))
d974f731
TG
37do_cloud_tools=$(sort $(filter-out false,$(do_tools_hyperv)))
38
1154d441
TG
39# Don't build tools in a cross compile environment.
40ifneq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH))
d974f731
TG
41 do_tools=false
42endif
43
d3d25a07 44# Stages -- support both DEB_STAGE=stage1 and DEB_BUILD_PROFILE=bootstrap
356bd1e1 45ifeq ($(DEB_STAGE),stage1)
d3d25a07
AW
46 DEB_BUILD_PROFILE=bootstrap
47endif
af1c8d31
AW
48ifneq ($(DEB_BUILD_PROFILE),)
49 DEB_BUILD_PROFILES=$(DEB_BUILD_PROFILE)
50endif
51ifneq ($(filter bootstrap,$(DEB_BUILD_PROFILES)),)
356bd1e1
LO
52 do_tools=false
53 do_doc_package=false
54 do_source_package=false
55 do_flavour_image_package=false
56 do_flavour_header_package=false
57endif
58
aa3f30c9
TG
59# Disable tools build and packaging if do_tools != true
60ifneq ($(do_tools),true)
61 do_linux_tools=
62 do_cloud_tools=
288ce282 63 do_tools_common=
aa3f30c9
TG
64endif
65
66# Either tools package needs the common source preparation
67do_any_tools=$(sort $(filter-out false,$(do_linux_tools) $(do_cloud_tools)))
68
bcbac363
AW
69# autopkgtest -- rebuild support
70# only build the first flavour on the assumption it is representative
71ifeq ($(DEB_BUILD_PROFILE),autopkgtest)
72flavours := $(firstword $(flavours))
73endif
74
356bd1e1
LO
75# Debian Build System targets
76binary: binary-indep binary-arch
77
78build: build-arch build-indep
79
80clean: debian/control
81 dh_testdir
82 dh_testroot
83 dh_clean
84
85 # d-i stuff
86 rm -rf $(DEBIAN)/d-i-$(arch)
b3dd6088
AW
87 # Generated on the fly.
88 rm -f $(DEBIAN)/d-i/firmware/kernel-image
356bd1e1
LO
89
90 # normal build junk
91 rm -rf $(DEBIAN)/abi/$(release)-$(revision)
92 rm -rf $(builddir)
93 rm -f $(stampdir)/stamp-*
94 rm -rf $(DEBIAN)/linux-*
95
96 # This gets rid of the d-i packages in control
97 cp -f $(DEBIAN)/control.stub $(DEBIAN)/control
98 cp $(DEBIAN)/changelog debian/changelog
99
100 # Install the copyright information.
101 cp $(DEBIAN)/copyright debian/copyright
102
103distclean: clean
104 rm -rf $(DEBIAN)/control $(DEBIAN)/control.stub \
105 $(DEBIAN)/d-i/kernel-versions debian/changelog \
106 debian/control debian/control.stub debian/copyright
107
108# Builds the image, arch headers and debug packages
109include $(DROOT)/rules.d/2-binary-arch.mk
110
111# Rules for building the udebs ($(DEBIAN)-installer)
112include $(DROOT)/rules.d/5-udebs.mk
113
114# Builds the source, doc and linux-headers indep packages
115include $(DROOT)/rules.d/3-binary-indep.mk
116
117# Various checks to be performed on builds
118include $(DROOT)/rules.d/4-checks.mk
119
120# Misc stuff
121.PHONY: $(DEBIAN)/control.stub
122$(DEBIAN)/control.stub: $(DEBIAN)/d-i/kernel-versions.in \
123 $(DROOT)/scripts/control-create \
124 $(DEBIAN)/control.stub.in \
125 $(DEBIAN)/changelog \
126 $(wildcard $(DEBIAN)/control.d/* $(DEBIAN)/sub-flavours/*.vars)
127 for i in $(DEBIAN)/d-i/kernel-versions.in $(DEBIAN)/control.stub.in; do \
128 new=`echo $$i | sed 's/\.in$$//'`; \
129 cat $$i | sed -e 's/PKGVER/$(release)/g' \
130 -e 's/ABINUM/$(abinum)/g' \
131 -e 's/SRCPKGNAME/$(src_pkg_name)/g' \
132 -e 's/=HUMAN=/$(human_arch)/g' \
133 > $$new; \
134 done
adf41842 135 flavours="$(sort $(wildcard $(DEBIAN)/control.d/vars.* $(DEBIAN)/sub-flavours/*.vars))";\
356bd1e1
LO
136 for i in $$flavours; do \
137 $(SHELL) $(DROOT)/scripts/control-create $$i | \
138 sed -e 's/PKGVER/$(release)/g' \
139 -e 's/ABINUM/$(abinum)/g' \
140 -e 's/SRCPKGNAME/$(src_pkg_name)/g' \
141 -e 's/=HUMAN=/$(human_arch)/g' \
142 >> $(DEBIAN)/control.stub; \
143 done
144 cp $(DEBIAN)/control.stub $(DEBIAN)/control
145
146.PHONY: debian/control
147debian/control: $(DEBIAN)/control.stub
148 rm -rf $(builddir)/modules $(builddir)/firmware \
149 $(builddir)/kernel-versions $(builddir)/package-list \
150 $(builddir)/$(DEBIAN)
151 mkdir -p $(builddir)/modules/$(arch)/
152 cp $(DEBIAN)/d-i/modules/* $(builddir)/modules/$(arch)/
153 mkdir -p $(builddir)/firmware/$(arch)/
154 cp $(DEBIAN)/d-i/firmware/* $(builddir)/firmware/$(arch)/
155 cp $(DEBIAN)/d-i/package-list $(DEBIAN)/d-i/kernel-versions $(builddir)/
156 touch $(builddir)/modules/$(arch)/kernel-image
157 # kernel-wedge needs to poke around in $(DEBIAN)/
158 ln -nsf $(CURDIR)/debian $(builddir)/debian
159
160 # Some files may need to differ between architectures
161 if [ -d $(DEBIAN)/d-i/modules-$(arch) ]; then \
162 cp $(DEBIAN)/d-i/modules-$(arch)/* \
163 $(builddir)/modules/$(arch)/; \
164 fi
165 if [ -d $(DEBIAN)/d-i/firmware-$(arch) ]; then \
166 cp $(DEBIAN)/d-i/firmware-$(arch)/* \
167 $(builddir)/firmware/$(arch)/; \
168 fi
169
170 # Remove unwanted stuff for this architecture
171 if [ -r "$(DEBIAN)/d-i/exclude-modules.$(arch)" ]; then \
172 (cat $(DEBIAN)/d-i/exclude-modules.$(arch); \
173 ls $(builddir)/modules/$(arch)/) | sort | uniq -d | \
174 (cd $(builddir)/modules/$(arch)/; xargs rm -f); \
175 fi
176 if [ -r "$(DEBIAN)/d-i/exclude-firmware.$(arch)" ]; then \
177 (cat $(DEBIAN)/d-i/exclude-firmware.$(arch); \
178 ls $(builddir)/firmware/$(arch)/) | sort | uniq -d | \
179 (cd $(builddir)/firmware/$(arch)/; xargs rm -f); \
180 fi
181
182 # Per flavour module lists
183 flavour_modules=`ls $(DEBIAN)/d-i/modules.$(arch)-* 2>/dev/null` \
184 || true; \
185 if [ "$$flavour_modules" != "" ]; then \
186 for flav in $$flavour_modules; do \
187 name=`echo $$flav | sed 's/.*\/modules.$(arch)-//'`; \
188 mkdir $(builddir)/modules/$(arch)-$$name; \
189 (cd $(builddir)/modules/; tar cf - `cat ../$$flav`) | \
190 (cd $(builddir)/modules/$(arch)-$$name/; tar xf -); \
191 touch $(builddir)/modules/$(arch)-$$name/kernel-image; \
192 done; \
193 fi
194 flavour_firmware=`ls $(DEBIAN)/d-i/firmware.$(arch)-* 2>/dev/null` \
195 || true; \
196 if [ "$$flavour_firmware" != "" ]; then \
197 for flav in $$flavour_firmware; do \
198 name=`echo $$flav | sed 's/.*\/firmware.$(arch)-//'`; \
199 mkdir $(builddir)/firmware/$(arch)-$$name; \
200 (cd $(builddir)/firmware/; tar cf - `cat ../$$flav`) | \
201 (cd $(builddir)/firmware/$(arch)-$$name/; tar xf -);\
202 touch $(builddir)/firmware/$(arch)-$$name/kernel-image; \
203 done; \
204 fi
205
206 # Some files may need to differ between flavours
207 flavour_module_dirs=`ls -d $(DEBIAN)/d-i/modules-$(arch)-* 2>/dev/null`\
208 || true; \
209 if [ "$$flavour_module_dirs" ]; then \
210 for flav in $$flavour_module_dirs; do \
211 name=`echo $$flav | sed 's/.*\/modules-$(arch)-//'`; \
212 [ -d $(builddir)/modules/$(arch)-$$name ] || \
213 cp -a $(builddir)/modules/$(arch) \
214 modules/$(arch)-$$name; \
215 cp $$flav/* $(builddir)/modules/$(arch)-$$name/; \
216 done; \
217 fi
218 flavour_firmware_dirs=`ls -d $(DEBIAN)/d-i/firmware-$(arch)-* 2>/dev/null`\
219 || true; \
220 if [ "$$flavour_firmware_dirs" ]; then \
221 for flav in $$flavour_firmware_dirs; do \
222 name=`echo $$flav | sed 's/.*\/firmware-$(arch)-//'`; \
223 [ -d $(builddir)/firmware/$(arch)-$$name ] || \
224 cp -a $(builddir)/firmware/$(arch) \
225 firmware/$(arch)-$$name; \
226 cp $$flav/* $(builddir)/firmware/$(arch)-$$name/; \
227 done; \
228 fi
229
230 # Remove unwanted stuff for each flavour
231 flavour_exclude=`ls $(DEBIAN)/d-i/exclude-modules.$(arch)-* 2>/dev/null`\
232 || true; \
233 if [ "$$flavour_exclude" ]; then \
234 for flav in $$flavour_exclude; do \
235 name=`echo $$flav | sed 's/.*\/exclude-modules.$(arch)-//'`;\
236 [ -d $(builddir)/modules/$(arch)-$$name ] || \
237 cp -a $(builddir)/modules/$(arch) \
238 $(builddir)/modules/$(arch)-$$name; \
239 (cat $$flav; \
240 ls $(builddir)/modules/$(arch)-$$name) | \
241 sort | uniq -d | \
242 (cd $(builddir)/modules/$(arch)-$$name/; \
243 xargs rm -f); \
244 done; \
245 fi
246 flavour_exclude=`ls $(DEBIAN)/d-i/exclude-firmware.$(arch)-* 2>/dev/null`\
247 || true; \
248 if [ "$$flavour_exclude" ]; then \
249 for flav in $$flavour_exclude; do \
250 name=`echo $$flav | sed 's/.*\/exclude-firmware.$(arch)-//'`;\
251 [ -d $(builddir)/firmware/$(arch)-$$name ] || \
252 cp -a $(builddir)/firmware/$(arch) \
253 $(builddir)/firmware/$(arch)-$$name; \
254 (cat $$flav; \
255 ls $(builddir)/firmware/$(arch)-$$name) | \
256 sort | uniq -d | \
257 (cd $(builddir)/firmware/$(arch)-$$name/; \
258 xargs rm -f); \
259 done; \
260 fi
261
262 if [ ! -d $(builddir)/modules/$(build_arch) ]; then \
263 mkdir -p $(builddir)/modules/$(build_arch); \
264 cp $(builddir)/modules/$(arch)/* \
265 $(builddir)/modules/$(build_arch); \
266 fi
267 if [ ! -d $(builddir)/firmware/$(build_arch) ]; then \
268 mkdir -p $(builddir)/firmware/$(build_arch); \
269 cp $(builddir)/firmware/$(arch)/* \
270 $(builddir)/firmware/$(build_arch); \
271 fi
272
273 cp $(DEBIAN)/control.stub debian/control.stub
adf41842 274 cd $(builddir) && LANG=C kernel-wedge gen-control > $(CURDIR)/debian/control