os/Makefile
2024-07-15 20:14:00 +02:00

67 lines
1,023 B
Makefile

ARCHDIR=arch/i686
CFLAGS?=
INCLUDEDIR=include
CFLAGS:=-O2 \
-std=gnu99 \
-ffreestanding \
-Wall -Wextra \
-I$(INCLUDEDIR) \
$(CFLAGS)
KERNEL_OBJS=kernel/kernel.o
LIB_OBJS=\
$(ARCHDIR)/bootstrap.o \
$(ARCHDIR)/tty.o\
$(ARCHDIR)/strlib.o\
$(ARCHDIR)/interrupt.o\
OBJS=$(KERNEL_OBJS) $(LIB_OBJS)
LDFLAGS=$(OBJS) \
-ffreestanding \
-O2 \
-nostdlib \
-lgcc
.SUFFIXES: .c .o .s
all:
$(MAKE) run-grub-qemu
clean:
rm -f $(OBJS)
rm myos.bin
rm myos.iso
debug:
mkdir build || true
cp Makefile build
cp -r isodir build
CFLAGS=-g $(MAKE) -C build debug-grub-qemu
.c.o:
i686-elf-gcc -c $< -o $@ $(CFLAGS)
.s.o:
i686-elf-as $< -o $@
myos.bin: $(OBJS)
i686-elf-gcc -T $(ARCHDIR)/linker.ld -o myos.bin $(LDFLAGS)
grub-file --is-x86-multiboot myos.bin
run-grub-qemu: myos.bin
cp myos.bin isodir/boot/myos.bin
grub-mkrescue -o myos.iso isodir
qemu-system-i386 myos.iso
debug-grub-qemu: myos.bin
cp myos.bin isodir/boot/myos.bin
grub-mkrescue -o myos.iso isodir
qemu-system-i386 -S -gdb tcp::9000 myos.iso