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"
|
2018-12-28 19:15:22 +01:00
|
|
|
CC2NAME=gcc
|
|
|
|
COPTIM=-O2
|
2018-12-24 18:13:58 +01:00
|
|
|
CLDSCR=-T kernel.ld
|
2018-12-28 18:52:55 +01:00
|
|
|
CWARNS=-pedantic -Wall -Wextra -Werror
|
2018-12-20 18:03:39 +01:00
|
|
|
CFLAGS=-nostdlib -ffreestanding -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2
|
2018-12-30 20:13:56 +01:00
|
|
|
CINCLUDES=-isystem.
|
2018-12-25 19:09:58 +01:00
|
|
|
CDEFINES=
|
2018-12-20 18:03:39 +01:00
|
|
|
|
2018-12-28 18:52:55 +01:00
|
|
|
CC=$(CCNAME) $(COPTIM) $(CWARNS) $(CFLAGS) $(CDEFINES) $(CINCLUDES)
|
2018-12-25 19:09:58 +01:00
|
|
|
KCC=$(CC) -D_KALEID_KERNEL
|
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
|
2018-12-25 19:09:58 +01:00
|
|
|
LINXDIR=kaleid/linux
|
2018-12-20 18:03:39 +01:00
|
|
|
|
|
|
|
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-25 19:09:58 +01:00
|
|
|
LOBJDIR=$(OBJDIR)/$(LINXDIR)
|
2018-12-20 18:03:39 +01:00
|
|
|
|
2018-12-28 18:52:55 +01:00
|
|
|
COMMDEPS=$(COMMDIR)/common.h $(COMMDIR)/assert.h $(COMMDIR)/atomic.h $(KERNDIR)/config.h \
|
2018-12-20 18:03:39 +01:00
|
|
|
$(COMMDIR)/status.h
|
|
|
|
|
2018-12-28 18:52:55 +01:00
|
|
|
COMMOBJS=$(COBJDIR)/lib/string.o $(COBJDIR)/lib/status.o $(COBJDIR)/lib/convert.o $(COBJDIR)/lib/memory.o
|
2018-12-20 18:03:39 +01:00
|
|
|
|
2018-12-25 19:09:58 +01:00
|
|
|
common: $(COMMDEPS) $(COMMDIR)/lib/string.c $(COMMDIR)/lib/status.c
|
|
|
|
$(KCC) -c $(COMMDIR)/lib/string.c -o $(COBJDIR)/lib/string.o
|
|
|
|
$(KCC) -c $(COMMDIR)/lib/status.c -o $(COBJDIR)/lib/status.o
|
2018-12-28 18:52:55 +01:00
|
|
|
$(KCC) -c $(COMMDIR)/lib/memory.c -o $(COBJDIR)/lib/memory.o
|
|
|
|
$(KCC) -c $(COMMDIR)/lib/convert.c -o $(COBJDIR)/lib/convert.o
|
2018-12-20 18:03:39 +01:00
|
|
|
|
2018-12-28 19:15:22 +01:00
|
|
|
CCC=$(CC2NAME) $(COPTIM) $(CWARNS) $(CINCLUDES)
|
2018-12-24 22:38:14 +01:00
|
|
|
|
2018-12-28 21:20:59 +01:00
|
|
|
test-common:
|
2018-12-25 19:09:58 +01:00
|
|
|
$(CCC) -c $(COMMDIR)/lib/string.c -o $(COBJDIR)/lib/string.o
|
|
|
|
$(CCC) -c $(COMMDIR)/lib/status.c -o $(COBJDIR)/lib/status.o
|
2018-12-28 18:52:55 +01:00
|
|
|
$(CCC) -c $(COMMDIR)/lib/memory.c -o $(COBJDIR)/lib/memory.o
|
|
|
|
$(CCC) -c $(COMMDIR)/lib/convert.c -o $(COBJDIR)/lib/convert.o
|
2018-12-25 19:09:58 +01:00
|
|
|
$(CCC) -c $(LINXDIR)/test-common.c -o $(LOBJDIR)/test-common.o
|
|
|
|
$(CCC) $(COMMOBJS) $(LOBJDIR)/test-common.o -o $(BINDIR)/kaleid-common.elf
|
2018-12-20 18:03:39 +01:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------------#
|
|
|
|
# KERNEL MAKEFILE
|
|
|
|
|
|
|
|
KOBJDIR=$(OBJDIR)/$(KERNDIR)
|
|
|
|
|
2018-12-25 19:09:58 +01:00
|
|
|
KERNDEPS=common $(KERNDIR)/init.h $(KERNDIR)/io/terminal.h $(KERNDIR)/io/ports.h $(KERNDIR)/ke/panic.h
|
2018-12-29 23:51:00 +01:00
|
|
|
KERNSRCS=$(KERNDIR)/init.c $(KERNDIR)/ke/state.c $(KERNDIR)/ke/panic.c $(KERNDIR)/io/ports.c $(KERNDIR)/io/terminal.c
|
|
|
|
KERNOBJS=$(KOBJDIR)/init.o $(KOBJDIR)/ke/state.o $(KOBJDIR)/ke/panic.o $(KOBJDIR)/io/ports.o $(KOBJDIR)/io/terminal.o
|
2018-12-20 18:03:39 +01:00
|
|
|
|
2018-12-25 19:09:58 +01:00
|
|
|
kernel: common $(KERNSRCS)
|
|
|
|
$(KCC) -c $(KERNDIR)/init.c -o $(KOBJDIR)/init.o
|
2018-12-29 23:51:00 +01:00
|
|
|
$(KCC) -c $(KERNDIR)/ke/state.c -o $(KOBJDIR)/ke/state.o
|
2018-12-25 19:09:58 +01:00
|
|
|
$(KCC) -c $(KERNDIR)/ke/panic.c -o $(KOBJDIR)/ke/panic.o
|
|
|
|
$(KCC) -c $(KERNDIR)/io/ports.c -o $(KOBJDIR)/io/ports.o
|
|
|
|
$(KCC) -c $(KERNDIR)/io/terminal.c -o $(KOBJDIR)/io/terminal.o
|
|
|
|
$(KCC) $(CLDSCR) $(COMMOBJS) $(KERNOBJS) -o $(BINDIR)/kaleid-kernel.elf
|
2018-12-20 18:03:39 +01:00
|
|
|
|
2018-12-24 22:38:14 +01:00
|
|
|
#----------------------------------------------------------------------------#
|
2018-12-20 18:03:39 +01:00
|
|
|
|