blob: a342accebe28cffa993e05646f99c2f8e4f9b3f1 (
plain) (
tree)
|
|
TOOLSDIR := $(PWD)/tools
KERNELDIR := $(PWD)/kernel
SYSROOTDIR := $(PWD)/sysroot
INITRDDIR := $(PWD)/initrd
LIBDIR := $(PWD)/lib
include kernel/config.mk
CC = $(TOOLSDIR)/bin/$(TARGET_TRIPLET)-gcc
LD = $(TOOLSDIR)/bin/$(TARGET_TRIPLET)-ld
AS = $(TOOLSDIR)/bin/$(TARGET_TRIPLET)-as
KERNEL_BIN := $(KERNELDIR)/jove.elf
LIBC := $(SYSROOTDIR)/lib/libc.a
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
.PHONY: $(KERNEL_BIN)
$(KERNEL_BIN):
$(MAKE) -C $(KERNELDIR) CC=$(CC) LD=$(LD) AS=$(AS)
.PHONY: test
.ONESHELL:
test: $(TEST_HDD) $(KERNEL_BIN)
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
.PHONY: $(TEST_HDD)
$(TEST_HDD): $(INITRD_TAR)
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%
.PHONY: $(INITRD_TAR)
$(INITRD_TAR): $(LIBC)
$(MAKE) -C $(INITRDDIR) OUT=$(INITRD_TAR) ABIDIR=$(KERNELDIR)/abi LIBDIR=$(LIBDIR)
.PHONY: $(LIBC)
$(LIBC):
$(MAKE) -C $(LIBDIR)/crt LIBDIR=$(SYSROOTDIR)/lib TARGET_MACHINE=$(TARGET_MACHINE)
$(MAKE) -C $(LIBDIR)/jlibc OUT=$@
|