#----------------------------------------------------------------------------# # GNU GPL OS/K # # # # Authors: spectral` # # NeoX # # # # Desc: Project Makefile # #----------------------------------------------------------------------------# CCNAME="/opt/cross-cc/bin/x86_64-elf-gcc" CC2NAME=gcc # compiler for testing CLDSCR=-T kernel.ld CWARNS= -pedantic -Wall -Wextra -Werror CFLAGS=-nostdlib -ffreestanding -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2 CINCLUDES=-I./kaleid CDEFINES= CC=$(CCNAME) $(CWARNS) $(CFLAGS) $(CDEFINES) $(CINCLUDES) KCC=$(CC) -D_KALEID_KERNEL ASM=nasm ASMFLAGS= BOOTFLAGS=-f bin BINDIR=../bin OBJDIR=../obj BOOTDIR=boot COMMDIR=kaleid/common KERNDIR=kaleid/kernel SYSTDIR=kaleid/system LINXDIR=kaleid/linux all: bootloader boot.mbr.s: $(BOOTDIR)/mbr.s $(BOOTDIR)/mbr.inc $(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 cp $(OBJDIR)/boot/mbr.bin $(BINDIR)/mbr.bin cp $(OBJDIR)/boot/loader.bin $(BINDIR)/loader.bin #----------------------------------------------------------------------------# # 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) LOBJDIR=$(OBJDIR)/$(LINXDIR) COMMDEPS=$(COMMDIR)/common.h $(COMMDIR)/assert.h $(COMMDIR)/atomic.h $(COMMDIR)/config.h \ $(COMMDIR)/status.h COMMOBJS=$(COBJDIR)/lib/string.o $(COBJDIR)/lib/status.o 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 CCC=$(CC2NAME) $(CWARNS) $(CDEFINES) $(CINCLUDES) common-test: $(CCC) -c $(COMMDIR)/lib/string.c -o $(COBJDIR)/lib/string.o $(CCC) -c $(COMMDIR)/lib/status.c -o $(COBJDIR)/lib/status.o $(CCC) -c $(LINXDIR)/test-common.c -o $(LOBJDIR)/test-common.o $(CCC) $(COMMOBJS) $(LOBJDIR)/test-common.o -o $(BINDIR)/kaleid-common.elf #----------------------------------------------------------------------------# # KERNEL MAKEFILE KOBJDIR=$(OBJDIR)/$(KERNDIR) KERNDEPS=common $(KERNDIR)/init.h $(KERNDIR)/io/terminal.h $(KERNDIR)/io/ports.h $(KERNDIR)/ke/panic.h KERNSRCS=$(KERNDIR)/init.c $(KERNDIR)/ke/panic.c $(KERNDIR)/io/ports.c $(KERNDIR)/io/terminal.c KERNOBJS=$(KOBJDIR)/init.o $(KOBJDIR)/ke/panic.o $(KOBJDIR)/io/ports.o $(KOBJDIR)/io/terminal.o kernel: common $(KERNSRCS) $(KCC) -c $(KERNDIR)/init.c -o $(KOBJDIR)/init.o $(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 #----------------------------------------------------------------------------#