os/Makefile

87 lines
1.4 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-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 \
kernel/task.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 \
2024-08-09 23:16:20 +02:00
$(ARCHDIR)/interrupts/idt.o \
$(ARCHDIR)/interrupts/interrupt.o \
$(ARCHDIR)/interrupts/irq0.o \
2024-08-10 01:14:29 +02:00
$(ARCHDIR)/interrupts/syscall.o \
$(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
.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
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
%.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
2024-08-08 21:34:30 +02:00
run: all
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