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
|
2019-01-01 13:09:57 +01:00
|
|
|
CINCLUDES=-isystem./kaleid/include
|
2018-12-25 19:09:58 +01:00
|
|
|
CDEFINES=
|
2018-12-20 18:03:39 +01:00
|
|
|
|
2018-12-31 10:49:08 +01:00
|
|
|
CFLAGS1=-nostdlib -ffreestanding -mcmodel=large
|
|
|
|
CFLAGS2=-mno-red-zone -mno-mmx -mno-sse -mno-sse2
|
|
|
|
CFLAGS=$(CFLAGS1) $(CFLAGS2)
|
|
|
|
|
2018-12-28 18:52:55 +01:00
|
|
|
CC=$(CCNAME) $(COPTIM) $(CWARNS) $(CFLAGS) $(CDEFINES) $(CINCLUDES)
|
2019-01-01 13:09:57 +01:00
|
|
|
KCC=$(CC) -D_OSK_SOURCE -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
|
2019-01-01 13:09:57 +01:00
|
|
|
LINXDIR=kaleid/common/test
|
|
|
|
INCDIR=kaleid/include
|
2018-12-20 18:03:39 +01:00
|
|
|
|
2018-12-31 10:49:08 +01:00
|
|
|
all: bootloader kernel
|
2018-12-20 18:03:39 +01:00
|
|
|
|
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
|
|
|
|
2019-01-01 13:09:57 +01:00
|
|
|
#COMMDEPS=$(COMMDIR)/common.h $(COMMDIR)/stdlib.h $(KERNDIR)/config.h
|
|
|
|
COMMDEPS=$(INCDIR)/kaleid.h $(INCDIR)/kaldefs.h $(INCDIR)/kaltypes.h \
|
|
|
|
$(INCDIR)/kalmask.h $(INCDIR)/kalmask.h $(INCDIR)/kalassrt.h
|
2018-12-20 18:03:39 +01:00
|
|
|
|
2019-01-01 17:11:30 +01:00
|
|
|
COMMSRCS=$(COMMDIR)/string.c $(COMMDIR)/status.c $(COMMDIR)/rand.c \
|
|
|
|
$(COMMDIR)/convert.c $(COMMDIR)/memory.c $(COMMDIR)/arith.c
|
2018-12-20 18:03:39 +01:00
|
|
|
|
2019-01-01 17:11:30 +01:00
|
|
|
COMMOBJS=$(COBJDIR)/string.o $(COBJDIR)/status.o $(COBJDIR)/rand.o \
|
2019-01-01 17:37:58 +01:00
|
|
|
$(COBJDIR)/memory.o $(COBJDIR)/arith.o \
|
|
|
|
$(COBJDIR)/itoa.o $(COBJDIR)/ltoa.o $(COBJDIR)/utoa.o $(COBJDIR)/ultoa.o
|
2019-01-01 13:09:57 +01:00
|
|
|
|
2019-01-01 17:37:58 +01:00
|
|
|
comm-convert:
|
|
|
|
$(KCC) -c $(COMMDIR)/convert.c -D_NEED_ITOA -o $(COBJDIR)/itoa.o
|
|
|
|
$(KCC) -c $(COMMDIR)/convert.c -D_NEED_LTOA -o $(COBJDIR)/ltoa.o
|
|
|
|
$(KCC) -c $(COMMDIR)/convert.c -D_NEED_UTOA -o $(COBJDIR)/utoa.o
|
|
|
|
$(KCC) -c $(COMMDIR)/convert.c -D_NEED_ULTOA -o $(COBJDIR)/ultoa.o
|
|
|
|
|
|
|
|
common: $(COMMDEPS) $(COMMSRCS) comm-convert
|
2019-01-01 17:11:30 +01:00
|
|
|
$(KCC) -c $(COMMDIR)/rand.c -o $(COBJDIR)/rand.o
|
|
|
|
$(KCC) -c $(COMMDIR)/arith.c -o $(COBJDIR)/arith.o
|
|
|
|
$(KCC) -c $(COMMDIR)/string.c -o $(COBJDIR)/string.o
|
|
|
|
$(KCC) -c $(COMMDIR)/status.c -o $(COBJDIR)/status.o
|
|
|
|
$(KCC) -c $(COMMDIR)/memory.c -o $(COBJDIR)/memory.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
|
|
|
|
2019-01-01 17:37:58 +01:00
|
|
|
tests-comm-convert:
|
|
|
|
$(CCC) -c $(COMMDIR)/convert.c -D_NEED_ITOA -o $(COBJDIR)/itoa.o
|
|
|
|
$(CCC) -c $(COMMDIR)/convert.c -D_NEED_LTOA -o $(COBJDIR)/ltoa.o
|
|
|
|
$(CCC) -c $(COMMDIR)/convert.c -D_NEED_UTOA -o $(COBJDIR)/utoa.o
|
|
|
|
$(CCC) -c $(COMMDIR)/convert.c -D_NEED_ULTOA -o $(COBJDIR)/ultoa.o
|
|
|
|
|
|
|
|
tests: $(COMMSRCS) tests-comm-convert
|
2019-01-01 17:11:30 +01:00
|
|
|
$(CCC) -c $(COMMDIR)/rand.c -o $(COBJDIR)/rand.o
|
|
|
|
$(CCC) -c $(COMMDIR)/arith.c -o $(COBJDIR)/arith.o
|
2019-01-01 13:09:57 +01:00
|
|
|
$(CCC) -c $(COMMDIR)/string.c -o $(COBJDIR)/string.o
|
|
|
|
$(CCC) -c $(COMMDIR)/status.c -o $(COBJDIR)/status.o
|
|
|
|
$(CCC) -c $(COMMDIR)/memory.c -o $(COBJDIR)/memory.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)
|
|
|
|
|
2019-01-01 13:09:57 +01:00
|
|
|
KERNDEPS=common $(KERNDIR)/init.h $(KERNDIR)/io/terminal.h $(KERNDIR)/ke/lock.h \
|
|
|
|
$(KERNDIR)/io/ports.h $(KERNDIR)/ke/panic.h $(KERNDIR)/ke/state.h
|
2018-12-31 10:49:08 +01:00
|
|
|
|
2019-01-01 13:09:57 +01:00
|
|
|
KERNSRCS=$(KERNDIR)/init.c $(KERNDIR)/io/terminal.c $(KERNDIR)/ke/lock.c \
|
|
|
|
$(KERNDIR)/io/ports.c $(KERNDIR)/ke/panic.c $(KERNDIR)/ke/state.c
|
2018-12-31 10:49:08 +01:00
|
|
|
|
2019-01-01 13:09:57 +01:00
|
|
|
KERNOBJS=$(KOBJDIR)/init.o $(KOBJDIR)/io/terminal.o $(KOBJDIR)/ke/lock.o \
|
|
|
|
$(KOBJDIR)/io/ports.o $(KOBJDIR)/ke/panic.o $(KOBJDIR)/ke/state.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
|
2019-01-01 13:09:57 +01:00
|
|
|
$(KCC) -c $(KERNDIR)/ke/lock.c -o $(KOBJDIR)/ke/lock.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
|
|
|
|