diff --git a/Makefile b/Makefile index 1f8194b..15f352c 100644 --- a/Makefile +++ b/Makefile @@ -12,11 +12,51 @@ ARCH := x86_64 include $(PWD)/config.env include $(PWD)/make/keys.mk include $(PWD)/make/fetch.mk -include $(PWD)/make/extract.mk include $(PWD)/make/toolchain.mk .DEFAULT_GOAL := default -default: $(OUT_DIR)/bzImage +.PHONY: default +default: fetch $(OUT_DIR)/bzImage + +# Clean repo back to initial clone state +.PHONY: clean +clean: + rm -rf cache out + docker image rm -f local/$(NAME)-build + +# Source anything required from the internet to build +.PHONY: fetch +fetch: \ + toolchain \ + keys \ + $(OUT_DIR) \ + $(CACHE_DIR) \ + $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz \ + $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.sign \ + $(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2 \ + $(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2.sig + +# Build latest image and run in terminal via Qemu +.PHONY: run +run: default + qemu-system-x86_64 \ + -m 512M \ + -nographic \ + -initrd $(OUT_DIR)/rootfs.cpio \ + -kernel $(OUT_DIR)/bzImage + +# Run ncurses busybox config menu and save output +.PHONY: busybox-config +busybox-config: + rm $(CONFIG_DIR)/busybox.config + make $(CONFIG_DIR)/busybox.config + +# Run linux config menu and save output +.PHONY: linux-config +linux-config: + rm $(CONFIG_DIR)/linux.config + make $(CONFIG_DIR)/linux.config + $(CONFIG_DIR)/busybox.config: $(toolchain) " \ @@ -58,8 +98,10 @@ endif # | LANG=C bsdtar --null -cf - --format=newc @- \ # " > $@ - -$(OUT_DIR)/busybox: extract +$(OUT_DIR)/busybox: \ + $(CACHE_DIR)/busybox-$(BUSYBOX_VERSION) \ + $(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2 \ + $(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2.sig $(toolchain) " \ cd /cache/busybox-$(BUSYBOX_VERSION) && \ cp /config/busybox.config .config && \ @@ -67,7 +109,11 @@ $(OUT_DIR)/busybox: extract cp busybox /out/; \ " -$(OUT_DIR)/bzImage: extract $(OUT_DIR)/rootfs.cpio +$(OUT_DIR)/bzImage: \ + $(OUT_DIR)/rootfs.cpio \ + $(CACHE_DIR)/linux-$(LINUX_VERSION) \ + $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz \ + $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.sign $(toolchain) " \ cd /cache/linux-$(LINUX_VERSION) && \ cp /config/linux.config .config && \ @@ -76,10 +122,3 @@ $(OUT_DIR)/bzImage: extract $(OUT_DIR)/rootfs.cpio cp arch/x86_64/boot/bzImage /out/; \ " -.PHONY: run -run: - qemu-system-x86_64 \ - -m 512M \ - -nographic \ - -initrd $(OUT_DIR)/rootfs.cpio \ - -kernel $(OUT_DIR)/bzImage diff --git a/make/extract.mk b/make/extract.mk deleted file mode 100644 index e80fae0..0000000 --- a/make/extract.mk +++ /dev/null @@ -1,25 +0,0 @@ -.PHONY: extract -extract: \ - fetch \ - $(CACHE_DIR)/linux-$(LINUX_VERSION).tar \ - $(CACHE_DIR)/linux-$(LINUX_VERSION)/README \ - $(CACHE_DIR)/busybox-$(BUSYBOX_VERSION)/README - -$(CACHE_DIR)/linux-$(LINUX_VERSION).tar: - xz -d $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz - -$(CACHE_DIR)/linux-$(LINUX_VERSION)/README: - $(toolchain) " \ - cd /cache && \ - gpg --import /keys/$(LINUX_KEY).asc && \ - gpg --verify linux-$(LINUX_VERSION).tar.sign && \ - tar xf linux-$(LINUX_VERSION).tar; \ - " - -$(CACHE_DIR)/busybox-$(BUSYBOX_VERSION)/README: - $(toolchain) " \ - cd /cache && \ - gpg --import /keys/$(BUSYBOX_KEY).asc && \ - gpg --verify busybox-$(BUSYBOX_VERSION).tar.bz2.sig && \ - tar -xf busybox-$(BUSYBOX_VERSION).tar.bz2 \ - " diff --git a/make/fetch.mk b/make/fetch.mk index 6f6236a..245d716 100644 --- a/make/fetch.mk +++ b/make/fetch.mk @@ -1,14 +1,3 @@ -.PHONY: fetch -fetch: \ - toolchain \ - keys \ - $(OUT_DIR) \ - $(CACHE_DIR) \ - $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz \ - $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.sign \ - $(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2 \ - $(CACHE_DIR)/busybox-$(BUSYBOX_VERSION).tar.bz2.sig - $(OUT_DIR): mkdir -p $(OUT_DIR) @@ -34,3 +23,22 @@ $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz: curl \ --url $(LINUX_SERVER)/linux-$(LINUX_VERSION).tar.xz \ --output $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz + +$(CACHE_DIR)/linux-$(LINUX_VERSION).tar: + xz -d $(CACHE_DIR)/linux-$(LINUX_VERSION).tar.xz + +$(CACHE_DIR)/linux-$(LINUX_VERSION): $(CACHE_DIR)/linux-$(LINUX_VERSION).tar + $(toolchain) " \ + cd /cache && \ + gpg --import /keys/$(LINUX_KEY).asc && \ + gpg --verify linux-$(LINUX_VERSION).tar.sign && \ + tar xf linux-$(LINUX_VERSION).tar; \ + " + +$(CACHE_DIR)/busybox-$(BUSYBOX_VERSION): + $(toolchain) " \ + cd /cache && \ + gpg --import /keys/$(BUSYBOX_KEY).asc && \ + gpg --verify busybox-$(BUSYBOX_VERSION).tar.bz2.sig && \ + tar -xf busybox-$(BUSYBOX_VERSION).tar.bz2 \ + "