2024-09-07 06:04:57 -04:00
|
|
|
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
|
2024-09-07 23:03:50 -04:00
|
|
|
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
|
2024-09-07 23:03:50 -04:00
|
|
|
LIBS := -L libbozo/build/ -lbozo -lgcc
|
2024-09-06 18:36:03 -04:00
|
|
|
|
2024-09-07 08:17:21 -04:00
|
|
|
SSRC := $(shell find $(SOURCEDIR) -name '*.s')
|
|
|
|
CSRC := $(shell find $(SOURCEDIR) -name '*.c')
|
2024-09-07 06:04:57 -04:00
|
|
|
OBJ := $(patsubst $(SOURCEDIR)/%.c,$(OBJECTDIR)/%.o,$(CSRC))\
|
|
|
|
$(patsubst $(SOURCEDIR)/%.s,$(OBJECTDIR)/%.o,$(SSRC))
|
2024-09-06 18:36:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
all: $(NAME)
|
|
|
|
|
2024-09-07 06:04:57 -04:00
|
|
|
$(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 $@
|
|
|
|
|
2024-09-07 06:04:57 -04:00
|
|
|
$(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
|
2024-09-07 06:04:57 -04:00
|
|
|
mkdir -p $(BUILDDIR)/
|
|
|
|
$(LD) $(LDFLAGS) -o $(BUILDDIR)/$(NAME).bin $(OBJ) $(LIBS)
|
2024-09-06 18:36:03 -04:00
|
|
|
|
|
|
|
run: $(NAME)
|
2024-09-07 06:04:57 -04:00
|
|
|
qemu-system-i386 -kernel $(BUILDDIR)/$(NAME).bin
|
2024-09-06 18:36:03 -04:00
|
|
|
|
2024-09-07 05:56:18 -04:00
|
|
|
iso: $(NAME)
|
|
|
|
mkdir -p isodir/boot/grub
|
2024-09-07 06:04:57 -04:00
|
|
|
cp $(BUILDDIR)/$(NAME).bin isodir/boot/bozOS.bin
|
2024-09-07 05:56:18 -04:00
|
|
|
cp config/grub.cfg isodir/boot/grub/grub.cfg
|
2024-09-07 06:04:57 -04:00
|
|
|
grub-mkrescue -o $(BUILDDIR)/bozOS.iso isodir
|
|
|
|
rm -rf isodir
|
2024-09-07 05:56:18 -04:00
|
|
|
|
|
|
|
run_iso: iso
|
2024-09-07 06:04:57 -04:00
|
|
|
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
|
2024-09-07 06:04:57 -04:00
|
|
|
rm -rf $(BUILDDIR)/
|
2024-09-06 18:36:03 -04:00
|
|
|
|
|
|
|
re: fclean all
|
|
|
|
|
2024-09-07 05:56:18 -04:00
|
|
|
.PHONY: all clean fclean re run iso run_iso
|