diff mbox

[26/27] UBUNTU: build: Add a command that allows overriding vars by flavours

Message ID bb39f330eb9c4f949a50003bbd59bf357aaed356.1339455422.git.bcollins@ubuntu.com
State New
Headers show

Commit Message

Benjamin Collins June 10, 2012, 8:20 p.m. UTC
This is an old command that used to be in here but wasn't used. I need it
back now.

In the next commit I'll be adding the powerpc-e500mc. The build_image,
loader and kernel_file are different than other powerpc targets, so this
will allow me to override it just for this one flavour.

Signed-off-by: Ben Collins <bcollins@ubuntu.com>
---
 debian/rules.d/0-common-vars.mk |    5 +++++
 debian/rules.d/2-binary-arch.mk |   15 +++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/debian/rules.d/0-common-vars.mk b/debian/rules.d/0-common-vars.mk
index 17eed6a..f0cde1a 100644
--- a/debian/rules.d/0-common-vars.mk
+++ b/debian/rules.d/0-common-vars.mk
@@ -230,3 +230,8 @@  endif
 lockme_file = $(CURDIR)/debian/.LOCK
 lockme_cmd = flock -w 60
 lockme = $(lockme_cmd) $(lockme_file)
+
+# Checks if a var is overriden by the custom rules. Called with var and
+# flavour as arguments.
+custom_override = \
+ $(shell if [ -n "$($(1)_$(2))" ]; then echo "$($(1)_$(2))"; else echo "$($(1))"; fi)
diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index a2555ee..37a5c5a 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -34,9 +34,10 @@  build-%: $(stampdir)/stamp-build-%
 
 # Do the actual build, including image and modules
 $(stampdir)/stamp-build-%: target_flavour = $*
+$(stampdir)/stamp-build-%: bimage = $(call custom_override,build_image,$*)
 $(stampdir)/stamp-build-%: $(stampdir)/stamp-prepare-%
 	@echo Debug: $@
-	$(build_cd) $(kmake) $(build_O) $(conc_level) $(build_image) modules
+	$(build_cd) $(kmake) $(build_O) $(conc_level) $(bimage) modules
 	@touch $@
 
 # Install the finished build
@@ -46,6 +47,8 @@  install-%: bindoc = $(pkgdir)/usr/share/doc/$(bin_pkg_name)-$*
 install-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
 install-%: basepkg = $(hdrs_pkg_name)
 install-%: hdrdir = $(CURDIR)/debian/$(basepkg)-$*/usr/src/$(basepkg)-$*
+install-%: kfile = $(call custom_override,kernel_file,$*)
+install-%: bload = $(call custom_override,loader,$*)
 install-%: target_flavour = $*
 install-%: checks-%
 	@echo Debug: $@
@@ -59,11 +62,11 @@  install-%: checks-%
 	# compress_file logic required because not all architectures
 	# generate a zImage automatically out of the box
 ifeq ($(compress_file),)
-	install -m600 -D $(builddir)/build-$*/$(kernel_file) \
+	install -m600 -D $(builddir)/build-$*/$(kfile) \
 		$(pkgdir)/boot/$(install_file)-$(abi_release)-$*
 else
 	install -d $(pkgdir)/boot
-	gzip -c9v $(builddir)/build-$*/$(kernel_file) > \
+	gzip -c9v $(builddir)/build-$*/$(kfile) > \
 		$(pkgdir)/boot/$(install_file)-$(abi_release)-$*
 	chmod 600 $(pkgdir)/boot/$(install_file)-$(abi_release)-$*
 endif
@@ -119,7 +122,7 @@  endif
 	install -d $(pkgdir)/DEBIAN
 	for script in postinst postrm preinst prerm; do				\
 	  sed -e 's/=V/$(abi_release)-$*/g' -e 's/=K/$(install_file)/g'		\
-	      -e 's/=L/$(loader)/g'         -e 's@=B@$(build_arch)@g'		\
+	      -e 's/=L/$(bload)/g'         -e 's@=B@$(build_arch)@g'		\
 	       $(DROOT)/control-scripts/$$script > $(pkgdir)/DEBIAN/$$script;	\
 	  chmod 755 $(pkgdir)/DEBIAN/$$script;					\
 	done
@@ -128,7 +131,7 @@  endif
 		install -d $(pkgdir_ex)/DEBIAN;					\
 		for script in postinst postrm ; do				\
 			sed -e 's/=V/$(abi_release)-$*/g' -e 's/=K/$(install_file)/g'		\
-			    -e 's/=L/$(loader)/g'         -e 's@=B@$(build_arch)@g'		\
+			    -e 's/=L/$(bload)/g'         -e 's@=B@$(build_arch)@g'		\
 			    debian/control-scripts/$$script > $(pkgdir_ex)/DEBIAN/$$script; \
 			chmod 755 $(pkgdir_ex)/DEBIAN/$$script;			\
 		done;								\
@@ -153,7 +156,7 @@  ifneq ($(skipsub),true)
 		for script in postinst postrm preinst prerm; do			\
 			sed -e 's/=V/$(abi_release)-$*/g'			\
 			    -e 's/=K/$(install_file)/g'				\
-			    -e 's/=L/$(loader)/g'				\
+			    -e 's/=L/$(bload)/g'				\
 			    -e 's@=B@$(build_arch)@g'				\
 				$(DROOT)/control-scripts/$$script >		\
 				debian/$(bin_pkg_name)-$$sub/DEBIAN/$$script;\