42_KFS/Makefile

63 lines
1.4 KiB
Makefile
Raw Normal View History

BUILDDIR := build
SOURCEDIR := src
OBJECTDIR := obj
NAME := bozOS
2024-09-06 18:36:03 -04:00
AS := i386-elf-as
ASFLAGS :=
CC := i386-elf-gcc
CCFLAGS := -std=gnu99 -ffreestanding -O2 -Wall -Wextra -iquotelibbozo/headers -iquoteheaders -g
2024-09-06 18:36:03 -04:00
LD := $(CC)
LDFLAGS := -T boot/linker.ld -ffreestanding -O2 -nostdlib
LIBS := -L libbozo/build/ -lbozo -lgcc
2024-09-06 18:36:03 -04:00
SSRC := $(shell find $(SOURCEDIR) -name '*.s')
CSRC := $(shell find $(SOURCEDIR) -name '*.c')
OBJ := $(patsubst $(SOURCEDIR)/%.c,$(OBJECTDIR)/%.o,$(CSRC))\
$(patsubst $(SOURCEDIR)/%.s,$(OBJECTDIR)/%.o,$(SSRC))
2024-09-06 18:36:03 -04:00
all: $(NAME)
$(OBJECTDIR)/%.o: $(SOURCEDIR)/%.s
2024-09-06 19:44:40 -04:00
mkdir -p $(dir $@)
2024-09-06 18:36:03 -04:00
$(AS) $(ASFLAGS) $< -o $@
$(OBJECTDIR)/%.o: $(SOURCEDIR)/%.c
2024-09-06 19:44:40 -04:00
mkdir -p $(dir $@)
2024-09-06 18:36:03 -04:00
$(CC) $(CCFLAGS) -c $< -o $@
$(NAME): $(OBJ)
2024-09-06 19:44:40 -04:00
make -C libbozo
mkdir -p $(BUILDDIR)/
$(LD) $(LDFLAGS) -o $(BUILDDIR)/$(NAME).bin $(OBJ) $(LIBS)
2024-09-06 18:36:03 -04:00
run: $(NAME)
qemu-system-i386 -kernel $(BUILDDIR)/$(NAME).bin
2024-09-06 18:36:03 -04:00
iso: $(NAME)
mkdir -p isodir/boot/grub
cp $(BUILDDIR)/$(NAME).bin isodir/boot/bozOS.bin
cp config/grub.cfg isodir/boot/grub/grub.cfg
grub-mkrescue -o $(BUILDDIR)/bozOS.iso isodir
rm -rf isodir
run_iso: iso
qemu-system-i386 -cdrom $(BUILDDIR)/bozOS.iso
debug: iso
qemu-system-i386 -s -S $(BUILDDIR)/bozOS.iso
2024-09-06 18:36:03 -04:00
clean:
2024-09-06 19:44:40 -04:00
make -C libbozo clean
2024-09-07 06:08:46 -04:00
rm -rf $(OBJDIR)
2024-09-06 18:36:03 -04:00
fclean: clean
2024-09-06 19:44:40 -04:00
make -C libbozo fclean
rm -rf $(BUILDDIR)/
2024-09-06 18:36:03 -04:00
re: fclean all
.PHONY: all clean fclean re run iso run_iso