Change: build process & makefile, tree restructuration

This commit is contained in:
xamidev
2024-07-18 20:25:42 +02:00
parent ddbc549cb0
commit 77f40f0bb0
25 changed files with 20 additions and 9 deletions
+1
View File
@@ -1,2 +1,3 @@
*.o *.o
bochslog.txt bochslog.txt
build/
Binary file not shown.
BIN
View File
Binary file not shown.
+19 -9
View File
@@ -1,15 +1,30 @@
OBJECTS = loader.o kmain.o stdio.o io.o string.o serial.o gdt.o idt.o system.o isr.o irq.o timer.o kb.o
CC = gcc CC = gcc
CFLAGS = -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -Wall -Wextra -c CFLAGS = -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -Wall -Wextra -c -I src/
LDFLAGS = -T link.ld -melf_i386 LDFLAGS = -T link.ld -melf_i386
AS = nasm AS = nasm
ASFLAGS = -f elf ASFLAGS = -f elf
SRC_DIR = src
OBJ_DIR = build
all: kernel.elf C_SOURCES = $(wildcard $(SRC_DIR)/*.c)
ASM_SOURCES = $(wildcard $(SRC_DIR)/*.s)
OBJECTS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(C_SOURCES)) \
$(patsubst $(SRC_DIR)/%.s, $(OBJ_DIR)/%.o, $(ASM_SOURCES))
all: $(OBJ_DIR) kernel.elf
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
kernel.elf: $(OBJECTS) kernel.elf: $(OBJECTS)
ld $(LDFLAGS) $(OBJECTS) -o kernel.elf ld $(LDFLAGS) $(OBJECTS) -o kernel.elf
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) $< -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.s
$(AS) $(ASFLAGS) $< -o $@
os.iso: kernel.elf os.iso: kernel.elf
cp kernel.elf iso/boot/kernel.elf cp kernel.elf iso/boot/kernel.elf
genisoimage -R \ genisoimage -R \
@@ -26,10 +41,5 @@ os.iso: kernel.elf
run: os.iso run: os.iso
bochs -f bochsrc.txt -q bochs -f bochsrc.txt -q
%.o: %.c
$(CC) $(CFLAGS) $< -o $@
%.o: %.s
$(AS) $(ASFLAGS) $< -o $@
clean: clean:
rm -rf *.o kernel.elf os.iso rm -rf $(OBJ_DIR) *.o kernel.elf os.iso
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File