2022-12-25 01:43:45 -05:00
|
|
|
.phony: run clean all debug user_programs_clean user_programs fatcopy_clean
|
2022-11-18 21:27:35 -05:00
|
|
|
|
2022-12-19 23:55:10 -05:00
|
|
|
C_SRC=$(wildcard src/*/*/*.c src/*/*.c src/*.c)
|
|
|
|
ASM_SRC=$(wildcard src/*/*/*.asm src/*/*.asm)
|
|
|
|
O_FILES=$(C_SRC:src/%.c=build/%.o)
|
|
|
|
O_FILES+=$(ASM_SRC:src/%.asm=build/%.asm.o)
|
|
|
|
|
|
|
|
#kernel.asm.o must be first, then the rest
|
|
|
|
FILES=build/kernel.asm.o $(O_FILES)
|
|
|
|
|
2022-12-23 15:03:33 -05:00
|
|
|
INCLUDES = -Isrc -Isrc/libk
|
|
|
|
FLAGS = -D__KERNEL__ -g -ffreestanding -falign-jumps -falign-functions -falign-labels -falign-loops -fstrength-reduce -fomit-frame-pointer -finline-functions -Wno-unused-function -fno-builtin -Werror -Wno-unused-label -Wno-cpp -Wno-unused-parameter -nostdlib -nostartfiles -nodefaultlibs -Wall -O0 -Iinc -std=gnu99
|
2022-12-19 23:55:10 -05:00
|
|
|
|
|
|
|
CC=i686-elf-gcc
|
|
|
|
LD=i686-elf-ld
|
|
|
|
NASM=nasm
|
|
|
|
QEMU=qemu-system-i386
|
|
|
|
GDB=gdb
|
|
|
|
|
2022-12-25 01:43:45 -05:00
|
|
|
all: clean fatcopy_clean run
|
2022-11-18 21:27:35 -05:00
|
|
|
|
2022-12-23 09:28:39 -05:00
|
|
|
bin/os.bin: bin/boot.bin bin/kernel.bin hello.txt user_programs external/fatcopy/fatcopy
|
2022-12-10 23:55:00 -05:00
|
|
|
mkdir -p bin
|
2022-11-18 21:27:35 -05:00
|
|
|
rm -f bin/os.bin
|
|
|
|
dd if=bin/boot.bin >> bin/os.bin
|
|
|
|
dd if=bin/kernel.bin >> bin/os.bin
|
2022-11-24 05:09:59 -05:00
|
|
|
dd if=/dev/zero bs=1048576 count=16 >> bin/os.bin
|
2022-12-23 09:28:39 -05:00
|
|
|
./external/fatcopy/fatcopy bin/os.bin hello.txt hello.txt
|
|
|
|
./external/fatcopy/fatcopy bin/os.bin programs/blank/blank.elf blank.elf
|
|
|
|
./external/fatcopy/fatcopy bin/os.bin programs/shell/shell.elf shell.elf
|
2022-12-25 01:43:45 -05:00
|
|
|
./external/fatcopy/fatcopy bin/os.bin programs/stdlib/testlib.elf testlib.elf
|
2022-12-23 09:28:39 -05:00
|
|
|
|
2022-12-25 01:43:45 -05:00
|
|
|
external/fatcopy/configure:
|
2022-12-23 09:28:39 -05:00
|
|
|
cd external/fatcopy && autoreconf -iv
|
2022-12-25 01:43:45 -05:00
|
|
|
|
|
|
|
external/fatcopy/Makefile:
|
2022-12-23 09:28:39 -05:00
|
|
|
cd external/fatcopy && ./configure
|
2022-12-25 01:43:45 -05:00
|
|
|
|
|
|
|
external/fatcopy/fatcopy:
|
|
|
|
cd external/fatcopy && $(MAKE)
|
|
|
|
|
|
|
|
fatcopy_clean:
|
|
|
|
cd external/fatcopy && $(MAKE) clean
|
2022-11-18 21:27:35 -05:00
|
|
|
|
|
|
|
bin/kernel.bin: $(FILES)
|
2022-12-10 23:55:00 -05:00
|
|
|
mkdir -p bin
|
2022-12-19 23:55:10 -05:00
|
|
|
$(LD) -g -relocatable $(FILES) -o build/kernelfull.o
|
|
|
|
$(CC) $(FLAGS) -T src/linker.ld -o bin/kernel.bin -ffreestanding -O0 -nostdlib build/kernelfull.o
|
2022-11-17 04:56:48 -05:00
|
|
|
|
2022-12-19 23:55:10 -05:00
|
|
|
bin/boot.bin: boot/boot.asm
|
2022-12-10 23:55:00 -05:00
|
|
|
mkdir -p bin
|
2022-12-19 23:55:10 -05:00
|
|
|
$(NASM) -f bin $< -o $@
|
2022-11-21 05:18:03 -05:00
|
|
|
|
2022-12-19 23:55:10 -05:00
|
|
|
build/%.o: src/%.c
|
|
|
|
mkdir -p $(dir $@)
|
|
|
|
$(CC) $(INCLUDES) $(FLAGS) -I$(dir $<) -c $< -o $@
|
2022-11-24 05:09:59 -05:00
|
|
|
|
|
|
|
build/fs/fat/fat16.o: src/fs/fat/fat16.c
|
|
|
|
mkdir -p build/fs/fat
|
2022-12-19 23:55:10 -05:00
|
|
|
$(CC) $(INCLUDES) $(FLAGS) -Isrc/fs -Isrc/fs/fat -c $< -o $@
|
2022-11-26 20:12:33 -05:00
|
|
|
|
2023-01-15 01:26:19 -05:00
|
|
|
build/video/bga/bga.o: src/video/bga/bga.c
|
|
|
|
mkdir -p build/video/bga
|
|
|
|
$(CC) $(INCLUDES) $(FLAGS) -Isrc/video -Isrc/video/bga -c $< -o $@
|
|
|
|
|
2022-11-28 23:31:30 -05:00
|
|
|
clean: user_programs_clean
|
2022-12-10 23:55:00 -05:00
|
|
|
rm -rf bin
|
|
|
|
rm -rf build
|
2022-11-18 21:27:35 -05:00
|
|
|
|
2022-12-19 23:55:10 -05:00
|
|
|
build/%.asm.o: src/%.asm
|
|
|
|
mkdir -p $(dir $@)
|
|
|
|
$(NASM) -f elf -g $< -o $@
|
2022-11-28 23:31:30 -05:00
|
|
|
|
2022-11-18 21:27:35 -05:00
|
|
|
run: bin/os.bin
|
2022-12-19 23:55:10 -05:00
|
|
|
$(QEMU) -hda bin/os.bin
|
2022-11-17 04:56:48 -05:00
|
|
|
|
2022-11-24 05:09:59 -05:00
|
|
|
debug: bin/os.bin debug.gdb
|
2022-12-19 23:55:10 -05:00
|
|
|
$(GDB) --command=debug.gdb
|
2022-11-28 23:31:30 -05:00
|
|
|
|
|
|
|
user_programs:
|
2022-12-10 23:55:00 -05:00
|
|
|
cd programs/stdlib && $(MAKE) all
|
2022-11-28 23:31:30 -05:00
|
|
|
cd programs/blank && $(MAKE) all
|
2022-12-11 22:09:38 -05:00
|
|
|
cd programs/shell && $(MAKE) all
|
2022-11-28 23:31:30 -05:00
|
|
|
|
|
|
|
user_programs_clean:
|
2022-12-10 23:55:00 -05:00
|
|
|
cd programs/stdlib && $(MAKE) clean
|
2022-11-28 23:31:30 -05:00
|
|
|
cd programs/blank && $(MAKE) clean
|
2022-12-11 22:09:38 -05:00
|
|
|
cd programs/shell && $(MAKE) clean
|