OBJS = boot/bootsect 
KOBJS = init/head.o init/main.o
KSRCS = init/head.S init/main.c

all: Makefile
	make -C boot/
	make -C init/
	make xnix.img

kernel: $(KSRCS) boot/bootsect Makefile
	ld -b elf64-x86-64 -o kernel.o $(KOBJS) -T kernel.lds
	objcopy -I elf64-x86-64 -S -R ".comment" -R ".eh_frame" -O binary kernel.o kernel


xnix.img: boot/bootsect $(KSRCS) Makefile kernel
	dd if=/dev/zero of=xnix.img bs=1024 count=1440
	dd if=boot/bootsect of=xnix.img conv=notrunc seek=0
	dd if=kernel of=xnix.img conv=notrunc bs=512 seek=2


lines: Makefile
	wc -l `find ./ -name *.asm`


clear: Makefile
	make -C boot/ clear
	make -C init/ clear
	rm boot/bootsect
	rm xnix.img kernel kernel.o



