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
))
44 do_zfs_disable
:=$(shell cat
$(DROOT
)/zfs-modules.ignore
>>$(prev_abidir
)/..
/modules.ignore
)
47 # Stages -- support both DEB_STAGE=stage1 and DEB_BUILD_PROFILE=bootstrap
48 ifeq ($(DEB_STAGE
),stage1
)
49 DEB_BUILD_PROFILES
=stage1
51 ifneq ($(DEB_BUILD_PROFILE
),)
52 DEB_BUILD_PROFILES
=$(DEB_BUILD_PROFILE
)
54 ifneq ($(filter stage1
,$(DEB_BUILD_PROFILES
)),)
57 do_source_package
=false
58 do_flavour_image_package
=false
59 do_flavour_header_package
=false
62 # Being used to build a mainline build -- turn off things which do not work.
63 ifeq ($(do_mainline_build
),true
)
64 do_extras_package
=false
70 # Disable tools build and packaging if do_tools != true
71 ifneq ($(do_tools
),true
)
77 # Either tools package needs the common source preparation
78 do_any_tools
=$(sort $(filter-out false
,$(do_linux_tools
) $(do_cloud_tools
)))
80 # autopkgtest -- rebuild support
81 # only build the first flavour on the assumption it is representative
82 ifneq ($(filter autopkgtest
,$(DEB_BUILD_PROFILES
)),)
83 flavours
:= $(firstword $(flavours
))
86 # Debian Build System targets
87 binary
: binary-indep binary-arch
89 build
: build-arch build-indep
97 rm -rf
$(DEBIAN
)/d-i-
$(arch
)
98 # Generated on the fly.
99 rm -f
$(DEBIAN
)/d-i
/firmware
/kernel-image
102 rm -rf
$(DEBIAN
)/abi
/$(release
)-$(revision
)
104 rm -f
$(stampdir
)/stamp-
*
105 rm -rf
$(DEBIAN
)/linux-
*
107 # This gets rid of the d-i packages in control
108 cp
-f
$(DEBIAN
)/control.stub
$(DROOT
)/control
109 cp
$(DEBIAN
)/changelog debian
/changelog
111 # Install the copyright information.
112 cp
$(DEBIAN
)/copyright debian
/copyright
114 # If we have a reconstruct script use it.
115 [ -f
$(DEBIAN
)/reconstruct
] && bash
$(DEBIAN
)/reconstruct
117 # Remove generated intermediate files
118 rm -f
$(DROOT
)/control.stub
$(DEBIAN
)/control.stub \
119 $(DEBIAN
)/d-i
/kernel-versions
122 rm -rf
$(DROOT
)/control debian
/changelog \
123 debian
/control debian
/control.stub debian
/copyright
125 # Builds the image, arch headers and debug packages
126 include $(DROOT
)/rules.d
/2-binary-arch.mk
128 # Rules for building the udebs ($(DEBIAN)-installer)
129 include $(DROOT
)/rules.d
/5-udebs.mk
131 # Builds the source, doc and linux-headers indep packages
132 include $(DROOT
)/rules.d
/3-binary-indep.mk
134 # Various checks to be performed on builds
135 include $(DROOT
)/rules.d
/4-checks.mk
138 .PHONY
: $(DEBIAN
)/control.stub
139 $(DEBIAN
)/control.stub
: $(DEBIAN
)/d-i
/kernel-versions.in \
140 $(DROOT
)/scripts
/control-create \
141 $(DEBIAN
)/control.stub.in \
142 $(DEBIAN
)/changelog \
143 $(wildcard $(DEBIAN
)/control.d
/* $(DEBIAN
)/sub-flavours
/*.vars
)
144 for i in
$(DEBIAN
)/d-i
/kernel-versions.in
$(DEBIAN
)/control.stub.in
; do \
145 new
=`echo $$i | sed 's/\.in$$//'`; \
146 cat
$$i | sed
-e
's/PKGVER/$(release)/g' \
147 -e
's/ABINUM/$(abinum)/g' \
148 -e
's/SRCPKGNAME/$(src_pkg_name)/g' \
149 -e
's/=HUMAN=/$(human_arch)/g' \
152 flavours
="$(sort $(wildcard $(DEBIAN)/control.d/vars.* $(DEBIAN)/sub-flavours/*.vars))";\
153 for i in
$$flavours; do \
154 $(SHELL
) $(DROOT
)/scripts
/control-create
$$i | \
155 sed
-e
's/PKGVER/$(release)/g' \
156 -e
's/ABINUM/$(abinum)/g' \
157 -e
's/SRCPKGNAME/$(src_pkg_name)/g' \
158 -e
's/=HUMAN=/$(human_arch)/g' \
159 >> $(DEBIAN
)/control.stub
; \
162 .PHONY
: debian
/control
163 debian
/control
: $(DEBIAN
)/control.stub
164 rm -rf
$(builddir
)/modules
$(builddir
)/firmware \
165 $(builddir
)/kernel-versions
$(builddir
)/package-list \
166 $(builddir
)/$(DEBIAN
)
167 mkdir
-p
$(builddir
)/modules
/$(arch
)/
168 cp
$(DEBIAN
)/d-i
/modules
/* $(builddir
)/modules
/$(arch
)/
169 mkdir
-p
$(builddir
)/firmware
/$(arch
)/
170 cp
$(DEBIAN
)/d-i
/firmware
/* $(builddir
)/firmware
/$(arch
)/
171 cp
$(DEBIAN
)/d-i
/package-list
$(DEBIAN
)/d-i
/kernel-versions
$(builddir
)/
172 touch
$(builddir
)/modules
/$(arch
)/kernel-image
173 # kernel-wedge needs to poke around in $(DEBIAN)/
174 ln
-nsf
$(CURDIR
)/debian
$(builddir
)/debian
176 # Some files may need to differ between architectures
177 if
[ -d
$(DEBIAN
)/d-i
/modules-
$(arch
) ]; then \
178 cp
$(DEBIAN
)/d-i
/modules-
$(arch
)/* \
179 $(builddir
)/modules
/$(arch
)/; \
181 if
[ -d
$(DEBIAN
)/d-i
/firmware-
$(arch
) ]; then \
182 cp
$(DEBIAN
)/d-i
/firmware-
$(arch
)/* \
183 $(builddir
)/firmware
/$(arch
)/; \
186 # Remove unwanted stuff for this architecture
187 if
[ -r
"$(DEBIAN)/d-i/exclude-modules.$(arch)" ]; then \
188 (cat
$(DEBIAN
)/d-i
/exclude-modules.
$(arch
); \
189 ls
$(builddir
)/modules
/$(arch
)/) |
sort | uniq
-d | \
190 (cd
$(builddir
)/modules
/$(arch
)/; xargs
rm -f
); \
192 if
[ -r
"$(DEBIAN)/d-i/exclude-firmware.$(arch)" ]; then \
193 (cat
$(DEBIAN
)/d-i
/exclude-firmware.
$(arch
); \
194 ls
$(builddir
)/firmware
/$(arch
)/) |
sort | uniq
-d | \
195 (cd
$(builddir
)/firmware
/$(arch
)/; xargs
rm -f
); \
198 # Per flavour module lists
199 flavour_modules
=`ls $(DEBIAN)/d-i/modules.$(arch)-* 2>/dev/null` \
201 if
[ "$$flavour_modules" != "" ]; then \
202 for flav in
$$flavour_modules; do \
203 name
=`echo $$flav | sed 's/.*\/modules.$(arch)-//'`; \
204 mkdir
$(builddir
)/modules
/$(arch
)-$$name; \
205 (cd
$(builddir
)/modules
/; tar cf
- `cat ../$$flav`) | \
206 (cd
$(builddir
)/modules
/$(arch
)-$$name/; tar xf
-); \
207 touch
$(builddir
)/modules
/$(arch
)-$$name/kernel-image
; \
210 flavour_firmware
=`ls $(DEBIAN)/d-i/firmware.$(arch)-* 2>/dev/null` \
212 if
[ "$$flavour_firmware" != "" ]; then \
213 for flav in
$$flavour_firmware; do \
214 name
=`echo $$flav | sed 's/.*\/firmware.$(arch)-//'`; \
215 mkdir
$(builddir
)/firmware
/$(arch
)-$$name; \
216 (cd
$(builddir
)/firmware
/; tar cf
- `cat ../$$flav`) | \
217 (cd
$(builddir
)/firmware
/$(arch
)-$$name/; tar xf
-);\
218 touch
$(builddir
)/firmware
/$(arch
)-$$name/kernel-image
; \
222 # Some files may need to differ between flavours
223 flavour_module_dirs
=`ls -d $(DEBIAN)/d-i/modules-$(arch)-* 2>/dev/null`\
225 if
[ "$$flavour_module_dirs" ]; then \
226 for flav in
$$flavour_module_dirs; do \
227 name
=`echo $$flav | sed 's/.*\/modules-$(arch)-//'`; \
228 [ -d
$(builddir
)/modules
/$(arch
)-$$name ] || \
229 cp
-a
$(builddir
)/modules
/$(arch
) \
230 modules
/$(arch
)-$$name; \
231 cp
$$flav/* $(builddir
)/modules
/$(arch
)-$$name/; \
234 flavour_firmware_dirs
=`ls -d $(DEBIAN)/d-i/firmware-$(arch)-* 2>/dev/null`\
236 if
[ "$$flavour_firmware_dirs" ]; then \
237 for flav in
$$flavour_firmware_dirs; do \
238 name
=`echo $$flav | sed 's/.*\/firmware-$(arch)-//'`; \
239 [ -d
$(builddir
)/firmware
/$(arch
)-$$name ] || \
240 cp
-a
$(builddir
)/firmware
/$(arch
) \
241 firmware
/$(arch
)-$$name; \
242 cp
$$flav/* $(builddir
)/firmware
/$(arch
)-$$name/; \
246 # Remove unwanted stuff for each flavour
247 flavour_exclude
=`ls $(DEBIAN)/d-i/exclude-modules.$(arch)-* 2>/dev/null`\
249 if
[ "$$flavour_exclude" ]; then \
250 for flav in
$$flavour_exclude; do \
251 name
=`echo $$flav | sed 's/.*\/exclude-modules.$(arch)-//'`;\
252 [ -d
$(builddir
)/modules
/$(arch
)-$$name ] || \
253 cp
-a
$(builddir
)/modules
/$(arch
) \
254 $(builddir
)/modules
/$(arch
)-$$name; \
256 ls
$(builddir
)/modules
/$(arch
)-$$name) | \
258 (cd
$(builddir
)/modules
/$(arch
)-$$name/; \
262 flavour_exclude
=`ls $(DEBIAN)/d-i/exclude-firmware.$(arch)-* 2>/dev/null`\
264 if
[ "$$flavour_exclude" ]; then \
265 for flav in
$$flavour_exclude; do \
266 name
=`echo $$flav | sed 's/.*\/exclude-firmware.$(arch)-//'`;\
267 [ -d
$(builddir
)/firmware
/$(arch
)-$$name ] || \
268 cp
-a
$(builddir
)/firmware
/$(arch
) \
269 $(builddir
)/firmware
/$(arch
)-$$name; \
271 ls
$(builddir
)/firmware
/$(arch
)-$$name) | \
273 (cd
$(builddir
)/firmware
/$(arch
)-$$name/; \
278 if
[ ! -d
$(builddir
)/modules
/$(build_arch
) ]; then \
279 mkdir
-p
$(builddir
)/modules
/$(build_arch
); \
280 cp
$(builddir
)/modules
/$(arch
)/* \
281 $(builddir
)/modules
/$(build_arch
); \
283 if
[ ! -d
$(builddir
)/firmware
/$(build_arch
) ]; then \
284 mkdir
-p
$(builddir
)/firmware
/$(build_arch
); \
285 cp
$(builddir
)/firmware
/$(arch
)/* \
286 $(builddir
)/firmware
/$(build_arch
); \
289 echo
"# placebo control.stub for kernel-wedge flow change" >debian
/control.stub
290 cp
$(DEBIAN
)/control.stub debian
/control
291 cd
$(builddir
) && LANG
=C kernel-wedge gen-control
>> $(CURDIR
)/debian
/control