From 1687e615b47a28d50146ae788694f0578dad6da5 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Mon, 13 Feb 2023 22:50:59 -0600 Subject: [PATCH] Add top-level Makefile Building the OS is now as simple as running `make` on a Gentoo system. Interestingly, when `make` is executed as a (grand)child process of another `make` process, it always prints an `Entering directory ...` message. This breaks the `make kernelversion` command, by adding extraneous text to the output. --- .gitignore | 2 ++ Makefile | 95 +++++++++++++++++++++++++++++++++++++++++++++++++ build-kernel.sh | 4 +-- podman-build.sh | 2 +- 4 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index a7040c0..5b208c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /images /linux /output +/.prepared +/.host-tools diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a3b4351 --- /dev/null +++ b/Makefile @@ -0,0 +1,95 @@ +update.tar: output/update.tar.zstd + +.prepared: \ + prepare.sh \ + config-portage.sh \ + setup-local-repo.sh \ + $(shell find portage host-portage -type f) \ + $(shell find patches/ebuilds -type f) + ./prepare.sh + ./config-portage.sh + ./setup-local-repo.sh + touch .prepared + +prepare: .prepared + +.host-tools: \ + build-host-tools.sh \ + .prepared + ./build-host-tools.sh + touch .host-tools + +host-tools: .host-tools + +images/rootfs.squashfs: \ + build.sh \ + build-rootfs.sh \ + build-squashfs.sh \ + linux/arch/arm64/boot/Image.gz \ + .host-tools \ + .prepared + ./build.sh + ./build-rootfs.sh + ./build-squashfs.sh + +squashfs: images/rootfs.squashfs + +linux/arch/arm64/boot/Image.gz: \ + build-kernel.sh \ + linux.config \ + .host-tools \ + .prepared + ./build-kernel.sh + +kernel: linux/arch/arm64/boot/Image.gz + +output/efi-part/EFI/BOOT/BOOTAA64.efi: \ + build-grub.sh \ + grub.cfg \ + .host-tools \ + .prepared + ./build-grub.sh + +grub: output/efi-part/EFI/BOOT/BOOTAA64.efi + +output/efi-part/u-boot.bin: \ + build-uboot.sh \ + u-boot.config + ./build-uboot.sh + +uboot: output/efi-part/u-boot.bin + +images/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 + +sdcard.img: images/sdcard.img + +images/firmware.img: images/sdcard.img + +output/update.tar.zstd: \ + images/rootfs.squashfs \ + images/firmware.img \ + .host-tools \ + .prepared + ./build-update.sh + +clean: + git -C u-boot clean -fdx && git -C u-boot checkout -- . + rm -rf linux output images tmp + rm -f .prepared .host-tools + +.PHONY: \ + grub \ + host-tools \ + kernel \ + prepare \ + sdcard.img \ + squashfs \ + uboot \ + update.tar diff --git a/build-kernel.sh b/build-kernel.sh index 89535e9..5d22bd1 100755 --- a/build-kernel.sh +++ b/build-kernel.sh @@ -15,11 +15,11 @@ cd linux ../linux.config make -C /usr/src/linux O=${PWD} olddefconfig make -j$(nproc) -kver=$(make kernelversion) +kver=$(make -s kernelversion) make modules_install INSTALL_MOD_PATH=/mnt/gentoo cd - -printf 'Installing Kernel ...\n' +printf 'Installing Kernel %s ...\n' "${kver}" mkdir -p /mnt/gentoo/boot cp -au linux/arch/arm64/boot/Image.gz /mnt/gentoo/boot/vmlinuz-${kver} cp -au linux/.config /mnt/gentoo/boot/config-${kver} diff --git a/podman-build.sh b/podman-build.sh index 5c6f34a..9e493e0 100755 --- a/podman-build.sh +++ b/podman-build.sh @@ -22,7 +22,7 @@ cid=$(podman run \ ./patch-uboot.sh -podman exec -it ${cid} ./build-all.sh "${target}" +podman exec -it ${cid} make podman stop ${cid} podman rm ${cid}