2018-12-20 18:03:39 +01:00
|
|
|
#----------------------------------------------------------------------------#
|
|
|
|
# GNU GPL OS/K #
|
|
|
|
# #
|
|
|
|
# Authors: spectral` #
|
|
|
|
# NeoX #
|
|
|
|
# #
|
|
|
|
# Desc: Project Makefile #
|
|
|
|
#----------------------------------------------------------------------------#
|
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
CCNAME="/opt/cross-cc/bin/x86_64-elf-gcc"
|
|
|
|
CWARNS=-Wall -Wextra -Werror -pedantic
|
|
|
|
CLDSCR=-T kernel.ld
|
2018-12-20 18:03:39 +01:00
|
|
|
CFLAGS=-nostdlib -ffreestanding -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2
|
|
|
|
CINCLUDES=-I./kaleid
|
|
|
|
CDEFINES=
|
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
CC=$(CCNAME) $(CWARNS) $(CLDSCR) $(CFLAGS) $(CDEFINES) $(CINCLUDES)
|
2018-12-20 18:03:39 +01:00
|
|
|
|
|
|
|
ASM=nasm
|
|
|
|
ASMFLAGS=
|
|
|
|
BOOTFLAGS=-f bin
|
|
|
|
|
|
|
|
BINDIR=../bin
|
|
|
|
OBJDIR=../obj
|
|
|
|
|
|
|
|
BOOTDIR=boot
|
|
|
|
COMMDIR=kaleid/common
|
|
|
|
KERNDIR=kaleid/kernel
|
|
|
|
SYSTDIR=kaleid/system
|
|
|
|
|
|
|
|
all: bootloader
|
|
|
|
|
2018-12-22 23:58:46 +01:00
|
|
|
boot.mbr.s: $(BOOTDIR)/mbr.s $(BOOTDIR)/mbr.inc
|
2018-12-20 18:03:39 +01:00
|
|
|
$(ASM) $(BOOTFLAGS) $(BOOTDIR)/mbr.s -o $(OBJDIR)/boot/mbr.bin
|
|
|
|
|
|
|
|
boot.loader.s: $(BOOTDIR)/loader.s
|
|
|
|
$(ASM) $(BOOTFLAGS) $(BOOTDIR)/loader.s -o $(OBJDIR)/boot/loader.bin
|
|
|
|
|
|
|
|
bootloader: boot.mbr.s boot.loader.s
|
2018-12-20 19:16:31 +01:00
|
|
|
cp $(OBJDIR)/boot/mbr.bin $(BINDIR)/mbr.bin
|
|
|
|
cp $(OBJDIR)/boot/loader.bin $(BINDIR)/loader.bin
|
2018-12-20 18:03:39 +01:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------------#
|
|
|
|
# TESTING MAKEFILE
|
|
|
|
|
|
|
|
pseudo_kern:
|
|
|
|
$(ASM) $(BOOTFLAGS) $(BOOTDIR)/pseudo_kernel.s -o $(OBJDIR)/boot/pkernel.bin
|
|
|
|
|
|
|
|
testing: bootloader pseudo_kern
|
|
|
|
cat $(BINDIR)/bootloader.bin $(OBJDIR)/boot/pkernel.bin > $(BINDIR)/boot.bin
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------#
|
|
|
|
# COMMON MAKEFILE
|
|
|
|
|
|
|
|
COBJDIR=$(OBJDIR)/$(COMMDIR)
|
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
COMMDEPS=$(COMMDIR)/common.h $(COMMDIR)/assert.h $(COMMDIR)/atomic.h $(COMMDIR)/config.h \
|
2018-12-20 18:03:39 +01:00
|
|
|
$(COMMDIR)/status.h
|
|
|
|
|
|
|
|
COBJECTS=$(COBJDIR)/lib/string.o
|
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
common: common.lib.string.c $(COMMDEPS)
|
2018-12-20 18:03:39 +01:00
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
common.lib.string.c: $(COMMDIR)/lib/string.c $(COMMDEPS)
|
2018-12-20 18:03:39 +01:00
|
|
|
$(CC) -c $(COMMDIR)/lib/string.c -o $(OBJDIR)/$(COMMDIR)/lib/string.o
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------#
|
|
|
|
# KERNEL MAKEFILE
|
|
|
|
|
|
|
|
KOBJDIR=$(OBJDIR)/$(KERNDIR)
|
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
KERNDEPS=$(COMMDEPS) $(KERNDIR)/init.h $(KERNDIR)/io/terminal.h $(KERNDIR)/io/ports.h
|
2018-12-20 18:03:39 +01:00
|
|
|
|
|
|
|
kernel: common kernel.io.terminal.c kernel.init.c kernel.io.ports.c
|
2018-12-24 18:13:58 +01:00
|
|
|
$(CC) -o $(BINDIR)/kaleid-kernel.elf \
|
|
|
|
$(COBJECTS) $(KOBJDIR)/init.o \
|
2018-12-20 18:03:39 +01:00
|
|
|
$(KOBJDIR)/io/terminal.o $(KOBJDIR)/io/ports.o
|
|
|
|
|
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
kernel.init.c: $(KERNDIR)/init.c $(KERNDEPS)
|
2018-12-20 18:03:39 +01:00
|
|
|
$(CC) -c $(KERNDIR)/init.c -o $(KOBJDIR)/init.o
|
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
kernel.io.ports.c: $(KERNDIR)/io/ports.c $(KERNDEPS)
|
2018-12-20 18:03:39 +01:00
|
|
|
$(CC) -c $(KERNDIR)/io/ports.c -o $(KOBJDIR)/io/ports.o
|
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
kernel.io.terminal.c: $(KERNDIR)/io/terminal.c $(KERNDEPS)
|
2018-12-20 18:03:39 +01:00
|
|
|
$(CC) -c $(KERNDIR)/io/terminal.c -o $(KOBJDIR)/io/terminal.o
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|