3 # $(DEBIAN)/rules for Ubuntu linux
5 # Use this however you want, just give credit where credit is due.
7 # Copyright (c) 2007 Ben Collins <bcollins@ubuntu.com>
10 DEBIAN
=$(shell awk
-F
= '($$1 == "DEBIAN") { print $$2 }' <debian
/debian.env
)
12 # dpkg-buildpackage passes options that are incomptatible
13 # with the kernel build.
18 export SHELL
=/bin
/bash
-e
20 # Where do we find the common configuration.
23 # Common variables for all architectures
24 include $(DROOT
)/rules.d
/0-common-vars.mk
26 # Pull in some arch specific stuff
27 -include $(DEBIAN
)/rules.d
/$(arch
).mk
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
34 include $(DROOT
)/rules.d
/1-maintainer.mk
36 do_linux_tools
=$(sort $(filter-out false
,$(do_tools_usbip
) $(do_tools_cpupower
) $(do_tools_perf
) $(do_tools_x86
)))
37 do_cloud_tools
=$(sort $(filter-out false
,$(do_tools_hyperv
)))
39 # Don't build tools or udebs in a cross compile environment.
40 ifneq ($(DEB_HOST_ARCH
),$(DEB_BUILD_ARCH
))
46 # Stages -- support both DEB_STAGE=stage1 and DEB_BUILD_PROFILE=bootstrap
47 ifeq ($(DEB_STAGE
),stage1
)
48 DEB_BUILD_PROFILES
=stage1
50 ifneq ($(DEB_BUILD_PROFILE
),)
51 DEB_BUILD_PROFILES
=$(DEB_BUILD_PROFILE
)
53 ifneq ($(filter stage1
,$(DEB_BUILD_PROFILES
)),)
56 do_source_package
=false
57 do_flavour_image_package
=false
58 do_flavour_header_package
=false
61 # Being used to build a mainline build -- turn off things which do not work.
62 ifeq ($(do_mainline_build
),true
)
63 do_extras_package
=false
72 # Disable tools build and packaging if do_tools != true
73 ifneq ($(do_tools
),true
)
79 ifeq ($(do_zfs
),false
)
80 do_zfs_disable
:=$(shell cat
$(DROOT
)/zfs-modules.ignore
>>$(prev_abidir
)/..
/modules.ignore
)
83 # Either tools package needs the common source preparation
84 do_any_tools
=$(sort $(filter-out false
,$(do_linux_tools
) $(do_cloud_tools
)))
86 # autopkgtest -- rebuild support
87 # only build the first flavour on the assumption it is representative
88 ifneq ($(filter autopkgtest
,$(DEB_BUILD_PROFILES
)),)
89 flavours
:= $(firstword $(flavours
))
92 # Debian Build System targets
93 binary
: binary-indep binary-arch
95 build
: build-arch build-indep
103 rm -rf
$(DEBIAN
)/d-i-
$(arch
)
104 # Generated on the fly.
105 rm -f
$(DEBIAN
)/d-i
/firmware
/kernel-image
108 rm -rf
$(DEBIAN
)/abi
/$(release
)-$(revision
)
110 rm -f
$(stampdir
)/stamp-
*
111 rm -rf
$(DEBIAN
)/linux-
*
113 # This gets rid of the d-i packages in control
114 cp
-f
$(DEBIAN
)/control.stub
$(DROOT
)/control
115 cp
$(DEBIAN
)/changelog debian
/changelog
117 # Install the copyright information.
118 cp
$(DEBIAN
)/copyright debian
/copyright
120 # Install the retpoline extractor.
121 cp
$(DROOT
)/scripts
/retpoline-extract-one scripts
/ubuntu-retpoline-extract-one
123 # If we have a reconstruct script use it.
124 [ -f
$(DEBIAN
)/reconstruct
] && bash
$(DEBIAN
)/reconstruct
126 # Remove generated intermediate files
127 rm -f
$(DROOT
)/control.stub
$(DEBIAN
)/control.stub \
128 $(DEBIAN
)/d-i
/kernel-versions
131 rm -rf
$(DROOT
)/control debian
/changelog \
132 debian
/control debian
/control.stub debian
/copyright \
133 scripts
/ubuntu-retpoline-extract-one
135 # Builds the image, arch headers and debug packages
136 include $(DROOT
)/rules.d
/2-binary-arch.mk
138 # Rules for building the udebs ($(DEBIAN)-installer)
139 include $(DROOT
)/rules.d
/5-udebs.mk
141 # Builds the source, doc and linux-headers indep packages
142 include $(DROOT
)/rules.d
/3-binary-indep.mk
144 # Various checks to be performed on builds
145 include $(DROOT
)/rules.d
/4-checks.mk
148 .PHONY
: $(DEBIAN
)/control.stub
149 $(DEBIAN
)/control.stub
: $(DEBIAN
)/d-i
/kernel-versions.in \
150 $(DROOT
)/scripts
/control-create \
151 $(DEBIAN
)/control.stub.in \
152 $(DEBIAN
)/changelog \
153 $(wildcard $(DEBIAN
)/control.d
/* $(DEBIAN
)/sub-flavours
/*.vars
)
154 for i in
$(DEBIAN
)/d-i
/kernel-versions.in
$(DEBIAN
)/control.stub.in
; do \
155 new
=`echo $$i | sed 's/\.in$$//'`; \
156 cat
$$i | sed
-e
's/PKGVER/$(release)/g' \
157 -e
's/ABINUM/$(abinum)/g' \
158 -e
's/SRCPKGNAME/$(src_pkg_name)/g' \
159 -e
's/=HUMAN=/$(human_arch)/g' \
162 flavours
="$(sort $(wildcard $(DEBIAN)/control.d/vars.* $(DEBIAN)/sub-flavours/*.vars))";\
163 for i in
$$flavours; do \
164 $(SHELL
) $(DROOT
)/scripts
/control-create
$$i | \
165 sed
-e
's/PKGVER/$(release)/g' \
166 -e
's/ABINUM/$(abinum)/g' \
167 -e
's/SRCPKGNAME/$(src_pkg_name)/g' \
168 -e
's/=HUMAN=/$(human_arch)/g' \
169 >> $(DEBIAN
)/control.stub
; \
172 .PHONY
: debian
/control
173 debian
/control
: $(DEBIAN
)/control.stub
174 rm -rf
$(builddir
)/modules
$(builddir
)/firmware \
175 $(builddir
)/kernel-versions
$(builddir
)/package-list \
176 $(builddir
)/$(DEBIAN
)
177 mkdir
-p
$(builddir
)/modules
/$(arch
)/
178 cp
$(DEBIAN
)/d-i
/modules
/* $(builddir
)/modules
/$(arch
)/
179 mkdir
-p
$(builddir
)/firmware
/$(arch
)/
180 cp
$(DEBIAN
)/d-i
/firmware
/* $(builddir
)/firmware
/$(arch
)/
181 cp
$(DEBIAN
)/d-i
/package-list
$(DEBIAN
)/d-i
/kernel-versions
$(builddir
)/
182 touch
$(builddir
)/modules
/$(arch
)/kernel-image
183 # kernel-wedge needs to poke around in $(DEBIAN)/
184 ln
-nsf
$(CURDIR
)/debian
$(builddir
)/debian
186 # Some files may need to differ between architectures
187 if
[ -d
$(DEBIAN
)/d-i
/modules-
$(arch
) ]; then \
188 cp
$(DEBIAN
)/d-i
/modules-
$(arch
)/* \
189 $(builddir
)/modules
/$(arch
)/; \
191 if
[ -d
$(DEBIAN
)/d-i
/firmware-
$(arch
) ]; then \
192 cp
$(DEBIAN
)/d-i
/firmware-
$(arch
)/* \
193 $(builddir
)/firmware
/$(arch
)/; \
196 # Remove unwanted stuff for this architecture
197 if
[ -r
"$(DEBIAN)/d-i/exclude-modules.$(arch)" ]; then \
198 (cat
$(DEBIAN
)/d-i
/exclude-modules.
$(arch
); \
199 ls
$(builddir
)/modules
/$(arch
)/) |
sort | uniq
-d | \
200 (cd
$(builddir
)/modules
/$(arch
)/; xargs
rm -f
); \
202 if
[ -r
"$(DEBIAN)/d-i/exclude-firmware.$(arch)" ]; then \
203 (cat
$(DEBIAN
)/d-i
/exclude-firmware.
$(arch
); \
204 ls
$(builddir
)/firmware
/$(arch
)/) |
sort | uniq
-d | \
205 (cd
$(builddir
)/firmware
/$(arch
)/; xargs
rm -f
); \
208 # Per flavour module lists
209 flavour_modules
=`ls $(DEBIAN)/d-i/modules.$(arch)-* 2>/dev/null` \
211 if
[ "$$flavour_modules" != "" ]; then \
212 for flav in
$$flavour_modules; do \
213 name
=`echo $$flav | sed 's/.*\/modules.$(arch)-//'`; \
214 mkdir
$(builddir
)/modules
/$(arch
)-$$name; \
215 (cd
$(builddir
)/modules
/; tar cf
- `cat ../$$flav`) | \
216 (cd
$(builddir
)/modules
/$(arch
)-$$name/; tar xf
-); \
217 touch
$(builddir
)/modules
/$(arch
)-$$name/kernel-image
; \
220 flavour_firmware
=`ls $(DEBIAN)/d-i/firmware.$(arch)-* 2>/dev/null` \
222 if
[ "$$flavour_firmware" != "" ]; then \
223 for flav in
$$flavour_firmware; do \
224 name
=`echo $$flav | sed 's/.*\/firmware.$(arch)-//'`; \
225 mkdir
$(builddir
)/firmware
/$(arch
)-$$name; \
226 (cd
$(builddir
)/firmware
/; tar cf
- `cat ../$$flav`) | \
227 (cd
$(builddir
)/firmware
/$(arch
)-$$name/; tar xf
-);\
228 touch
$(builddir
)/firmware
/$(arch
)-$$name/kernel-image
; \
232 # Some files may need to differ between flavours
233 flavour_module_dirs
=`ls -d $(DEBIAN)/d-i/modules-$(arch)-* 2>/dev/null`\
235 if
[ "$$flavour_module_dirs" ]; then \
236 for flav in
$$flavour_module_dirs; do \
237 name
=`echo $$flav | sed 's/.*\/modules-$(arch)-//'`; \
238 [ -d
$(builddir
)/modules
/$(arch
)-$$name ] || \
239 cp
-a
$(builddir
)/modules
/$(arch
) \
240 modules
/$(arch
)-$$name; \
241 cp
$$flav/* $(builddir
)/modules
/$(arch
)-$$name/; \
244 flavour_firmware_dirs
=`ls -d $(DEBIAN)/d-i/firmware-$(arch)-* 2>/dev/null`\
246 if
[ "$$flavour_firmware_dirs" ]; then \
247 for flav in
$$flavour_firmware_dirs; do \
248 name
=`echo $$flav | sed 's/.*\/firmware-$(arch)-//'`; \
249 [ -d
$(builddir
)/firmware
/$(arch
)-$$name ] || \
250 cp
-a
$(builddir
)/firmware
/$(arch
) \
251 firmware
/$(arch
)-$$name; \
252 cp
$$flav/* $(builddir
)/firmware
/$(arch
)-$$name/; \
256 # Remove unwanted stuff for each flavour
257 flavour_exclude
=`ls $(DEBIAN)/d-i/exclude-modules.$(arch)-* 2>/dev/null`\
259 if
[ "$$flavour_exclude" ]; then \
260 for flav in
$$flavour_exclude; do \
261 name
=`echo $$flav | sed 's/.*\/exclude-modules.$(arch)-//'`;\
262 [ -d
$(builddir
)/modules
/$(arch
)-$$name ] || \
263 cp
-a
$(builddir
)/modules
/$(arch
) \
264 $(builddir
)/modules
/$(arch
)-$$name; \
266 ls
$(builddir
)/modules
/$(arch
)-$$name) | \
268 (cd
$(builddir
)/modules
/$(arch
)-$$name/; \
272 flavour_exclude
=`ls $(DEBIAN)/d-i/exclude-firmware.$(arch)-* 2>/dev/null`\
274 if
[ "$$flavour_exclude" ]; then \
275 for flav in
$$flavour_exclude; do \
276 name
=`echo $$flav | sed 's/.*\/exclude-firmware.$(arch)-//'`;\
277 [ -d
$(builddir
)/firmware
/$(arch
)-$$name ] || \
278 cp
-a
$(builddir
)/firmware
/$(arch
) \
279 $(builddir
)/firmware
/$(arch
)-$$name; \
281 ls
$(builddir
)/firmware
/$(arch
)-$$name) | \
283 (cd
$(builddir
)/firmware
/$(arch
)-$$name/; \
288 if
[ ! -d
$(builddir
)/modules
/$(build_arch
) ]; then \
289 mkdir
-p
$(builddir
)/modules
/$(build_arch
); \
290 cp
$(builddir
)/modules
/$(arch
)/* \
291 $(builddir
)/modules
/$(build_arch
); \
293 if
[ ! -d
$(builddir
)/firmware
/$(build_arch
) ]; then \
294 mkdir
-p
$(builddir
)/firmware
/$(build_arch
); \
295 cp
$(builddir
)/firmware
/$(arch
)/* \
296 $(builddir
)/firmware
/$(build_arch
); \
299 echo
"# placebo control.stub for kernel-wedge flow change" >debian
/control.stub
300 cp
$(DEBIAN
)/control.stub debian
/control
301 cd
$(builddir
) && LANG
=C kernel-wedge gen-control
>> $(CURDIR
)/debian
/control