271 lines
11 KiB
Makefile
271 lines
11 KiB
Makefile
# User sets these
|
|
CC = gcc
|
|
ASM = nasm
|
|
CURDIR = /media/6C9EE8DF9EE8A336/ctaos
|
|
|
|
# Other parameters & paths used
|
|
LSCRIPT = SysCore/objects/linker.ld
|
|
OBJ = Build
|
|
|
|
CCPARAM = -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I./SysCore/include -c
|
|
ASMPARAMobj = -f aout
|
|
ASMPARAMbin = -f bin
|
|
|
|
#.PHONY : FORCE
|
|
#FORCE :#
|
|
# @echo -e "\e[1;4m\e[36mC\e[31mT\e[32mA \e[37mOperating System v0.1\e[0"
|
|
|
|
# Build final floppy image
|
|
ctaos.img : $(OBJ)bootload.bin $(OBJ)stage2.cta $(OBJ)kernel.bin
|
|
@echo -e "\e[1;32m[ 99%]\e[0m Making floppy image"
|
|
dd bs=512 count=2880 if=/dev/zero of=ctaos.img
|
|
mkfs.msdos ctaos.img
|
|
dd bs=512 count=1 conv=notrunc if=$(OBJ)bootload.bin of=ctaos.img
|
|
sudo mkdir /media/floppy1/
|
|
sudo mount -o loop ctaos.img /media/floppy1/
|
|
sudo cp $(OBJ)stage2.cta /media/floppy1
|
|
sudo cp $(OBJ)kernel.bin /media/floppy1
|
|
sudo umount /media/floppy1/
|
|
sudo rm -r /media/floppy1/
|
|
|
|
|
|
# Build Bootloader: Stage 1
|
|
$(OBJ)bootload.bin : SysBoot/stage1/bootload.asm
|
|
echo -e "\e[1;32m[ 4%]\e[0m BOOTLOADER :: stage 1"
|
|
@$(ASM) $(ASMPARAMbin) SysBoot/stage1/bootload.asm -o $(OBJ)bootload.bin
|
|
|
|
# Build Bootloader: Stage 2
|
|
$(OBJ)stage2.cta : SysBoot/stage2/stage2.asm \
|
|
SysBoot/stage2/a20.inc \
|
|
SysBoot/stage2/bootinfo.inc \
|
|
SysBoot/stage2/common.inc \
|
|
SysBoot/stage2/fat12.inc \
|
|
SysBoot/stage2/floppy16.inc \
|
|
SysBoot/stage2/gdt.inc \
|
|
SysBoot/stage2/getdata.inc \
|
|
SysBoot/stage2/memory.inc \
|
|
SysBoot/stage2/paging.inc \
|
|
SysBoot/stage2/stdio.inc
|
|
@echo -e "\e[1;32m[ 8%]\e[0m BOOTLOADER :: stage 2"
|
|
@$(ASM) $(ASMPARAMbin) -I./SysBoot/stage2/ -o $(OBJ)stage2.cta SysBoot/stage2/stage2.asm
|
|
|
|
# Build KERNEL:
|
|
$(OBJ)kernel.bin : $(OBJ)/loader.o \
|
|
$(OBJ)/main.o \
|
|
$(OBJ)/lib-conio.o \
|
|
$(OBJ)/lib-ctype.o \
|
|
$(OBJ)/mmngr-asm.o \
|
|
$(OBJ)/mmngr-phys.o \
|
|
$(OBJ)/mmngr-virt.o \
|
|
$(OBJ)/mmngr-lib-pde.o \
|
|
$(OBJ)/mmngr-lib-pte.o \
|
|
$(OBJ)/shell.o \
|
|
$(OBJ)/lib-stdlib.o \
|
|
$(OBJ)/lib-string.o \
|
|
$(OBJ)/lib-system.o \
|
|
$(OBJ)/lib-time.o \
|
|
$(OBJ)/driver-bsod.o \
|
|
$(OBJ)/driver-cpu.o \
|
|
$(OBJ)/driver-dma.o \
|
|
$(OBJ)/driver-drivers.o \
|
|
$(OBJ)/driver-floppy.o \
|
|
$(OBJ)/driver-gdt.o \
|
|
$(OBJ)/driver-gdt-asm.o \
|
|
$(OBJ)/driver-idt.o \
|
|
$(OBJ)/driver-idt-asm.o \
|
|
$(OBJ)/driver-isrs.o \
|
|
$(OBJ)/driver-isrs-asm.o \
|
|
$(OBJ)/driver-irq.o \
|
|
$(OBJ)/driver-irq-asm.o \
|
|
$(OBJ)/driver-keyboard.o \
|
|
$(OBJ)/driver-fat.o \
|
|
$(OBJ)/driver-pic.o \
|
|
$(OBJ)/driver-pit.o \
|
|
$(OBJ)/video-vga03h.o
|
|
ld -T SysCore/link.ld
|
|
|
|
# ---------- Kernel components ---------- #
|
|
|
|
# Build assembly sources:
|
|
$(OBJ)/loader.o : SysCore/loader.asm
|
|
@ echo -e "\e[1;33m[ 9%]\e[0m Assembly kernel loader"
|
|
@$(ASM) $(ASMPARAMobj) -o $(OBJ)/loader.o SysCore/loader.asm
|
|
|
|
$(OBJ)/driver-gdt-asm.o : SysCore/drivers/cpu/gdt/gdt.asm
|
|
@echo -e "\e[1;33m[ 10%]\e[0m Assembly code for GDT"
|
|
@$(ASM) $(ASMPARAMobj) -o $(OBJ)/driver-gdt-asm.o SysCore/drivers/cpu/gdt/gdt.asm
|
|
|
|
$(OBJ)/driver-idt-asm.o : SysCore/drivers/cpu/idt/idt.asm
|
|
@echo -e "\e[1;33m[ 11%]\e[0m Assembly code for IDT"
|
|
@$(ASM) $(ASMPARAMobj) -o $(OBJ)/driver-idt-asm.o SysCore/drivers/cpu/idt/idt.asm
|
|
|
|
$(OBJ)/driver-irq-asm.o : SysCore/drivers/cpu/irq/irq.asm
|
|
@echo -e "\e[1;33m[ 12%]\e[0m Assembly code for IRQ"
|
|
@$(ASM) $(ASMPARAMobj) -o $(OBJ)/driver-irq-asm.o SysCore/drivers/cpu/irq/irq.asm
|
|
|
|
$(OBJ)/driver-isrs-asm.o : SysCore/drivers/cpu/isrs/isrs.asm
|
|
@echo -e "\e[1;33m[ 13%]\e[0m Assembly code for ISRs"
|
|
@$(ASM) $(ASMPARAMobj) -o $(OBJ)/driver-isrs-asm.o SysCore/drivers/cpu/isrs/isrs.asm
|
|
|
|
|
|
# Build MAIN function
|
|
$(OBJ)/main.o : SysCore/main.c SysCore/include/string.h \
|
|
SysCore/include/system.h SysCore/include/conio.h \
|
|
SysCore/drivers/drivers.h SysCore/include/time.h \
|
|
SysCore/include/bootinfo.h SysCore/memory/mmngr_ph.h \
|
|
SysCore/memory/mmngr_vi.h SysCore/video/vga03h.h
|
|
@echo -e "\e[1;32m[ 14%]\e[0m MAIN C Function"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/main.o SysCore/main.c
|
|
|
|
# Build SHELL
|
|
$(OBJ)/shell.o : SysCore/shell/shell.c SysCore/shell/apps.h \
|
|
SysCore/include/system.h SysCore/include/conio.h \
|
|
SysCore/drivers/drivers.h SysCore/include/time.h \
|
|
SysCore/memory/mmngr_ph.h SysCore/drivers/keyboard.h \
|
|
SysCore/drivers/cpu/cpu.h SysCore/include/drivers/floppy.h \
|
|
SysCore/drivers/filesys/fat.h
|
|
@echo -e "\e[1;34m[ 15%]\e[0m Shell"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/shell.o SysCore/shell/shell.c
|
|
|
|
# Build LIBRARIES
|
|
$(OBJ)/lib-conio.o : SysCore/lib/conio.c \
|
|
SysCore/include/drivers/keyboard.h SysCore/include/stdarg.h \
|
|
SysCore/include/conio.h SysCore/include/stdlib.h \
|
|
SysCore/include/string.h SysCore/include/ctype.h \
|
|
SysCore/memory/mmngr_ph.h
|
|
@echo -e "\e[1;34m[ 16%]\e[0m Libraries: conio"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/lib-conio.o SysCore/lib/conio.c
|
|
|
|
$(OBJ)/lib-ctype.o : SysCore/lib/ctype.c SysCore/include/ctype.h
|
|
@echo -e "\e[1;34m[ 17%]\e[0m Libraries: ctype"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/lib-ctype.o SysCore/lib/ctype.c
|
|
|
|
$(OBJ)/lib-stdlib.o : SysCore/lib/stdlib.c SysCore/include/stdlib.h \
|
|
SysCore/include/ctype.h
|
|
@echo -e "\e[1;34m[ 18%]\e[0m Libraries: stdlib"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/lib-stdlib.o SysCore/lib/stdlib.c
|
|
|
|
$(OBJ)/lib-string.o : SysCore/lib/string.c SysCore/include/string.h
|
|
@echo -e "\e[1;32m[ 19%]\e[0m Libraries: string"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/lib-string.o SysCore/lib/string.c
|
|
|
|
$(OBJ)/lib-system.o : SysCore/lib/system.c SysCore/include/system.h
|
|
@echo -e "\e[1;34m[ 20%]\e[0m Libraries: system"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/lib-system.o SysCore/lib/system.c
|
|
|
|
$(OBJ)/lib-time.o : SysCore/lib/time.c SysCore/include/time.h \
|
|
SysCore/include/system.h
|
|
@echo -e "\e[1;34m[ 21%]\e[0m Libraries: time"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/lib-time.o SysCore/lib/time.c
|
|
|
|
|
|
# Build Memory Manager
|
|
$(OBJ)/mmngr-asm.o : SysCore/memory/mmngr.asm
|
|
@echo -e "\e[1;36m[ 22%]\e[0m Memory manager assembly code"
|
|
@$(ASM) $(ASMPARAMobj) -o $(OBJ)/mmngr-asm.o SysCore/memory/mmngr.asm
|
|
|
|
$(OBJ)/mmngr-phys.o : SysCore/memory/mmngr_ph.c SysCore/memory/mmngr_ph.h
|
|
@echo -e "\e[1;36m[ 22%]\e[0m Physical memory manager"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/mmngr-phys.o SysCore/memory/mmngr_ph.c
|
|
|
|
$(OBJ)/mmngr-virt.o : SysCore/memory/mmngr_vi.c SysCore/memory/mmngr_vi.h \
|
|
SysCore/memory/mmngr_ph.h
|
|
@echo -e "\e[1;36m[ 23%]\e[0m Virtual memory manager"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/mmngr-virt.o SysCore/memory/mmngr_vi.c
|
|
|
|
$(OBJ)/mmngr-lib-pde.o : SysCore/memory/lib/pde.c SysCore/memory/lib/pde.h
|
|
@echo -e "\e[1;36m[ 24%]\e[0m Memory manager libraries: PDE"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/mmngr-lib-pde.o SysCore/memory/lib/pde.c
|
|
|
|
$(OBJ)/mmngr-lib-pte.o : SysCore/memory/lib/pte.c SysCore/memory/lib/pte.h
|
|
@echo -e "\e[1;36m[ 25%]\e[0m Memory manager libraries: PTE"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/mmngr-lib-pte.o SysCore/memory/lib/pte.c
|
|
|
|
|
|
# Build drivers
|
|
$(OBJ)/driver-drivers.o : SysCore/drivers/drivers.c SysCore/include/system.h \
|
|
SysCore/drivers/cpu/cpu.h SysCore/drivers/clock/clock.h \
|
|
SysCore/drivers/floppy/floppy.h SysCore/include/drivers/keyboard.h
|
|
@echo -e "\e[1;35m[ 26%]\e[0m Driver manager"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/driver-drivers.o SysCore/drivers/drivers.c
|
|
|
|
$(OBJ)/driver-bsod.o : SysCore/drivers/BSOD.c SysCore/include/system.h \
|
|
SysCore/include/conio.h
|
|
@echo -e "\e[1;35m[ 27%]\e[0m Kernel panic screen"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/driver-bsod.o SysCore/drivers/BSOD.c
|
|
|
|
$(OBJ)/driver-cpu.o : SysCore/drivers/cpu/cpu.c SysCore/include/system.h \
|
|
SysCore/drivers/cpu/cpu.h SysCore/drivers/cpu/gdt/gdt.h \
|
|
SysCore/drivers/cpu/idt/idt.h SysCore/drivers/cpu/irq/irq.h \
|
|
SysCore/drivers/cpu/isrs/isrs.h
|
|
@echo -e "\e[1;35m[ 28%]\e[0m CPU modules"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/driver-cpu.o SysCore/drivers/cpu/cpu.c
|
|
|
|
$(OBJ)/driver-gdt.o : SysCore/drivers/cpu/gdt/gdt.c SysCore/drivers/cpu/gdt/gdt.h
|
|
@echo -e "\e[1;35m[ 29%]\e[0m Global descriptor table"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/driver-gdt.o SysCore/drivers/cpu/gdt/gdt.c
|
|
|
|
$(OBJ)/driver-idt.o : SysCore/drivers/cpu/idt/idt.c SysCore/drivers/cpu/idt/idt.h \
|
|
SysCore/include/system.h
|
|
@echo -e "\e[1;35m[ 30%]\e[0m Interrupt descriptor table"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/driver-idt.o SysCore/drivers/cpu/idt/idt.c
|
|
|
|
$(OBJ)/driver-isrs.o : SysCore/drivers/cpu/isrs/isrs.c SysCore/drivers/cpu/isrs/isrs.h \
|
|
SysCore/drivers/cpu/idt/idt.h SysCore/include/system.h \
|
|
SysCore/include/conio.h
|
|
@echo -e "\e[1;35m[ 31%]\e[0m Interrupt service routines"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/driver-isrs.o SysCore/drivers/cpu/isrs/isrs.c
|
|
|
|
|
|
$(OBJ)/driver-irq.o : SysCore/drivers/cpu/irq/irq.c SysCore/drivers/cpu/irq/irq.h \
|
|
SysCore/include/system.h SysCore/drivers/cpu/idt/idt.h \
|
|
SysCore/drivers/cpu/pic/pic.h
|
|
@echo -e "\e[1;35m[ 32%]\e[0m Interrupt requests"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/driver-irq.o SysCore/drivers/cpu/irq/irq.c
|
|
|
|
$(OBJ)/driver-pic.o : SysCore/drivers/cpu/irq/pic.c SysCore/drivers/cpu/irq/pic.h \
|
|
SysCore/include/system.h
|
|
@echo -e "\e[1;35m[ 33%]\e[0m Programmable interrupt controller"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/driver-pic.o SysCore/drivers/cpu/irq/pic.c
|
|
|
|
$(OBJ)/driver-pit.o : SysCore/drivers/clock/pit.c SysCore/drivers/clock/clock.h \
|
|
SysCore/include/system.h SysCore/include/time.h
|
|
@echo -e "\e[1;35m[ 34%]\e[0m Programmable interval timer"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/driver-pit.o SysCore/drivers/clock/pic.c
|
|
|
|
$(OBJ)/driver-keyboard.o : SysCore/drivers/keyboard/keyboard.c SysCore/include/system.h \
|
|
SysCore/include/drivers/keyboard.h
|
|
@echo -e "\e[1;35m[ 35%]\e[0m Keyboard"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/driver-pic.o SysCore/drivers/cpu/irq/pic.c
|
|
|
|
$(OBJ)/driver-dma.o : SysCore/drivers/floppy/dma.c SysCore/drivers/floppy/dma.h \
|
|
SysCore/include/system.h
|
|
@echo -e "\e[1;35m[ 36%]\e[0m DMA Controller"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/driver-dma.o SysCore/drivers/floppy/dma.c
|
|
|
|
$(OBJ)/driver-floppy.o : SysCore/drivers/floppy/floppy.c SysCore/drivers/floppy/dma.h \
|
|
SysCore/include/system.h SysCore/include/time.h \
|
|
SysCore/include/conio.h SysCore/drivers/floppy/storage.h \
|
|
SysCore/drivers/floppy/floppy.h
|
|
@echo -e "\e[1;35m[ 37%]\e[0m FDC Controller"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/driver-floppy.o SysCore/drivers/floppy/floppy.c
|
|
|
|
# TODO: add SysCore/drivers/filesys/vfs.h
|
|
$(OBJ)/driver-fat.o : SysCore/drivers/filesys/fat.c SysCore/drivers/filesys/fat.h \
|
|
SysCore/drivers/floppy/floppy.h SysCore/include/conio.h
|
|
@echo -e "\e[1;35m[ 38%]\e[0m File system"
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/driver-fat.o SysCore/drivers/floppy/fat.c
|
|
|
|
# TODO: add vfs.c
|
|
|
|
# TODO: add colors
|
|
$(OBJ)/video-vga03h.o : SysCore/video/vga03h.c SysCore/include/conio.h \
|
|
SysCore/include/system.h
|
|
@$(CC) $(CCPARAM) -o $(OBJ)/video-vga03h.o SysCore/video/vga03h.c
|
|
|
|
|
|
.PHONY : clean
|
|
clean:
|
|
- rm ctaos.img
|
|
rm $(OBJ)*.*
|