#----------------------------------------------------------------------------# # GNU GPL OS/K # # # # Authors: spectral` # # NeoX # # # # Desc: Project Makefile # #----------------------------------------------------------------------------# CCNAME="/opt/cross-cc/bin/x86_64-elf-gcc" CC2NAME=gcc COPTIM=-O2 CLDSCR=-T kernel.ld CWARNS=-pedantic -Wall -Wextra -Werror CINCLUDES=-isystem./kaleid/include CDEFINES= CFLAGS1=-nostdlib -ffreestanding -mcmodel=large CFLAGS2=-mno-red-zone -mno-mmx -mno-sse -mno-sse2 CFLAGS=$(CFLAGS1) $(CFLAGS2) CC=$(CCNAME) $(COPTIM) $(CWARNS) $(CFLAGS) $(CDEFINES) $(CINCLUDES) KCC=$(CC) -D_OSK_SOURCE -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/common/test INCDIR=kaleid/include all: bootloader kernel 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)/stdlib.h $(KERNDIR)/config.h COMMDEPS=$(INCDIR)/kaleid.h $(INCDIR)/kaldefs.h $(INCDIR)/kaltypes.h \ $(INCDIR)/kalmask.h $(INCDIR)/kalmask.h $(INCDIR)/kalassrt.h COMMSRCS=$(COMMDIR)/string.c $(COMMDIR)/status.c \ $(COMMDIR)/convert.c $(COMMDIR)/memory.c COMMOBJS=$(COBJDIR)/string.o $(COBJDIR)/status.o \ $(COBJDIR)/convert.o $(COBJDIR)/memory.o common: $(COMMDEPS) $(COMMSRCS) $(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 $(KCC) -c $(COMMDIR)/convert.c -o $(COBJDIR)/convert.o CCC=$(CC2NAME) $(COPTIM) $(CWARNS) $(CINCLUDES) test-common: $(COMMSRCS) $(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 $(CCC) -c $(COMMDIR)/convert.c -o $(COBJDIR)/convert.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)/ke/lock.h \ $(KERNDIR)/io/ports.h $(KERNDIR)/ke/panic.h $(KERNDIR)/ke/state.h KERNSRCS=$(KERNDIR)/init.c $(KERNDIR)/io/terminal.c $(KERNDIR)/ke/lock.c \ $(KERNDIR)/io/ports.c $(KERNDIR)/ke/panic.c $(KERNDIR)/ke/state.c KERNOBJS=$(KOBJDIR)/init.o $(KOBJDIR)/io/terminal.o $(KOBJDIR)/ke/lock.o \ $(KOBJDIR)/io/ports.o $(KOBJDIR)/ke/panic.o $(KOBJDIR)/ke/state.o kernel: common $(KERNSRCS) $(KCC) -c $(KERNDIR)/init.c -o $(KOBJDIR)/init.o $(KCC) -c $(KERNDIR)/ke/lock.c -o $(KOBJDIR)/ke/lock.o $(KCC) -c $(KERNDIR)/ke/state.c -o $(KOBJDIR)/ke/state.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 #----------------------------------------------------------------------------#