Support external build directory
When running inside a QEMU microvm with the source directory shared via 9pfs, the kernel build process fails > Error: Could not mmap file: vmlinux Thus, we need to run the build in a path on a local filesystem. To support this, the Makefile now supports an `O` option, and all the build scripts have been adjusted to make use of it as needed. Since building in a local filesystem would ultimately discard the final artifacts when the VM terminates, we need yet a different location for the files we want to keep. The `IMAGESDIR` option can be used to specify this path. This path can be on a shared filesystem, thus saving the artifacts outside the microvm.
This commit is contained in:
94
Makefile
94
Makefile
@@ -1,6 +1,9 @@
|
||||
update.tar: output/update.tar.zstd
|
||||
O ?= .
|
||||
IMAGESDIR ?= $(O)/images
|
||||
|
||||
.prepared: \
|
||||
update.tar: $(IMAGESDIR)/update.tar.zstd
|
||||
|
||||
$(O)/.prepared: \
|
||||
prepare.sh \
|
||||
config-portage.sh \
|
||||
setup-local-repo.sh \
|
||||
@@ -9,86 +12,87 @@ update.tar: output/update.tar.zstd
|
||||
./prepare.sh
|
||||
./config-portage.sh
|
||||
./setup-local-repo.sh
|
||||
touch .prepared
|
||||
mkdir -p $(O)
|
||||
touch $(O)/.prepared
|
||||
|
||||
prepare: .prepared
|
||||
prepare: $(O)/.prepared
|
||||
|
||||
.host-tools: \
|
||||
$(O)/.host-tools: \
|
||||
build-host-tools.sh \
|
||||
.prepared
|
||||
$(O)/.prepared
|
||||
./build-host-tools.sh
|
||||
touch .host-tools
|
||||
touch $(O)/.host-tools
|
||||
|
||||
host-tools: .host-tools
|
||||
host-tools: $(O)/.host-tools
|
||||
|
||||
.built: \
|
||||
$(O)/.built: \
|
||||
build.sh \
|
||||
build-rootfs.sh \
|
||||
linux/arch/arm64/boot/Image.gz \
|
||||
.host-tools \
|
||||
.prepared
|
||||
$(O)/linux/arch/arm64/boot/Image.gz \
|
||||
$(O)/.host-tools \
|
||||
$(O)/.prepared
|
||||
./build.sh
|
||||
./build-rootfs.sh
|
||||
touch .built
|
||||
touch $(O)/.built
|
||||
|
||||
images/rootfs.squashfs: \
|
||||
$(IMAGESDIR)/rootfs.squashfs: \
|
||||
build-squashfs.sh \
|
||||
squashfs.exclude \
|
||||
.built
|
||||
./build-squashfs.sh
|
||||
$(O)/.built
|
||||
./build-squashfs.sh "$(IMAGESDIR)"
|
||||
|
||||
squashfs: images/rootfs.squashfs
|
||||
squashfs: $(IMAGESDIR)/rootfs.squashfs
|
||||
|
||||
linux/arch/arm64/boot/Image.gz: \
|
||||
$(O)/linux/arch/arm64/boot/Image.gz: \
|
||||
build-kernel.sh \
|
||||
linux.config \
|
||||
.host-tools \
|
||||
.prepared
|
||||
./build-kernel.sh
|
||||
$(O)/.host-tools \
|
||||
$(O)/.prepared
|
||||
./build-kernel.sh "$(O)"
|
||||
|
||||
kernel: linux/arch/arm64/boot/Image.gz
|
||||
kernel: $(O)/linux/arch/arm64/boot/Image.gz
|
||||
|
||||
output/efi-part/EFI/BOOT/BOOTAA64.efi: \
|
||||
$(O)/efi-part/EFI/BOOT/BOOTAA64.efi: \
|
||||
build-grub.sh \
|
||||
grub.cfg \
|
||||
.host-tools \
|
||||
.prepared
|
||||
./build-grub.sh
|
||||
$(O)/.host-tools \
|
||||
$(O)/.prepared
|
||||
./build-grub.sh "$(O)"
|
||||
|
||||
grub: output/efi-part/EFI/BOOT/BOOTAA64.efi
|
||||
grub: $(O)/efi-part/EFI/BOOT/BOOTAA64.efi
|
||||
|
||||
output/efi-part/u-boot.bin: \
|
||||
$(O)/efi-part/u-boot.bin: \
|
||||
build-uboot.sh \
|
||||
u-boot.config
|
||||
./build-uboot.sh
|
||||
./build-uboot.sh "$(O)"
|
||||
|
||||
uboot: output/efi-part/u-boot.bin
|
||||
uboot: $(O)/efi-part/u-boot.bin
|
||||
|
||||
images/sdcard.img: \
|
||||
$(IMAGESDIR)/sdcard.img: \
|
||||
genimage.cfg \
|
||||
genimage.sh \
|
||||
post-build.sh \
|
||||
output/efi-part/u-boot.bin \
|
||||
output/efi-part/EFI/BOOT/BOOTAA64.efi
|
||||
./post-build.sh
|
||||
./genimage.sh
|
||||
$(O)/efi-part/u-boot.bin \
|
||||
$(O)/efi-part/EFI/BOOT/BOOTAA64.efi
|
||||
./post-build.sh "$(O)"
|
||||
./genimage.sh "$(O)" "$(IMAGESDIR)"
|
||||
|
||||
sdcard.img: images/sdcard.img
|
||||
sdcard.img: $(IMAGESDIR)/sdcard.img
|
||||
|
||||
images/firmware.img: images/sdcard.img
|
||||
$(IMAGESDIR)/firmware.img: $(IMAGESDIR)/sdcard.img
|
||||
|
||||
output/update.tar.zstd: \
|
||||
images/rootfs.squashfs \
|
||||
images/firmware.img \
|
||||
$(IMAGESDIR)/update.tar.zstd: \
|
||||
$(IMAGESDIR)/rootfs.squashfs \
|
||||
$(IMAGESDIR)/firmware.img \
|
||||
install-update.sh \
|
||||
.host-tools \
|
||||
.prepared
|
||||
./build-update.sh
|
||||
$(O)/.host-tools \
|
||||
$(O)/.prepared
|
||||
./build-update.sh "$(IMAGESDIR)"
|
||||
|
||||
clean:
|
||||
git -C u-boot clean -fdx && git -C u-boot checkout -- .
|
||||
rm -rf linux output images tmp
|
||||
rm -f .prepared .host-tools
|
||||
rm -rf $(O)/linux $(O)/output $(IMAGESDIR) $(O)/tmp
|
||||
rm -f $(O)/.prepared $(O)/.host-tools
|
||||
|
||||
.PHONY: \
|
||||
grub \
|
||||
|
||||
Reference in New Issue
Block a user