os/Makefile

79 lines
1.2 KiB
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?=
ASFLAGS?=
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)
ASFLAGS:=\
-I$(INCLUDEDIR) \
-I$(ARCHDIR) \
$(ASFLAGS)
KERNEL_OBJS=\
kernel/kernel.o \
kernel/debugging.o \
kernel/elf.o \
2024-07-11 08:56:52 +02:00
2024-07-15 20:14:00 +02:00
LIB_OBJS=\
$(ARCHDIR)/bootstrap.o \
$(ARCHDIR)/tty.o \
$(ARCHDIR)/strlib.o \
$(ARCHDIR)/idt.o \
$(ARCHDIR)/interrupt.o \
$(ARCHDIR)/gdt.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
.PHONY: all clean myos.iso
2024-07-15 20:14:00 +02:00
.SUFFIXES: .c .o .s
2024-07-11 08:56:52 +02:00
all: myos.iso
2024-07-11 08:56:52 +02:00
2024-07-15 20:14:00 +02:00
clean:
rm -f $(OBJS)
rm -f myos.kernel
rm -f myos.iso
rm -f isodir/boot/myos.kernel
2024-07-11 08:56:52 +02:00
$(ARCHDIR)/interrupt.o: CFLAGS += -mgeneral-regs-only
kernel/elf.o: CFLAGS += -masm=intel
%.o : %.c
2024-07-15 20:14:00 +02:00
i686-elf-gcc -c $< -o $@ $(CFLAGS)
2024-07-11 08:56:52 +02:00
%.o : %.s
i686-elf-as $< -o $@ $(ASFLAGS)
2024-07-11 08:56:52 +02:00
myos.kernel: $(OBJS)
i686-elf-gcc -T $(ARCHDIR)/linker.ld -o myos.kernel $(LDFLAGS)
grub-file --is-x86-multiboot myos.kernel
2024-07-11 08:56:52 +02:00
myos.iso: myos.kernel
cp myos.kernel isodir/boot/myos.kernel
2024-07-15 20:14:00 +02:00
grub-mkrescue -o myos.iso isodir
debug: CFLAGS += -g -O0
debug: ASFLAGS += -g
debug: all
2024-07-15 20:14:00 +02:00
run: myos.iso
qemu-system-i386 myos.iso
2024-07-11 08:56:52 +02:00
run-debug: debug
qemu-system-i386 -S -gdb tcp::9000 myos.iso