summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-09-30 11:03:58 +0000
committerJoursoir <chat@joursoir.net>2021-09-30 11:03:58 +0000
commit59bc01df5b44e248079bb5d00dfabf7b99287440 (patch)
tree26e8cb5a802ff0b19ccf14ff2fad792bf1221e56
parent92456c92b6da38110df60785a563b30c7108190a (diff)
downloadmfsos-59bc01df5b44e248079bb5d00dfabf7b99287440.tar.gz
mfsos-59bc01df5b44e248079bb5d00dfabf7b99287440.tar.bz2
mfsos-59bc01df5b44e248079bb5d00dfabf7b99287440.zip
makefile: export tools, call bootloader make
-rw-r--r--Makefile19
1 files changed, 17 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 31f1bbb..753f84f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,10 @@
OSNAME = mfsos
OSBIN = $(OSNAME).bin
+ARCH = x86
+ARCH_BOOT = arch/$(ARCH)/boot
+BOOTBIN = $(ARCH_BOOT)/bootloader.bin
+
OBJECTS = kernel/main.o
LINKER = kernel/linker.ld
BOOT_SRC = kernel/boot.s
@@ -8,7 +12,13 @@ BOOT_OBJ = ${BOOT_SRC:.s=.o}
TARGET_TOOLS = $(HOME)/path/to/cross/compiler/i686-elf-
CC = $(TARGET_TOOLS)gcc
+export CC
+LD = $(TARGET_TOOLS)ld
+export LD
AS = $(TARGET_TOOLS)as
+export AS
+OBJDUMP = $(TARGET_TOOLS)objdump
+export OBJDUMP
.PHONY: all qemu clean
@@ -18,7 +28,10 @@ $(OSBIN): $(BOOT_OBJ) $(OBJECTS)
$(CC) -T $(LINKER) -o $(OSBIN) -ffreestanding -O2 -nostdlib \
$(OBJECTS) $(BOOT_OBJ) -lgcc
-$(BOOT_OBJ): $(BOOT_SRC)
+$(BOOTBIN):
+ $(MAKE) -C $(ARCH_BOOT)
+
+%.o: %.s
$(AS) $< -o $@
%.o: %.c
@@ -30,4 +43,6 @@ qemu: $(OSBIN)
qemu-system-i386 -kernel $(OSBIN)
clean:
- rm -rf $(BOOT_OBJ) $(OBJECTS) $(OSBIN)
+ $(MAKE) -C $(ARCH_BOOT) clean
+ rm -rf $(BOOT_OBJ) $(OBJECTS)
+ rm -rf $(OSBIN)