From b41b176d4db691a5639933db79b3e40f930352c0 Mon Sep 17 00:00:00 2001 From: Seiya Nuta Date: Fri, 12 Nov 2021 19:40:13 +0900 Subject: [PATCH] build: Use Docker image cross compiling for M1 Mac --- Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 82f812ac..cda33eac 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,15 @@ INITRAMFS_PATH := build/$(IMAGE_FILENAME).initramfs export INIT_SCRIPT := $(shell tools/inspect-init-in-docker-image.py $(IMAGE)) endif +# Set the platform name for docker image cross compiling. +ifeq ($(ARCH),x64) +docker_platform = linux/amd64 +endif + +ifeq ($(docker_platform),) +$(error "docker_platform is not set for $(ARCH)!") +endif + topdir := $(PWD) build_mode := $(if $(RELEASE),release,debug) target_json := kernel/arch/$(ARCH)/$(ARCH).json @@ -171,7 +180,7 @@ clean: # build/kerla.initramfs: $(wildcard initramfs/*) $(wildcard initramfs/*/*) Makefile $(PROGRESS) "BUILD" initramfs - cd initramfs && docker buildx build -t kerla-initramfs . + cd initramfs && docker buildx build --platform $(docker_platform) -t kerla-initramfs . $(PROGRESS) "EXPORT" initramfs mkdir -p build $(PYTHON3) tools/docker2initramfs.py $@ kerla-initramfs