<commit_before>ARCH=i686-elf
TEST_CC=clang
GCOV=gcov
GRUB_MKRESCUE=grub2-mkrescue
CC=compiler/$(ARCH)/bin/$(ARCH)-gcc
AS=compiler/$(ARCH)/bin/$(ARCH)-as
ASFLAGS=-g
CFLAGS= -std=c11 -ffreestanding -O0 -Wall -Wextra -g -I ./include -I tlibc/include -D ARCH_X86
TEST_CFLAGS= -std=c11 -O0 -Wall -Wextra -g -I ./include -coverage -Wno-format -D ARCH_USERLAND
QEMU_FLAGS= -m 1G -serial file:build/qemu-serial.log
VB=virtualbox
VBM=VBoxManage

all: bootloader-x86 kernel link-x86

tests: build libk-tests

run-tests: tests
	./build/tests/kmem
	${GCOV} kmem.gcno
	./build/tests/physical_allocator
	${GCOV} physical_allocator.gcno

bootloader-x86: build
	${AS} kernel/arch/x86/boot.s -o build/boot.o ${ASFLAGS}

libk: build serial
	${CC} -c kernel/libk/kmem.c -o build/kmem.o  ${CFLAGS}
	${CC} -c kernel/libk/kabort.c -o build/kabort.o  ${CFLAGS}
	${CC} -c kernel/libk/kputs.c -o build/kputs.o  ${CFLAGS}
	${CC} -c kernel/libk/klog.c -o build/klog.o  ${CFLAGS}
	${CC} -c kernel/libk/physical_allocator.c -o build/physical_allocator.o  ${CFLAGS}

libk-tests:
	${TEST_CC} kernel/libk/tests/stubs.c kernel/libk/tests/kmem.c kernel/libk/kmem.c  -o build/tests/kmem ${TEST_CFLAGS}
	${TEST_CC} kernel/libk/tests/stubs.c kernel/libk/tests/physical_allocator.c -o build/tests/physical_allocator ${TEST_CFLAGS}

io: build
	#${CC} -c kernel/arch/x86/io.c -o build/io.o ${CFLAGS}

kernel: libk terminal gdt-x86 idt-x86 tlibc build keyboard timer paging-x86 io
	${CC} -c kernel/kernel.c -o build/kernel.o  ${CFLAGS}

link-x86: build
	${CC} -T kernel/arch/x86/linker.ld -o build/truthos.bin -ffreestanding -O0 -nostdlib build/*.o -lgcc

terminal: build
	${CC} -c kernel/drivers/terminal.c -o build/terminal.o ${CFLAGS}

timer: build
	${AS} -c kernel/drivers/timer.s -o build/timers.o ${ASFLAGS}
	${CC} -c kernel/drivers/timer.c -o build/timerc.o ${CFLAGS}

paging-x86: build
	${AS} -c kernel/arch/x86/paging.s -o build/pagings.o ${ASFLAGS}
	${CC} -c kernel/arch/x86/paging.c -o build/pagingc.o ${CFLAGS}


gdt-x86: build
	${CC} -c kernel/arch/x86/gdt.c -o build/gdtc.o ${CFLAGS}
	${AS} kernel/arch/x86/gdt.s -o build/gdts.o ${ASFLAGS}

idt-x86: build keyboard
	${CC} -c kernel/arch/x86/idt.c build/keyboard.o -o build/idtc.o ${CFLAGS}
	${AS} kernel/arch/x86/idt.s -o build/idts.o ${ASFLAGS}


serial: build
	${CC} -c kernel/drivers/serial_port.c -o build/serial_port.o ${CFLAGS}
	${AS} kernel/drivers/serial_port.s -o build/_serial_port.o ${ASFLAGS}

keyboard: build
	${CC} -c kernel/drivers/keyboard.c -o build/keyboard.o ${CFLAGS}

tlibc: build
	${CC} -c tlibc/string/string.c -o build/tlibc.o ${CFLAGS}

start:
	qemu-system-i386 -kernel build/truthos.bin ${QEMU_FLAGS}

start-log:
	qemu-system-i386 -kernel build/truthos.bin -d in_asm,cpu_reset,exec,int,ioport,guest_errors,pcall -no-reboot ${QEMU_FLAGS} &> qemu.log

start-debug:
	qemu-system-i386 -S -s -kernel build/truthos.bin ${QEMU_FLAGS} -curses

build:
	mkdir build<commit_msg>Remove unused assembly file from Makefile<commit_after>ARCH=i686-elf
TEST_CC=clang
GCOV=gcov
GRUB_MKRESCUE=grub2-mkrescue
CC=compiler/$(ARCH)/bin/$(ARCH)-gcc
AS=compiler/$(ARCH)/bin/$(ARCH)-as
ASFLAGS=-g
CFLAGS= -std=c11 -ffreestanding -O0 -Wall -Wextra -g -I ./include -I tlibc/include -D ARCH_X86
TEST_CFLAGS= -std=c11 -O0 -Wall -Wextra -g -I ./include -coverage -Wno-format -D ARCH_USERLAND
QEMU_FLAGS= -m 1G -serial file:build/qemu-serial.log
VB=virtualbox
VBM=VBoxManage

all: bootloader-x86 kernel link-x86

tests: build libk-tests

run-tests: tests
	./build/tests/kmem
	${GCOV} kmem.gcno
	./build/tests/physical_allocator
	${GCOV} physical_allocator.gcno

bootloader-x86: build
	${AS} kernel/arch/x86/boot.s -o build/boot.o ${ASFLAGS}

libk: build serial
	${CC} -c kernel/libk/kmem.c -o build/kmem.o  ${CFLAGS}
	${CC} -c kernel/libk/kabort.c -o build/kabort.o  ${CFLAGS}
	${CC} -c kernel/libk/kputs.c -o build/kputs.o  ${CFLAGS}
	${CC} -c kernel/libk/klog.c -o build/klog.o  ${CFLAGS}
	${CC} -c kernel/libk/physical_allocator.c -o build/physical_allocator.o  ${CFLAGS}

libk-tests:
	${TEST_CC} kernel/libk/tests/stubs.c kernel/libk/tests/kmem.c kernel/libk/kmem.c  -o build/tests/kmem ${TEST_CFLAGS}
	${TEST_CC} kernel/libk/tests/stubs.c kernel/libk/tests/physical_allocator.c -o build/tests/physical_allocator ${TEST_CFLAGS}

io: build
	#${CC} -c kernel/arch/x86/io.c -o build/io.o ${CFLAGS}

kernel: libk terminal gdt-x86 idt-x86 tlibc build keyboard timer paging-x86 io
	${CC} -c kernel/kernel.c -o build/kernel.o  ${CFLAGS}

link-x86: build
	${CC} -T kernel/arch/x86/linker.ld -o build/truthos.bin -ffreestanding -O0 -nostdlib build/*.o -lgcc

terminal: build
	${CC} -c kernel/drivers/terminal.c -o build/terminal.o ${CFLAGS}

timer: build
	${AS} -c kernel/drivers/timer.s -o build/timers.o ${ASFLAGS}
	${CC} -c kernel/drivers/timer.c -o build/timerc.o ${CFLAGS}

paging-x86: build
	${AS} -c kernel/arch/x86/paging.s -o build/pagings.o ${ASFLAGS}
	${CC} -c kernel/arch/x86/paging.c -o build/pagingc.o ${CFLAGS}


gdt-x86: build
	${CC} -c kernel/arch/x86/gdt.c -o build/gdtc.o ${CFLAGS}
	${AS} kernel/arch/x86/gdt.s -o build/gdts.o ${ASFLAGS}

idt-x86: build keyboard
	${CC} -c kernel/arch/x86/idt.c build/keyboard.o -o build/idtc.o ${CFLAGS}
	${AS} kernel/arch/x86/idt.s -o build/idts.o ${ASFLAGS}


serial: build
	${CC} -c kernel/drivers/serial_port.c -o build/serial_port.o ${CFLAGS}

keyboard: build
	${CC} -c kernel/drivers/keyboard.c -o build/keyboard.o ${CFLAGS}

tlibc: build
	${CC} -c tlibc/string/string.c -o build/tlibc.o ${CFLAGS}

start:
	qemu-system-i386 -kernel build/truthos.bin ${QEMU_FLAGS}

start-log:
	qemu-system-i386 -kernel build/truthos.bin -d in_asm,cpu_reset,exec,int,ioport,guest_errors,pcall -no-reboot ${QEMU_FLAGS} &> qemu.log

start-debug:
	qemu-system-i386 -S -s -kernel build/truthos.bin ${QEMU_FLAGS} -curses

build:
	mkdir build
{'fraction_non_alphanumeric': 0.16894109518051478, 'fraction_numerical': 0.021074451546035586, 'mean_word_length': 3.825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5113979', 'n_tokens_mistral': 2660, 'n_tokens_neox': 2538, 'n_words': 525}