42_KFS/Makefile
2024-09-22 10:13:13 +02:00

62 lines
1.3 KiB
Makefile

NAME := bozOS
AS := i386-elf-as
ASFLAGS :=
CC := i386-elf-gcc
CFLAGS := -std=gnu99 -ffreestanding -Wall -Wextra -iquotelibbozo/headers -iquoteheaders -MMD -fno-omit-frame-pointer -g
LD := $(CC)
LDFLAGS := -T boot/linker.ld -ffreestanding -nostdlib
LIBS := -L libbozo/build/ -lbozo -lgcc
SSRC := $(shell find src -name '*.s')
CSRC := $(shell find src -name '*.c')
OBJ := $(patsubst src/%.c,obj/%.o,$(CSRC))\
$(patsubst src/%.s,obj/%.o,$(SSRC))
DEP := $(patsubst %.o,%.d,$(OBJ))
all: $(NAME)
obj/%.o: src/%.s
mkdir -p $(dir $@)
$(AS) $(ASFLAGS) $< -o $@
obj/%.o: src/%.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
$(NAME): $(OBJ)
make -C libbozo
mkdir -p build
$(LD) $(LDFLAGS) -o build/$(NAME).bin $(OBJ) $(LIBS)
run: $(NAME)
qemu-system-i386 -kernel build/$(NAME).bin
iso: $(NAME)
mkdir -p isodir/boot/grub
cp build/$(NAME).bin isodir/boot/$(NAME).bin
cp config/grub.cfg isodir/boot/grub/grub.cfg
grub-mkrescue -o build/$(NAME).iso --compress=xz --locales=en@quot --themes= isodir
rm -rf isodir
run-iso: iso
qemu-system-i386 -cdrom build/$(NAME).iso
debug: iso
qemu-system-i386 -s -S build/$(NAME).iso
clean:
make -C libbozo clean
rm -rf isodir
rm -rf obj
fclean: clean
make -C libbozo fclean
rm -rf build
re: fclean all
.PHONY: all clean fclean re run iso run-iso
-include $(DEP)