

gamarjoba: gamarjoba.asm
	nasm -f elf64 -o gamarjoba.o gamarjoba.asm
	ld -o gamarjoba gamarjoba.o

run_gamarjoba: gamarjoba
	./gamarjoba

baremetal_gamarjoba: baremetal_gamarjoba.asm include.c
	gcc -m32 -ffreestanding -o include.o -c include.c
	nasm -f elf32 baremetal_gamarjoba.asm
	ld -m elf_i386 -nostdlib -T linker.ld baremetal_gamarjoba.o include.o -o baremetal_gamarjoba

run_baremetal_gamarjoba: baremetal_gamarjoba
	qemu-system-i386 -kernel baremetal_gamarjoba

keyboard: keyboard.asm c_keyboard.c keyboard.rs
	gcc -m32 -ffreestanding -o c_keyboard.o -c c_keyboard.c
	rustc --emit obj -o rust_keyboard.o --target i686-unknown-linux-gnu keyboard.rs
	nasm -f elf32 keyboard.asm
	ld -m elf_i386 -nostdlib -T linker.ld keyboard.o c_keyboard.o rust_keyboard.o -o keyboard

run_keyboard: keyboard
	qemu-system-i386 -kernel keyboard

run_terminal_keyboard: keyboard
	qemu-system-i386 -display curses -kernel keyboard


lightshow: lightshow.asm lightshow.rs
	rustc --emit obj -o lightshow_rust.o --target i686-unknown-linux-gnu -g lightshow.rs
	nasm -f elf32 -g lightshow.asm
	ld -m elf_i386 -nostdlib -T linker.ld lightshow.o lightshow_rust.o -o lightshow

run_lightshow: lightshow
	qemu-system-i386 -kernel lightshow

debug_lightshow: lightshow
	qemu-system-i386 -kernel lightshow -gdb tcp::9999 -S

.PHONY: clean
clean:
	rm -f *.o
	rm -f gamarjoba
	rm -f baremetal_gamarjoba
	rm -f keyboard
	rm -f lightshow
