1# This makefile generates the docker files for Yocto builds.
2# The containers for the current architecture are the one built using make all.
3# To build containers for a different architecture, you need to call make for
4# the image you want explicitely.
5# The containers are named this way:
6# YOCTOVERSION-TARGET for x86_64 hosts
7# YOCTOVERSION-TARGET-arm64v8 for arm64 hosts
8# For example you can build an arm64 container with the following command:
9# make yocto/scarthgap-qemuarm64-arm64v8
10
11# Yocto versions we are currently using.
12YOCTO_VERSION = scarthgap
13
14# Yocto BSPs we want to build for.
15YOCTO_TARGETS = qemuarm64 qemuarm qemux86-64
16
17# Supported container architectures.
18YOCTO_ARCHS = amd64 arm64v8
19
20# Architecture we want to use in gitlab CI (depends on runners arch).
21CI_ARCH-qemuarm64 = arm64v8
22CI_ARCH-qemuarm = arm64v8
23CI_ARCH-qemux86-64 = amd64
24
25define GEN_DOCKER
26# Make all is generating architecture we use in the CI.
27ifeq ($(CI_ARCH-$(2)),$(3))
28CONTAINERS += yocto/$(1)-$(2)$(4)
29else
30CONTAINERS_EXTRA += yocto/$(1)-$(2)$(4)
31endif
32
33.INTERMEDIATE: yocto/$(1)-$(2)$(4).dockerfile
34
35yocto/$(1)-$(2)$(4).dockerfile: yocto/yocto.dockerfile.in
36	@cat $$< | \
37	    sed -e "s,##YOCTOVERSION##,$(1),g" | \
38	    sed -e "s,##YOCTOTARGET##,$(2),g" | \
39	    sed -e "s,##DOCKERPLAT##,$(3)/,g" > $$@
40
41endef
42
43$(eval $(foreach version,$(YOCTO_VERSION),\
44       $(foreach target,$(YOCTO_TARGETS),\
45       $(foreach arch,$(YOCTO_ARCHS),\
46       $(call GEN_DOCKER,$(version),$(target),$(arch),$(if $(filter amd64,$(arch)),,-$(arch)))))))
47