summaryrefslogtreecommitdiffstats
path: root/debian/rules
diff options
context:
space:
mode:
Diffstat (limited to 'debian/rules')
-rwxr-xr-xdebian/rules65
1 files changed, 65 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..10bafab
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,65 @@
+#!/usr/bin/make -f
+
+include /usr/share/dpkg/architecture.mk
+include /usr/share/dpkg/buildtools.mk
+
+export DH_VERBOSE=1
+export TF_CFLAGS += -ffile-prefix-map=$(CURDIR)=.
+export DEB_BUILD_MAINT_OPTIONS=hardening=+all
+
+# Enable verbose build by default, disable when terse is specified.
+ifneq (,$(filter terse,$(DEB_BUILD_OPTIONS)))
+VERBOSE=0
+else
+VERBOSE=1
+endif
+
+platforms := g12a gxbb sun50i_h6 rk3328 rk3399 rpi3 rpi4 imx8mn
+platforms_nodebug := sun50i_a64 imx8mq
+
+# By default, iMX8MN uses UART2 console. However, other boards supported
+# upstream (e.g. Variscite VAR-SOM-MX8M-NANO board) uses UART4.
+# Add two subplatforms for imx8mn platform:
+# * imx8mn: default configuration
+# * imx8mn_uart4: console set to UART4
+imx8mn_subplatforms := imx8mn imx8mn_uart4
+imx8mn_uart4_assigns := IMX_BOOT_UART_BASE=0x30a60000
+
+# Always set CROSS_COMPILE, which also works for native builds.
+define build_platform
+ $(eval platform := $(1))
+ $(eval debug := $(2))
+ $(eval buildtype := $(3))
+ $(eval subplatforms := $(if $($(platform)_subplatforms), $($(platform)_subplatforms), $(platform)))
+ $(eval target := $(if $(filter rk3328 rk3399,$(platform)),bl31/bl31.elf,bl31.bin))
+ $(foreach subplatform, $(subplatforms), \
+ CROSS_COMPILE=aarch64-linux-gnu- CFLAGS=--param=min-pagesize=0 LDFLAGS= TF_LDFLAGS=--no-warn-rwx-segments dh_auto_build -- V=$(VERBOSE) DEBUG=$(debug) $($(subplatform)_assigns) PLAT=$(platform) bl31 ; \
+ install -m644 build/$(platform)/$(buildtype)/$(target) -Dt build/renamed/$(subplatform) ; \
+ # For each subplatform, make is called using the same PLAT variable. If
+ # the build is not cleaned between each call, objects will remain the
+ # same, without rebuilding them.
+ make DEBUG=$(debug) PLAT=$(platform) clean ; \
+ )
+endef
+
+%:
+ dh $@
+
+override_dh_auto_build:
+# Disable building of arm-trusted-firmware-tools
+ifeq ($(filter pkg.arm-trusted-firmware.notools,$(DEB_BUILD_PROFILES)),)
+ dh_auto_build --sourcedir=tools/fiptool -- DEBUG=1 V=$(VERBOSE) HOSTCC=$(CC) HOSTCCFLAGS="$(CFLAGS) $(CPPFLAGS)"
+ dh_auto_build --sourcedir=tools/cert_create -- DEBUG=1 V=$(VERBOSE) HOSTCC=$(CC) HOSTCCFLAGS="$(CFLAGS) $(CPPFLAGS) -std=c99 -DUSE_TBBR_DEFS=1"
+endif
+# Only build firmware on arm64.
+ifeq ($(DEB_HOST_ARCH),arm64)
+ override_dh_auto_build: $(platforms) $(platforms_nodebug)
+ $(platforms):
+ $(call build_platform,$@,1,debug)
+ $(platforms_nodebug):
+ $(call build_platform,$@,0,release)
+endif
+
+override_dh_installchangelogs:
+ dh_installchangelogs -parm-trusted-firmware docs/change-log.md
+ dh_installchangelogs -parm-trusted-firmware-tools