diff options
| author | czjstmax <jstmaxlol@disroot.org> | 2026-02-23 23:18:48 +0100 |
|---|---|---|
| committer | czjstmax <jstmaxlol@disroot.org> | 2026-02-23 23:18:48 +0100 |
| commit | 2420e3f52b62580af9cdd661fb441733e437daf9 (patch) | |
| tree | a2854d70e7297e9bff879c5dc358dfb95d263fab /Makefile | |
| parent | 6fc0fd2fd64388e32c4ec1cefa2ad8e1e43fdb5a (diff) | |
lots of changes. restructured repository. switched to limine.
Signed-off-by: czjstmax <jstmaxlol@disroot.org>
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 72 |
1 files changed, 57 insertions, 15 deletions
@@ -1,17 +1,59 @@ -all: - # assemble bootloader - nasm -f bin src/boot.asm -o build/boot.bin - nasm -f elf32 src/boot_s2.asm -o build/boot_s2.o - # compile kernel - gcc -m32 -ffreestanding -nostdlib -c src/krn/mkern.c -o build/mkernel.o - # link - ld -m elf_i386 -T src/linker.ld -nostdlib -o build/s2.elf build/boot_s2.o build/mkernel.o - objcopy -O binary build/s2.elf build/s2.bin - # make .img - cat build/boot.bin build/s2.bin > build/mullos.img - # qemu test - qemu-system-x86_64 -drive format=raw,file=build/mullos.img +CC = gcc +LD = ld -clean: - rm -vf build/* +CFLAGS = -std=gnu11 -ffreestanding -O2 -Wall -Wextra -m64 \ + -nostdlib -nostartfiles -I src/kernel/headers +LDFLAGS = -T linker.ld -nostdlib -static + +SRC_DIR = src/kernel +BUILD_DIR = build +ISO_DIR = $(BUILD_DIR)/iso +BOOT_DIR = $(ISO_DIR)/boot +LIMINE_DIR = /usr/share/limine + +SOURCES = $(wildcard $(SRC_DIR)/*.c) +OBJECTS = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SOURCES)) + +KERNEL = $(BUILD_DIR)/kernel.elf +ISO_IMAGE = $(BUILD_DIR)/mullos.iso + +all: $(KERNEL) + +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR) + $(CC) $(CFLAGS) -c $< -o $@ + +$(KERNEL): $(OBJECTS) + $(LD) $(OBJECTS) $(LDFLAGS) -o $(KERNEL) +iso: $(KERNEL) + rm -vrf $(ISO_DIR) + mkdir -p $(BOOT_DIR) + + cp $(KERNEL) $(BOOT_DIR)/kernel.elf + cp limine.conf $(ISO_DIR)/limine.conf + + # copy limine boot files + cp $(LIMINE_DIR)/limine-bios.sys $(ISO_DIR)/ + cp $(LIMINE_DIR)/limine-bios-cd.bin $(ISO_DIR)/ + cp $(LIMINE_DIR)/limine-uefi-cd.bin $(ISO_DIR)/ + + xorriso -as mkisofs \ + -b limine-bios-cd.bin \ + -no-emul-boot \ + -boot-load-size 4 \ + -boot-info-table \ + --efi-boot limine-uefi-cd.bin \ + -efi-boot-part --efi-boot-image \ + --protective-msdos-label \ + $(ISO_DIR) -o $(ISO_IMAGE) + + limine bios-install $(ISO_IMAGE) + +run: iso + qemu-system-x86_64 -cdrom $(ISO_IMAGE) + +clean: + rm -vrf $(BUILD_DIR) |