summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-08-02 12:45:38 +0000
committerJoursoir <chat@joursoir.net>2021-08-02 12:45:38 +0000
commit39f626a5d0cf0f5db95e695d013b70a04c29348e (patch)
tree8983e0caab3d3f1592d0febee727c31b789ef8f6 /Makefile
downloadmfsos-39f626a5d0cf0f5db95e695d013b70a04c29348e.tar.gz
mfsos-39f626a5d0cf0f5db95e695d013b70a04c29348e.tar.bz2
mfsos-39f626a5d0cf0f5db95e695d013b70a04c29348e.zip
init project
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile33
1 files changed, 33 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..31f1bbb
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,33 @@
+OSNAME = mfsos
+OSBIN = $(OSNAME).bin
+
+OBJECTS = kernel/main.o
+LINKER = kernel/linker.ld
+BOOT_SRC = kernel/boot.s
+BOOT_OBJ = ${BOOT_SRC:.s=.o}
+
+TARGET_TOOLS = $(HOME)/path/to/cross/compiler/i686-elf-
+CC = $(TARGET_TOOLS)gcc
+AS = $(TARGET_TOOLS)as
+
+.PHONY: all qemu clean
+
+all: $(OSBIN)
+
+$(OSBIN): $(BOOT_OBJ) $(OBJECTS)
+ $(CC) -T $(LINKER) -o $(OSBIN) -ffreestanding -O2 -nostdlib \
+ $(OBJECTS) $(BOOT_OBJ) -lgcc
+
+$(BOOT_OBJ): $(BOOT_SRC)
+ $(AS) $< -o $@
+
+%.o: %.c
+ $(CC) -c $< -o $@ \
+ -std=gnu89 -ffreestanding -O2 -Wall \
+ -Wpedantic -Wextra
+
+qemu: $(OSBIN)
+ qemu-system-i386 -kernel $(OSBIN)
+
+clean:
+ rm -rf $(BOOT_OBJ) $(OBJECTS) $(OSBIN)