Using our own mono-ask.mk
This commit is contained in:
@@ -51,43 +51,26 @@ RUN mkdir -p ASK/sources/tarballs && \
|
||||
|
||||
RUN mkdir linux && tar zxf "kernel.tar.gz" -C "linux" --strip-components=1
|
||||
|
||||
# Extract fmc & fmlib to prevent git fetching
|
||||
RUN mkdir -p ASK/sources/fmc && \
|
||||
mkdir -p ASK/sources/fmlib && \
|
||||
tar zxf "fmc.tar.gz" -C "ASK/sources/fmc" --strip-components=1 && \
|
||||
tar zxf "fmlib.tar.gz" -C "ASK/sources/fmlib" --strip-components=1
|
||||
|
||||
WORKDIR /src/ASK
|
||||
|
||||
# Extract fmc & fmlib to prevent git fetching
|
||||
RUN mkdir -p sources/fmc && \
|
||||
mkdir -p sources/fmlib && \
|
||||
tar zxf "/src/fmc.tar.gz" -C "sources/fmc" --strip-components=1 && \
|
||||
tar zxf "/src/fmlib.tar.gz" -C "sources/fmlib" --strip-components=1
|
||||
|
||||
# 1. Apply the NXP ASK kernel patch to your Linux source tree FIRST
|
||||
RUN cd /src/linux && \
|
||||
patch -p1 < /src/ASK/patches/kernel/002-mono-gateway-ask-kernel_linux_6_12.patch
|
||||
|
||||
# 2. Merge the NXP defconfig with your Kubernetes extra config
|
||||
# Assuming you copy kernel-extra.config into the container at /src/kernel-extra.config
|
||||
COPY patches/mono-ask.mk .
|
||||
COPY kernel-extra.config /src/kernel-extra.config
|
||||
COPY kernel-build/ensure-kconfig.sh /src/ensure-kconfig.sh
|
||||
|
||||
RUN cd /src/linux && \
|
||||
cp /src/ASK/config/kernel/defconfig .config && \
|
||||
./scripts/kconfig/merge_config.sh -m .config /src/kernel-extra.config && \
|
||||
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- olddefconfig
|
||||
# 1. This step patches the kernel, merges your k8s config, and builds the modules
|
||||
RUN make -f mono-ask.mk modules
|
||||
|
||||
# 3. Build the Kernel natively in the linux tree (Do NOT run 'make kernel' in the ASK folder)
|
||||
RUN cd /src/linux && \
|
||||
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc) Image modules
|
||||
# 2. This step cross-compiles fmlib, fmc, cmm, and dpa_app for Alpine
|
||||
RUN make -f mono-ask.mk userspace
|
||||
|
||||
# 4. Now build the ASK out-of-tree modules
|
||||
RUN make modules KDIR=/src/linux CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64
|
||||
|
||||
# 5. Build Userspace with the musl cross-compiler
|
||||
RUN make sources KDIR=/src/linux CROSS_COMPILE=aarch64-linux-musl- ARCH=arm64 HOST=aarch64-linux-musl
|
||||
RUN make userspace KDIR=/src/linux CROSS_COMPILE=aarch64-linux-musl- ARCH=arm64 \
|
||||
HOST=aarch64-linux-musl \
|
||||
CC="aarch64-linux-musl-gcc -static" \
|
||||
CXX="aarch64-linux-musl-g++ -static"
|
||||
|
||||
# Stage the artifacts
|
||||
RUN make dist
|
||||
# 3. Stage the artifacts
|
||||
RUN make -f mono-ask.mk dist
|
||||
|
||||
# Export stage
|
||||
FROM scratch AS export
|
||||
|
||||
43
patches/mono-ask.mk
Normal file
43
patches/mono-ask.mk
Normal file
@@ -0,0 +1,43 @@
|
||||
# mono-ask.mk
|
||||
# Custom wrapper to build the NXP ASK for the monok8s Alpine/musl ecosystem
|
||||
|
||||
# Define default paths and cross-compilers
|
||||
KDIR?= /src/linux
|
||||
ASK_DIR?= $(CURDIR)
|
||||
ARCH?= arm64
|
||||
GNU_CROSS?= aarch64-linux-gnu-
|
||||
MUSL_HOST?= aarch64-linux-musl
|
||||
|
||||
.PHONY: prepare-kernel build-kernel modules userspace dist
|
||||
|
||||
# 1. Patch the kernel and merge our custom Kubernetes configuration
|
||||
prepare-kernel:
|
||||
@echo "--> Patching the Linux kernel with NXP DPAA extensions..."
|
||||
# The -N flag and | true prevents failure if the patch is already applied
|
||||
cd $(KDIR) && patch -p1 -N < $(ASK_DIR)/patches/kernel/003-mono-gateway-ask-kernel_linux_6_12.patch | true
|
||||
@echo "--> Merging NXP defconfig with Kubernetes extra config..."
|
||||
cp $(ASK_DIR)/config/kernel/defconfig $(KDIR)/.config
|
||||
cd $(KDIR) && ./scripts/kconfig/merge_config.sh -m .config /src/kernel-extra.config
|
||||
$(MAKE) -C $(KDIR) ARCH=$(ARCH) CROSS_COMPILE=$(GNU_CROSS) olddefconfig
|
||||
/src/ensure-kconfig.sh $(KDIR)/.config /src/kernel-extra.config
|
||||
|
||||
# 2. Build the kernel tree (mandatory before out-of-tree modules can be built)
|
||||
build-kernel: prepare-kernel
|
||||
@echo "--> Building the Linux kernel natively..."
|
||||
$(MAKE) -C $(KDIR) ARCH=$(ARCH) CROSS_COMPILE=$(GNU_CROSS) -j$$(nproc) Image modules
|
||||
|
||||
# 3. Build the ASK out-of-tree modules using the vendor Makefile
|
||||
modules: build-kernel
|
||||
@echo "--> Building ASK out-of-tree modules..."
|
||||
$(MAKE) -f Makefile modules KDIR=$(KDIR) CROSS_COMPILE=$(GNU_CROSS) ARCH=$(ARCH)
|
||||
|
||||
# 4. Build the ASK userspace daemons using the musl cross-compiler
|
||||
userspace:
|
||||
@echo "--> Building ASK sources and libraries..."
|
||||
$(MAKE) -f Makefile sources KDIR=$(KDIR) CROSS_COMPILE=$(MUSL_HOST)- ARCH=$(ARCH) HOST=$(MUSL_HOST)
|
||||
@echo "--> Building ASK userspace executables statically..."
|
||||
$(MAKE) -f Makefile userspace KDIR=$(KDIR) CROSS_COMPILE=$(MUSL_HOST)- ARCH=$(ARCH) HOST=$(MUSL_HOST) CC="$(MUSL_HOST)-gcc -static" CXX="$(MUSL_HOST)-g++ -static"
|
||||
|
||||
# 5. Extract artifacts
|
||||
dist:
|
||||
$(MAKE) -f Makefile dist
|
||||
Reference in New Issue
Block a user