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
)))
40 # Don't build tools or udebs in a cross compile environment.
41 ifneq ($(DEB_HOST_ARCH
),$(DEB_BUILD_ARCH
))
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 ifeq ($(DEB_BUILD_PROFILE
),autopkgtest
)
83 flavours
:= $(firstword $(flavours
))
86 # Debian Build System targets
87 binary
: binary-indep binary-arch
89 build
: build-arch build-indep
91 # If we are building zfs update the provides.
94 rprovides
:=$(rprovides
), spl-dkms
, zfs-dkms
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 # If we have a reconstruct script use it.
121 [ -f
$(DEBIAN
)/reconstruct
] && bash
$(DEBIAN
)/reconstruct
123 # Remove generated intermediate files
124 rm -f
$(DROOT
)/control.stub
$(DEBIAN
)/control.stub \
125 $(DEBIAN
)/d-i
/kernel-versions
128 rm -rf
$(DROOT
)/control debian
/changelog \
129 debian
/control debian
/control.stub debian
/copyright
131 # Builds the image, arch headers and debug packages
132 include $(DROOT
)/rules.d
/2-binary-arch.mk
134 # Rules for building the udebs ($(DEBIAN)-installer)
135 include $(DROOT
)/rules.d
/5-udebs.mk
137 # Builds the source, doc and linux-headers indep packages
138 include $(DROOT
)/rules.d
/3-binary-indep.mk
140 # Various checks to be performed on builds
141 include $(DROOT
)/rules.d
/4-checks.mk
144 .PHONY
: $(DEBIAN
)/control.stub
145 $(DEBIAN
)/control.stub
: $(DEBIAN
)/d-i
/kernel-versions.in \
146 $(DROOT
)/scripts
/control-create \
147 $(DEBIAN
)/control.stub.in \
148 $(DEBIAN
)/changelog \
149 $(wildcard $(DEBIAN
)/control.d
/* $(DEBIAN
)/sub-flavours
/*.vars
)
150 for i in
$(DEBIAN
)/d-i
/kernel-versions.in
$(DEBIAN
)/control.stub.in
; do \
151 new
=`echo $$i | sed 's/\.in$$//'`; \
152 cat
$$i | sed
-e
's/PKGVER/$(release)/g' \
153 -e
's/ABINUM/$(abinum)/g' \
154 -e
's/SRCPKGNAME/$(src_pkg_name)/g' \
155 -e
's/=HUMAN=/$(human_arch)/g' \
156 -e
's/=RPROVIDES=/$(rprovides)/g' \
159 flavours
="$(sort $(wildcard $(DEBIAN)/control.d/vars.* $(DEBIAN)/sub-flavours/*.vars))";\
160 for i in
$$flavours; do \
161 $(SHELL
) $(DROOT
)/scripts
/control-create
$$i | \
162 sed
-e
's/PKGVER/$(release)/g' \
163 -e
's/ABINUM/$(abinum)/g' \
164 -e
's/SRCPKGNAME/$(src_pkg_name)/g' \
165 -e
's/=HUMAN=/$(human_arch)/g' \
166 -e
's/=RPROVIDES=/$(rprovides)/g' \
167 >> $(DEBIAN
)/control.stub
; \
170 .PHONY
: debian
/control
171 debian
/control
: $(DEBIAN
)/control.stub
172 rm -rf
$(builddir
)/modules
$(builddir
)/firmware \
173 $(builddir
)/kernel-versions
$(builddir
)/package-list \
174 $(builddir
)/$(DEBIAN
)
175 mkdir
-p
$(builddir
)/modules
/$(arch
)/
176 cp
$(DEBIAN
)/d-i
/modules
/* $(builddir
)/modules
/$(arch
)/
177 mkdir
-p
$(builddir
)/firmware
/$(arch
)/
178 cp
$(DEBIAN
)/d-i
/firmware
/* $(builddir
)/firmware
/$(arch
)/
179 cp
$(DEBIAN
)/d-i
/package-list
$(DEBIAN
)/d-i
/kernel-versions
$(builddir
)/
180 touch
$(builddir
)/modules
/$(arch
)/kernel-image
181 # kernel-wedge needs to poke around in $(DEBIAN)/
182 ln
-nsf
$(CURDIR
)/debian
$(builddir
)/debian
184 # Some files may need to differ between architectures
185 if
[ -d
$(DEBIAN
)/d-i
/modules-
$(arch
) ]; then \
186 cp
$(DEBIAN
)/d-i
/modules-
$(arch
)/* \
187 $(builddir
)/modules
/$(arch
)/; \
189 if
[ -d
$(DEBIAN
)/d-i
/firmware-
$(arch
) ]; then \
190 cp
$(DEBIAN
)/d-i
/firmware-
$(arch
)/* \
191 $(builddir
)/firmware
/$(arch
)/; \
194 # Remove unwanted stuff for this architecture
195 if
[ -r
"$(DEBIAN)/d-i/exclude-modules.$(arch)" ]; then \
196 (cat
$(DEBIAN
)/d-i
/exclude-modules.
$(arch
); \
197 ls
$(builddir
)/modules
/$(arch
)/) |
sort | uniq
-d | \
198 (cd
$(builddir
)/modules
/$(arch
)/; xargs
rm -f
); \
200 if
[ -r
"$(DEBIAN)/d-i/exclude-firmware.$(arch)" ]; then \
201 (cat
$(DEBIAN
)/d-i
/exclude-firmware.
$(arch
); \
202 ls
$(builddir
)/firmware
/$(arch
)/) |
sort | uniq
-d | \
203 (cd
$(builddir
)/firmware
/$(arch
)/; xargs
rm -f
); \
206 # Per flavour module lists
207 flavour_modules
=`ls $(DEBIAN)/d-i/modules.$(arch)-* 2>/dev/null` \
209 if
[ "$$flavour_modules" != "" ]; then \
210 for flav in
$$flavour_modules; do \
211 name
=`echo $$flav | sed 's/.*\/modules.$(arch)-//'`; \
212 mkdir
$(builddir
)/modules
/$(arch
)-$$name; \
213 (cd
$(builddir
)/modules
/; tar cf
- `cat ../$$flav`) | \
214 (cd
$(builddir
)/modules
/$(arch
)-$$name/; tar xf
-); \
215 touch
$(builddir
)/modules
/$(arch
)-$$name/kernel-image
; \
218 flavour_firmware
=`ls $(DEBIAN)/d-i/firmware.$(arch)-* 2>/dev/null` \
220 if
[ "$$flavour_firmware" != "" ]; then \
221 for flav in
$$flavour_firmware; do \
222 name
=`echo $$flav | sed 's/.*\/firmware.$(arch)-//'`; \
223 mkdir
$(builddir
)/firmware
/$(arch
)-$$name; \
224 (cd
$(builddir
)/firmware
/; tar cf
- `cat ../$$flav`) | \
225 (cd
$(builddir
)/firmware
/$(arch
)-$$name/; tar xf
-);\
226 touch
$(builddir
)/firmware
/$(arch
)-$$name/kernel-image
; \
230 # Some files may need to differ between flavours
231 flavour_module_dirs
=`ls -d $(DEBIAN)/d-i/modules-$(arch)-* 2>/dev/null`\
233 if
[ "$$flavour_module_dirs" ]; then \
234 for flav in
$$flavour_module_dirs; do \
235 name
=`echo $$flav | sed 's/.*\/modules-$(arch)-//'`; \
236 [ -d
$(builddir
)/modules
/$(arch
)-$$name ] || \
237 cp
-a
$(builddir
)/modules
/$(arch
) \
238 modules
/$(arch
)-$$name; \
239 cp
$$flav/* $(builddir
)/modules
/$(arch
)-$$name/; \
242 flavour_firmware_dirs
=`ls -d $(DEBIAN)/d-i/firmware-$(arch)-* 2>/dev/null`\
244 if
[ "$$flavour_firmware_dirs" ]; then \
245 for flav in
$$flavour_firmware_dirs; do \
246 name
=`echo $$flav | sed 's/.*\/firmware-$(arch)-//'`; \
247 [ -d
$(builddir
)/firmware
/$(arch
)-$$name ] || \
248 cp
-a
$(builddir
)/firmware
/$(arch
) \
249 firmware
/$(arch
)-$$name; \
250 cp
$$flav/* $(builddir
)/firmware
/$(arch
)-$$name/; \
254 # Remove unwanted stuff for each flavour
255 flavour_exclude
=`ls $(DEBIAN)/d-i/exclude-modules.$(arch)-* 2>/dev/null`\
257 if
[ "$$flavour_exclude" ]; then \
258 for flav in
$$flavour_exclude; do \
259 name
=`echo $$flav | sed 's/.*\/exclude-modules.$(arch)-//'`;\
260 [ -d
$(builddir
)/modules
/$(arch
)-$$name ] || \
261 cp
-a
$(builddir
)/modules
/$(arch
) \
262 $(builddir
)/modules
/$(arch
)-$$name; \
264 ls
$(builddir
)/modules
/$(arch
)-$$name) | \
266 (cd
$(builddir
)/modules
/$(arch
)-$$name/; \
270 flavour_exclude
=`ls $(DEBIAN)/d-i/exclude-firmware.$(arch)-* 2>/dev/null`\
272 if
[ "$$flavour_exclude" ]; then \
273 for flav in
$$flavour_exclude; do \
274 name
=`echo $$flav | sed 's/.*\/exclude-firmware.$(arch)-//'`;\
275 [ -d
$(builddir
)/firmware
/$(arch
)-$$name ] || \
276 cp
-a
$(builddir
)/firmware
/$(arch
) \
277 $(builddir
)/firmware
/$(arch
)-$$name; \
279 ls
$(builddir
)/firmware
/$(arch
)-$$name) | \
281 (cd
$(builddir
)/firmware
/$(arch
)-$$name/; \
286 if
[ ! -d
$(builddir
)/modules
/$(build_arch
) ]; then \
287 mkdir
-p
$(builddir
)/modules
/$(build_arch
); \
288 cp
$(builddir
)/modules
/$(arch
)/* \
289 $(builddir
)/modules
/$(build_arch
); \
291 if
[ ! -d
$(builddir
)/firmware
/$(build_arch
) ]; then \
292 mkdir
-p
$(builddir
)/firmware
/$(build_arch
); \
293 cp
$(builddir
)/firmware
/$(arch
)/* \
294 $(builddir
)/firmware
/$(build_arch
); \
297 echo
"# placebo control.stub for kernel-wedge flow change" >debian
/control.stub
298 cp
$(DEBIAN
)/control.stub debian
/control
299 cd
$(builddir
) && LANG
=C kernel-wedge gen-control
>> $(CURDIR
)/debian
/control