summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile40
1 files changed, 19 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 64a07c6..debc6d0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
-ARCH=i686-elf
+ARCH=i686-elf-
-export CC=$(ARCH)-gcc
-export AS=$(ARCH)-as
+export CC=$(ARCH)gcc
+export AS=$(ARCH)as
export CFLAGS=-ffreestanding -O2 -Wall -Wextra -fstack-protector-all
MKDIR=mkdir -p
@@ -22,26 +22,22 @@ TARGET=myos
BINARY=$(BUILD_DIR)/$(TARGET).bin
ISO=$(TARGET).iso
-CRTI_SOURCE=crti.s
-CRTN_SOURCE=crtn.s
-AS_SOURCE=boot.s irq.s paging.s
-C_SOURCES=gdt.c heap.c idt.c kernel.c keyboard.c keymap.c stdio.c string.c tty.c vga.c irq.c stack_protector.c timer.c paging.c
+CRTI_OBJ=crti.o
+CRTN_OBJ=crtn.o
+AS_OBJ=boot.o irq.o paging.o
+C_OBJ=gdt.o heap.o idt.o kernel.o keyboard.o keymap.o stdio.o string.o tty.o vga.o irq.o stack_protector.o timer.o paging.o
-C_SOURCE_FILES=$(patsubst %,$(C_SOURCE_DIR)/%,$(C_SOURCES))
-export C_OBJECTS=$(patsubst %,$(C_OBJECT_DIR)/%,$(C_SOURCES:c=o))
+export C_OBJECTS=$(patsubst %,$(C_OBJECT_DIR)/%,$(C_OBJ))
-AS_OBJECT=$(patsubst %,$(AS_OBJECT_DIR)/%,$(AS_SOURCE:s=o))
-CRTI_OBJECT=$(patsubst %,$(AS_OBJECT_DIR)/%,$(CRTI_SOURCE:s=o))
-CRTN_OBJECT=$(patsubst %,$(AS_OBJECT_DIR)/%,$(CRTN_SOURCE:s=o))
+AS_OBJECT=$(patsubst %,$(AS_OBJECT_DIR)/%,$(AS_OBJ))
+CRTI_OBJECT=$(patsubst %,$(AS_OBJECT_DIR)/%,$(CRTI_OBJ))
+CRTN_OBJECT=$(patsubst %,$(AS_OBJECT_DIR)/%,$(CRTN_OBJ))
-AS_SOURCES=$(AS_SOURCE) $(CRTI_SOURCE) $(CRTN_SOURCE)
-AS_SOURCE_FILES=$(patsubst %,$(AS_SOURCE_DIR)/%,$(AS_SOURCES))
-export AS_OBJECTS=$(patsubst %,$(AS_OBJECT_DIR)/%,$(AS_SOURCES:s=o))
-
-CRTBEGIN_OBJ=$(shell $(CC) -print-file-name=crtbegin.o)
-CRTEND_OBJ=$(shell $(CC) -print-file-name=crtend.o)
-OBJ=$(CRTI_OBJECT) $(CRTBEGIN_OBJ) $(AS_OBJECT) $(C_OBJECTS) $(CRTEND_OBJ) $(CRTN_OBJECT)
+export AS_OBJECTS=$(AS_OBJECT) $(CRTI_OBJECT) $(CRTN_OBJECT)
+CRTBEGIN_OBJECT=$(shell $(CC) -print-file-name=crtbegin.o)
+CRTEND_OBJECT=$(shell $(CC) -print-file-name=crtend.o)
+OBJ=$(CRTI_OBJECT) $(CRTBEGIN_OBJECT) $(AS_OBJECT) $(C_OBJECTS) $(CRTEND_OBJECT) $(CRTN_OBJECT)
.PHONY: all compile run run-iso clean
@@ -50,7 +46,8 @@ all: compile
$(BINARY): $(OBJ)
$(CC) -T $(SOURCE_DIR)/linker.ld -o $(BINARY) $(CFLAGS) -nostdlib -lgcc $(OBJ)
-compile: $(AS_SOURCE_FILES) $(C_SOURCE_FILES)
+compile:
+ ./headers.sh
$(MKDIR) $(AS_OBJECT_DIR)
$(MKDIR) $(C_OBJECT_DIR)
$(MAKE) --directory $(AS_SOURCE_DIR)
@@ -67,7 +64,8 @@ $(ISO): $(BINARY)
run: compile
$(QEMU) -kernel $(BINARY) $(QEMU_DEBUG)
-run-iso: compile $(ISO)
+run-iso: compile
+ $(MAKE) $(ISO)
$(QEMU) -cdrom $(ISO)
clean: