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-16 22:51:41 +02:00
|
|
|
ASFLAGS?=
|
2024-07-11 08:56:52 +02:00
|
|
|
|
2024-07-15 20:14:00 +02:00
|
|
|
INCLUDEDIR=include
|
|
|
|
|
2024-07-16 22:51:41 +02:00
|
|
|
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-16 22:51:41 +02:00
|
|
|
ASFLAGS:=\
|
|
|
|
-I$(INCLUDEDIR) \
|
|
|
|
-I$(ARCHDIR) \
|
|
|
|
$(ASFLAGS)
|
|
|
|
|
|
|
|
KERNEL_OBJS=\
|
|
|
|
kernel/kernel.o \
|
|
|
|
kernel/debugging.o \
|
2024-08-05 00:59:07 +02:00
|
|
|
kernel/elf.o \
|
2024-08-10 01:14:29 +02:00
|
|
|
kernel/syscall.o \
|
2024-08-11 13:40:21 +02:00
|
|
|
kernel/io/keyboard.o \
|
2024-08-10 03:49:28 +02:00
|
|
|
kernel/heap.o \
|
2024-08-22 13:41:51 +02:00
|
|
|
kernel/task.o \
|
2024-07-11 08:56:52 +02:00
|
|
|
|
2024-07-15 20:14:00 +02:00
|
|
|
LIB_OBJS=\
|
|
|
|
$(ARCHDIR)/bootstrap.o \
|
2024-07-16 22:51:41 +02:00
|
|
|
$(ARCHDIR)/tty.o \
|
|
|
|
$(ARCHDIR)/strlib.o \
|
2024-08-09 23:16:20 +02:00
|
|
|
$(ARCHDIR)/interrupts/idt.o \
|
|
|
|
$(ARCHDIR)/interrupts/interrupt.o \
|
2024-08-22 13:41:51 +02:00
|
|
|
$(ARCHDIR)/interrupts/irq0.o \
|
2024-08-10 01:14:29 +02:00
|
|
|
$(ARCHDIR)/interrupts/syscall.o \
|
2024-07-16 22:51:41 +02:00
|
|
|
$(ARCHDIR)/gdt.o \
|
2024-08-09 23:16:20 +02:00
|
|
|
$(ARCHDIR)/userland.o \
|
|
|
|
$(ARCHDIR)/interrupts/pic.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-16 22:51:41 +02:00
|
|
|
.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
|
|
|
|
2024-07-16 22:51:41 +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)
|
2024-07-16 22:51:41 +02:00
|
|
|
rm -f myos.kernel
|
|
|
|
rm -f myos.iso
|
|
|
|
rm -f isodir/boot/myos.kernel
|
2024-07-11 08:56:52 +02:00
|
|
|
|
2024-08-09 23:16:20 +02:00
|
|
|
$(ARCHDIR)/interrupts/interrupt.o: CFLAGS += -mgeneral-regs-only
|
2024-08-08 21:34:30 +02:00
|
|
|
# kernel/elf.o: CFLAGS += -masm=intel
|
2024-08-05 00:59:07 +02:00
|
|
|
|
|
|
|
%.o : %.c
|
2024-07-15 20:14:00 +02:00
|
|
|
i686-elf-gcc -c $< -o $@ $(CFLAGS)
|
2024-07-11 08:56:52 +02:00
|
|
|
|
2024-08-05 00:59:07 +02:00
|
|
|
%.o : %.s
|
2024-07-16 22:51:41 +02:00
|
|
|
i686-elf-as $< -o $@ $(ASFLAGS)
|
2024-07-11 08:56:52 +02:00
|
|
|
|
2024-07-16 22:51:41 +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
|
|
|
|
2024-07-16 22:51:41 +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
|
|
|
|
|
2024-07-16 22:51:41 +02:00
|
|
|
debug: CFLAGS += -g -O0
|
|
|
|
debug: ASFLAGS += -g
|
|
|
|
debug: all
|
2024-07-15 20:14:00 +02:00
|
|
|
|
2024-08-08 21:34:30 +02:00
|
|
|
run: all
|
2024-08-05 00:59:07 +02:00
|
|
|
qemu-system-i386 myos.iso
|
2024-07-11 08:56:52 +02:00
|
|
|
|
2024-07-16 22:51:41 +02:00
|
|
|
run-debug: debug
|
2024-08-05 00:59:07 +02:00
|
|
|
qemu-system-i386 -S -gdb tcp::9000 myos.iso
|