108 lines
3.1 KiB
Makefile
108 lines
3.1 KiB
Makefile
|
//----------------------------------------------------------------------------#
|
||
|
// GNU GPL OS/K #
|
||
|
// #
|
||
|
// Authors: spectral` #
|
||
|
// NeoX #
|
||
|
// #
|
||
|
// Desc: Project Makefile #
|
||
|
//----------------------------------------------------------------------------#
|
||
|
|
||
|
// The madman's Makefile
|
||
|
#include "preproc.h"
|
||
|
|
||
|
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) $(SFLAG)
|
||
|
|
||
|
CC=$(CCNAME) $(COPTIM) $(CWARNS) $(CFLAGS) $(CDEFINES) $(CINCLUDES)
|
||
|
|
||
|
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)
|
||
|
|
||
|
COMMOBJS=COBJ5(string,status,rand,memory,arith) COBJ4(itoa,ltoa,utoa,ultoa)
|
||
|
|
||
|
TCC=$(CC2NAME) $(COPTIM) $(CWARNS) $(CINCLUDES)
|
||
|
KCC=$(CC) -D_OSK_SOURCE -D_KALEID_KERNEL
|
||
|
|
||
|
comm-convert:
|
||
|
COMPILE_CONVRT(itoa) -D_NEED_ITOA
|
||
|
COMPILE_CONVRT(ltoa) -D_NEED_LTOA
|
||
|
COMPILE_CONVRT(utoa) -D_NEED_UTOA
|
||
|
COMPILE_CONVRT(ultoa) -D_NEED_ULTOA
|
||
|
|
||
|
common: comm-convert
|
||
|
COMPILE_COMMON(rand)
|
||
|
COMPILE_COMMON(arith)
|
||
|
COMPILE_COMMON(string)
|
||
|
COMPILE_COMMON(status)
|
||
|
COMPILE_COMMON(memory)
|
||
|
|
||
|
tests: common
|
||
|
$(TCC) -c $(LINXDIR)/test-common.c -o $(LOBJDIR)/test-common.o
|
||
|
$(TCC) $(COMMOBJS) $(LOBJDIR)/test-common.o -o $(BINDIR)/kaleid-common.elf
|
||
|
|
||
|
//----------------------------------------------------------------------------#
|
||
|
// KERNEL MAKEFILE
|
||
|
|
||
|
KOBJDIR=$(OBJDIR)/$(KERNDIR)
|
||
|
|
||
|
KERNOBJS=KOBJ5(init,ke/lock,ke/panic,ke/state,io/ports) KOBJ1(io/terminal)
|
||
|
|
||
|
kernel: common
|
||
|
COMPILE_KERNEL(init)
|
||
|
COMPILE_KERNEL(ke/lock)
|
||
|
COMPILE_KERNEL(ke/state)
|
||
|
COMPILE_KERNEL(ke/panic)
|
||
|
COMPILE_KERNEL(io/ports)
|
||
|
COMPILE_KERNEL(io/terminal)
|
||
|
LINK_KERNEL(kaleid-kernel.elf)
|
||
|
|
||
|
//----------------------------------------------------------------------------#
|
||
|
|