1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00
os-k/Makefile

97 lines
3.8 KiB
Makefile

#=----------------------------------------------------------------------------=#
# GNU GPL OS/K #
# #
# Desc: Project Makefile #
# #
# #
# Copyright © 2018-2019 The OS/K Team #
# #
# This file is part of OS/K. #
# #
# OS/K is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# any later version. #
# #
# OS/K is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY# without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with OS/K. If not, see <https://www.gnu.org/licenses/>. #
#=----------------------------------------------------------------------------=#
kernel:
cpp ./Makefile.in > build/Makefile.out
python ./build/idttool.py
make kernel -f build/Makefile.out.2
rm build/Makefile.out build/Makefile.out.2
kernel-asm:
cpp -D_TO_ASM ./Makefile.in > build/Makefile.out
python ./build/idttool.py
make kernel -f build/Makefile.out.2
rm build/Makefile.out build/Makefile.out.2
tests:
cpp -D_TESTS ./Makefile.in > build/Makefile.out
python ./build/idttool.py
make tests -f build/Makefile.out.2
rm build/Makefile.out build/Makefile.out.2
#Programs
ASM=nasm
ASMFLAGS=
BOOTFLAGS=-f bin
#Folders
MBRDIR=boot/grub
LOADERDIR=boot/loader
OBJDIR=build/obj
BINDIR=build/bin
#Color codes
CL='\033[0;32m'
CL2='\033[1;31m'
CL3='\033[0m'
NC='\033[1;37m'
boot.mbr: $(BINDIR)/disk.img $(MBRDIR)/grub.cfg
@mkdir -p $(BINDIR)/disk
@echo ${CL2}[boot.mbr]${NC} Installing MBR on image...${CL3}
@$(MBRDIR)/grub-install.sh $(BINDIR)/disk.img $(BINDIR)/disk $(MBRDIR)/grub.cfg
@echo ${CL2}[boot.mbr]${CL} OK${CL3}
@rmdir $(BINDIR)/disk
boot.loader.asm: $(LOADERDIR)/loader.asm
@echo ${CL2}[boot.loader.asm]${NC} Making loader.bin...${CL3}
@$(ASM) $(BOOTFLAGS) $(LOADERDIR)/loader.asm -o $(OBJDIR)/boot/loader.bin > /dev/null
@echo ${CL2}[boot.loader.asm]${CL} OK${CL3}
loader: boot.loader.asm
@mkdir -p $(BINDIR)/disk
@echo ${CL2}[loader]${NC} Constructing kernel loader...${CL3}
@$(MBRDIR)/mount.sh $(BINDIR)/disk.img $(BINDIR)/disk
@cp $(OBJDIR)/boot/loader.bin $(BINDIR)/disk/boot/loader.bin
@$(MBRDIR)/umount.sh $(BINDIR)/disk
@echo ${CL2}[loader]${CL} OK${CL3}
@rmdir $(BINDIR)/disk
make_disk:
@echo ${CL2}[make_disk]${NC} Constructing disk image...${CL3}
@$(MBRDIR)/create_disk.sh $(BINDIR)/disk.img
@echo ${CL2}[make_disk]${CL} OK${CL3}
testloader: loader
@qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset &
@ndisasm $(OBJDIR)/boot/loader.bin -b 32 > loader_dism.asm
boot: make_disk boot.mbr loader
@echo ${CL2}[[boot]]${CL} Terminated without error.${CL3}
all: boot kernel
@echo ${CL2}[[all]]${CL} Terminated without error.${CL3}