42_KFS/Makefile

62 lines
1.3 KiB
Makefile
Raw Permalink Normal View History

NAME := bozOS
2024-09-06 18:36:03 -04:00
AS := i386-elf-as
ASFLAGS :=
CC := i386-elf-gcc
CFLAGS := -std=gnu99 -ffreestanding -Wall -Wextra -iquotelibbozo/headers -iquoteheaders -MMD -fno-omit-frame-pointer -g
2024-09-06 18:36:03 -04:00
LD := $(CC)
LDFLAGS := -T boot/linker.ld -ffreestanding -nostdlib
LIBS := -L libbozo/build/ -lbozo -lgcc
2024-09-06 18:36:03 -04:00
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))
2024-09-06 18:36:03 -04:00
all: $(NAME)
obj/%.o: src/%.s
2024-09-06 19:44:40 -04:00
mkdir -p $(dir $@)
2024-09-06 18:36:03 -04:00
$(AS) $(ASFLAGS) $< -o $@
obj/%.o: src/%.c
2024-09-06 19:44:40 -04:00
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
2024-09-06 18:36:03 -04:00
$(NAME): $(OBJ)
2024-09-06 19:44:40 -04:00
make -C libbozo
mkdir -p build
$(LD) $(LDFLAGS) -o build/$(NAME).bin $(OBJ) $(LIBS)
2024-09-06 18:36:03 -04:00
run: $(NAME)
qemu-system-i386 -kernel build/$(NAME).bin
2024-09-06 18:36:03 -04:00
iso: $(NAME)
mkdir -p isodir/boot/grub
cp build/$(NAME).bin isodir/boot/$(NAME).bin
cp config/grub.cfg isodir/boot/grub/grub.cfg
2024-09-22 04:13:13 -04:00
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
2024-09-06 18:36:03 -04:00
clean:
2024-09-06 19:44:40 -04:00
make -C libbozo clean
rm -rf isodir
rm -rf obj
2024-09-06 18:36:03 -04:00
fclean: clean
2024-09-06 19:44:40 -04:00
make -C libbozo fclean
rm -rf build
2024-09-06 18:36:03 -04:00
re: fclean all
.PHONY: all clean fclean re run iso run-iso
-include $(DEP)