From 65ba015d6c1f248d36ad01a653bc49637804b15b Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Sun, 10 Aug 2025 15:46:33 -0400 Subject: working usermode objdir iteration --- Makefile | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b63fa27 --- /dev/null +++ b/Makefile @@ -0,0 +1,70 @@ +include config.mk + +KERNEL_BIN := $(KERNELDIR)/jove.elf +INITRD_TAR := $(SYSROOTDIR)/boot/initrd.tar + +TEST_HDD := $(PWD)/test.hdd +TEST_HDD_SIZEM = 64 +TEST_HDD_DIR := $(PWD)/test_hdd + +all: $(KERNEL_BIN) + +.PHONY: clean +clean: + $(MAKE) -C $(KERNELDIR) clean CONFIG=$(PWD)/config.mk + -rm $(STATICLIBS) + -rm $(APPS) + $(foreach dir, $(filter %/, $(wildcard $(APPSDIR)/*/)), $(MAKE) -C $(dir) clean CONFIG=$(PWD)/config.mk) + $(foreach dir, $(filter %/, $(wildcard $(LIBDIR)/*/)), $(MAKE) -C $(dir) clean CONFIG=$(PWD)/config.mk) + +.PHONY: $(KERNEL_BIN) +$(KERNEL_BIN): + $(MAKE) -C $(KERNELDIR) CONFIG=$(PWD)/config.mk + +.PHONY: $(INITRD_TAR) +$(INITRD_TAR): $(APPS) + $(MAKE) -C $(INITRDDIR) CONFIG=$(PWD)/config.mk OUT=$(INITRD_TAR) + +$(INITRDDIR)/files/bin/% : $(STATICLIBS) FORCE + $(MAKE) -C $(APPSDIR)/$(subst $(INITRDDIR)/files/bin/,,$@) CONFIG=$(PWD)/config.mk OUT=$(INITRDDIR)/files/bin + +$(SYSROOTDIR)/lib/%.a : $(SYSROOTDIR) FORCE + $(MAKE) -C $(LIBDIR)/$(subst $(SYSROOTDIR)/lib/,,$(subst .a,,$@)) CONFIG=$(PWD)/config.mk OUT=$(SYSROOTDIR)/lib + +.PHONY: $(SYSROOTDIR)/usr/include +$(SYSROOTDIR)/usr/include: + rm -rf $(SYSROOTDIR)/usr/include + cp -r $(LIBDIR)/libc-headless/include $(SYSROOTDIR)/usr/include + cp -r $(KERNELDIR)/include/ $(SYSROOTDIR)/usr/include/kernel + cp -r $(LIBDIR)/libjove/include $(SYSROOTDIR)/usr/include/jove + +$(SYSROOTDIR): $(SYSROOTDIR)/usr/include + +.PHONY: test +.ONESHELL: +test: $(TEST_HDD) $(KERNEL_BIN) $(INITRD_TAR) $(SYSROOTDIR) + sudo rm -rf $(TEST_HDD_DIR) + mkdir -p $(TEST_HDD_DIR) + export LOOPBACK_DEV=$(shell sudo losetup -Pf --show $(TEST_HDD)) + sudo partprobe $$LOOPBACK_DEV + sudo mkfs.fat -F 32 "$$LOOPBACK_DEV"p1 + sudo mount "$$LOOPBACK_DEV"p1 $(TEST_HDD_DIR) + sudo cp -r $(SYSROOTDIR)/* $(TEST_HDD_DIR) + sudo cp $(KERNEL_BIN) $(TEST_HDD_DIR)/boot + sudo cp limine/limine.exe $(TEST_HDD_DIR)/boot + sudo mkdir -p $(TEST_HDD_DIR)/EFI/BOOT + sudo cp limine/BOOTX64.EFI $(TEST_HDD_DIR)/EFI/BOOT + sync + sudo umount $(TEST_HDD_DIR) + sudo losetup -d $$LOOPBACK_DEV + sudo rm -rf $(TEST_HDD_DIR) + qemu-system-x86_64 -m 512M -M q35 -bios ovmf-x64/OVMF.fd -net none -smp 4 -hda test.hdd -serial stdio -no-shutdown -no-reboot -s -d int -d guest_errors + +.PHONY: $(TEST_HDD) +$(TEST_HDD): + rm -f $(TEST_HDD) + dd if=/dev/zero bs=1M count=0 seek=$(TEST_HDD_SIZEM) of=$(TEST_HDD) + parted -s $(TEST_HDD) mklabel gpt + parted -s $(TEST_HDD) mkpart primary 2048s 100% + +FORCE: ; -- cgit v1.2.1