Files
nub-os/makefile
nub31 87d1a291f7 ...
2025-09-03 13:13:16 +02:00

36 lines
927 B
Makefile

CC = x86_64-elf-gcc
LD = x86_64-elf-ld
AS = nasm
TARGET_PATH = src/arch/x86_64
CFLAGS = -m64 -ffreestanding -nostdlib -fno-builtin -Wall -Wextra -Wshadow -std=c11 -I src/stdlib -g
LDFLAGS = -g
ASFLAGS = -f elf64 -g -F dwarf
SRC_C := $(shell find src -name '*.c' )
SRC_ASM := $(shell find src -name '*.asm' )
OBJS := $(patsubst src/%.c, .build/%.o, $(SRC_C)) $(patsubst src/%.asm, .build/%.o, $(SRC_ASM))
iso: .build/nub-os.iso
@echo "ISO created at '.build/nub-os.iso'"
clean:
@rm -r .build 2>/dev/null || true
.build/nub-os.iso: .build/kernel grub.cfg
mkdir -p .build/nub-os/boot/grub
cp grub.cfg .build/nub-os/boot/grub
cp .build/kernel .build/nub-os/boot/
grub-mkrescue -o .build/nub-os.iso .build/nub-os/
.build/kernel: $(OBJS)
$(LD) $(LDFLAGS) -T linker.ld -o $@ $^
.build/%.o: src/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c -o $@ $<
.build/%.o: src/%.asm
@mkdir -p $(dir $@)
$(AS) $(ASFLAGS) -o $@ $<