# compiler
CC = gcc
LD = ld

# flags
CFLAGS = -Wall -Wextra -std=c11 -ffreestanding -fno-stack-protector -fno-stack-check -fno-lto -fPIE -m64 -march=x86-64 -mno-80387 -mno-mmx -mno-sse -mno-sse2 -mno-red-zone -Isrc
LDFLAGS = -T linker.ld -static -nostdlib -no-pie -z max-page-size=0x1000

# files
SRCS = src/kernel.c
OBJS = build/kernel.o

# build
all: florid.iso

build/kernel.o: src/kernel.c
	mkdir -p build
	$(CC) $(CFLAGS) -c src/kernel.c -o build/kernel.o

iso_root/kernel: build/kernel.o
	$(LD) $(LDFLAGS) build/kernel.o -o iso_root/kernel

florid.iso: iso_root/kernel
	xorriso -as mkisofs -b limine/limine-bios-cd.bin \
		-no-emul-boot -boot-load-size 4 -boot-info-table \
		iso_root -o florid.iso
	./iso_root/limine/limine bios-install florid.iso

# clean
clean:
	rm -rf build/*.o florid.iso iso_root/kernel