os/Makefile

67 lines
1,023 B
Makefile
Raw Normal View History

2024-07-15 20:14:00 +02:00
ARCHDIR=arch/i686
2024-07-11 08:56:52 +02:00
2024-07-15 20:14:00 +02:00
CFLAGS?=
2024-07-11 08:56:52 +02:00
2024-07-15 20:14:00 +02:00
INCLUDEDIR=include
CFLAGS:=-O2 \
2024-07-11 08:56:52 +02:00
-std=gnu99 \
-ffreestanding \
-Wall -Wextra \
2024-07-15 20:14:00 +02:00
-I$(INCLUDEDIR) \
$(CFLAGS)
2024-07-11 08:56:52 +02:00
2024-07-15 20:14:00 +02:00
KERNEL_OBJS=kernel/kernel.o
LIB_OBJS=\
$(ARCHDIR)/bootstrap.o \
$(ARCHDIR)/tty.o\
$(ARCHDIR)/strlib.o\
$(ARCHDIR)/interrupt.o\
2024-07-11 08:56:52 +02:00
OBJS=$(KERNEL_OBJS) $(LIB_OBJS)
2024-07-15 20:14:00 +02:00
2024-07-11 08:56:52 +02:00
LDFLAGS=$(OBJS) \
-ffreestanding \
-O2 \
-nostdlib \
-lgcc
2024-07-15 20:14:00 +02:00
.SUFFIXES: .c .o .s
2024-07-11 08:56:52 +02:00
2024-07-15 20:14:00 +02:00
all:
$(MAKE) run-grub-qemu
2024-07-11 08:56:52 +02:00
2024-07-15 20:14:00 +02:00
clean:
rm -f $(OBJS)
rm myos.bin
rm myos.iso
2024-07-11 08:56:52 +02:00
2024-07-15 20:14:00 +02:00
debug:
2024-07-11 08:56:52 +02:00
mkdir build || true
cp Makefile build
2024-07-15 20:14:00 +02:00
cp -r isodir build
CFLAGS=-g $(MAKE) -C build debug-grub-qemu
2024-07-11 08:56:52 +02:00
2024-07-15 20:14:00 +02:00
.c.o:
i686-elf-gcc -c $< -o $@ $(CFLAGS)
2024-07-11 08:56:52 +02:00
2024-07-15 20:14:00 +02:00
.s.o:
i686-elf-as $< -o $@
2024-07-11 08:56:52 +02:00
2024-07-15 20:14:00 +02:00
myos.bin: $(OBJS)
2024-07-11 08:56:52 +02:00
i686-elf-gcc -T $(ARCHDIR)/linker.ld -o myos.bin $(LDFLAGS)
grub-file --is-x86-multiboot myos.bin
2024-07-15 20:14:00 +02:00
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
2024-07-11 08:56:52 +02:00