Use JMK build system
diff --git a/src/kernel/Jmk b/src/kernel/Jmk
new file mode 100644
index 0000000..c8ac4fe
--- /dev/null
+++ b/src/kernel/Jmk
@@ -0,0 +1,61 @@
+init(kernel, kernel.elf)
+
+preset(freestanding)
+preset(optimize)
+preset(debug)
+preset(32)
+preset(warn)
+preset(nasm)
+
+archetype(c)
+archetype(asm)
+
+depends(initrd, $(ROOT)/boot/initrd, initrd.img)
+
+LDFLAGS = -Tlink.ld -melf_i386
+ASMFLAGS = -felf
+QEMUFLAGS = -d cpu_reset
+
+OBJECTS = 	boot.o \
+			main.o \
+			descriptor_tables.o \
+			io.o \
+			vga.o \
+			gdt_flush.o \
+			idt.o \
+			log.o \
+			irq.o \
+			pic.o \
+			timer.o \
+			paging.o \
+			switch_table.o \
+			scan_codes.o \
+			kheap.o \
+			alloc.o \
+			vfs.o \
+			multiboot.o \
+			vfs_initrd.o
+
+type(custom_link)
+
+debug: kernel.elf
+	qemu-system-i386 -s -S -kernel kernel.elf &
+	@echo run "target remote localhost:1234" to connect to qemu
+	gdb
+	@pkill qemu-system-i38
+
+qemu: kernel.elf
+	qemu-system-i386 $(QEMUFLAGS) -monitor stdio -kernel kernel.elf -no-reboot
+
+qemu-iso: install
+	qemu-system-i386 $(QEMUFLAGS) -monitor stdio $(ROOT)/bin/bluejay.iso
+
+scan_codes.c: gen_scan_codes.py scan_codes.tsv 
+	python3 $< > $@
+
+install: kernel.elf lib(initrd)
+	cp kernel.elf $(ROOT)/boot/
+	rm -f $(ROOT)/bin/bluejay.iso
+	grub-mkrescue -o $(ROOT)/bin/bluejay.iso $(ROOT)
+
+finish
diff --git a/src/kernel/Makefile b/src/kernel/Makefile
index 9029f26..ebac3b5 100644
--- a/src/kernel/Makefile
+++ b/src/kernel/Makefile
@@ -1,4 +1,42 @@
-SOURCES = 	boot.o \
+jmk_project := kernel
+jmk_target = kernel.elf
+ROOT := /home/ch/dev/bluejay
+ASM ?= nasm
+CC ?= gcc
+LD ?= ld
+CFLAGS += -I$(ROOT)/include
+
+all: $(jmk_target)
+
+CFLAGS += -nostdlib -nostdinc -fno-builtin -fno-stack-protector -ffreestanding
+CFLAGS += -O2
+CFLAGS += -g
+CFLAGS += -m32
+CFLAGS += -Wall -Wno-unused-function -Wno-unused-variable
+ASM = nasm
+    
+
+.c.o:
+	$(CC) -c $< -o $@ $(CFLAGS)
+
+.s.o:
+	$(ASM) $(ASMFLAGS) $< -o $@
+    
+
+
+
+jmk_lib_path_initrd = $(ROOT)/boot/initrd
+jmk_lib_target_initrd = initrd.img
+jmk_libs_phony += $(jmk_lib_path_initrd)/$(jmk_lib_target_initrd)
+
+$(jmk_lib_path_initrd)/$(jmk_lib_target_initrd):
+	$(MAKE) -C $(jmk_lib_path_initrd) $(jmk_lib_target_initrd)
+
+LDFLAGS = -Tlink.ld -melf_i386
+ASMFLAGS = -felf
+QEMUFLAGS = -d cpu_reset
+
+OBJECTS = 	boot.o \
 			main.o \
 			descriptor_tables.o \
 			io.o \
@@ -18,19 +56,9 @@
 			multiboot.o \
 			vfs_initrd.o
 
-JAYROOT = ../../
-CFLAGS = -nostdlib -nostdinc -fno-builtin -fno-stack-protector -ffreestanding \
-			-m32 -O2 -g -Wall -Wno-unused-function -Wno-unused-variable \
-			-I$(JAYROOT)/include
-LDFLAGS = -Tlink.ld -melf_i386
-ASMFLAGS = -felf
-QEMUFLAGS = -d cpu_reset
-
-kernel.elf: $(SOURCES)
-	ld $(LDFLAGS) -o $@ $^
-
-clean:
-	rm -f *.o *.bin *.elf $(JAYROOT)/bin/*.iso
+$(jmk_target): $(OBJECTS)
+	$(LD) $(LDFLAGS) -o $@ $^
+    
 
 debug: kernel.elf
 	qemu-system-i386 -s -S -kernel kernel.elf &
@@ -42,21 +70,20 @@
 	qemu-system-i386 $(QEMUFLAGS) -monitor stdio -kernel kernel.elf -no-reboot
 
 qemu-iso: install
-	qemu-system-i386 $(QEMUFLAGS) -monitor stdio $(JAYROOT)/bin/bluejay.iso
+	qemu-system-i386 $(QEMUFLAGS) -monitor stdio $(ROOT)/bin/bluejay.iso
 
 scan_codes.c: gen_scan_codes.py scan_codes.tsv 
 	python3 $< > $@
 
-.s.o:
-	nasm $(ASMFLAGS) $<
+install: kernel.elf $(jmk_lib_path_initrd)/$(jmk_lib_target_initrd)
+	cp kernel.elf $(ROOT)/boot/
+	rm -f $(ROOT)/bin/bluejay.iso
+	grub-mkrescue -o $(ROOT)/bin/bluejay.iso $(ROOT)
 
-$(JAYROOT)/boot/initrd.img:
-	$(MAKE) -C $(JAYROOT)/boot/initrd initrd.img
-	cp $(JAYROOT)/boot/initrd/initrd.img $(JAYROOT)/boot/
+clean:
+	rm -f *.o *.a *.so $(jmk_target)
 
-install: kernel.elf $(JAYROOT)/boot/initrd.img
-	cp kernel.elf $(JAYROOT)/boot/
-	rm -f $(JAYROOT)/bin/bluejay.iso
-	grub-mkrescue -o $(JAYROOT)/bin/bluejay.iso $(JAYROOT)
+Makefile: Jmk
+	cd "/home/ch/dev/bluejay" && ./bin/jmk
 
-.PHONY: install qemu clean qemu-iso debug $(JAYROOT)/boot/initrd.img
+.PHONY: $(jmk_libs_phony) $(jmk_custom_phony) clean all
diff --git a/src/kernel/main.c b/src/kernel/main.c
index 2ee2828..ead5232 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -26,30 +26,25 @@
 
 	// Load initrd
 	struct multiboot_info mb = make_multiboot_physical(mboot);
+	init_vfs();
 
+#ifdef INITRD
 	kassert(mb.mods_count, "No multiboot modules loaded!");
 	kprintf("mboot->mods_addr = %d (0x%x)\n", mb.mods_addr, mb.mods_addr);
 	uchar *initrd_loc = (uchar *)((uint *)mb.mods_addr)[0];
 
 	kprintf("initrd is at 0x%x to 0x%x\n", initrd_loc);
 
-	kprintf("%x |", initrd_loc);
-	for (int i = 0; i < 32; i++)
-	{
-		kprintf(" %x", initrd_loc[i]);
-		if (i % 8 == 0)
-			kprintf("\n");
-	}
-	kprintf("\n");
+	init_initrd_vfs(initrd_loc);
+#endif
 
-	init_vfs();
-	//init_initrd_vfs(initrd_loc);
 	kprintf("VFS initialized\n");
 
 	vga_set_color(LIGHT_GREEN, BLACK);
-	vga_write("Setup complete!\n");
+	kprintf("Setup complete!\n");
 	vga_set_color(WHITE, BLACK);
 
+#ifdef TEST_VFS_INITRD
 	kprintf("fs_readdir(\"/dev/initrd\")\n");
 
 	struct fs_dirent dirent;
@@ -57,6 +52,7 @@
 	{
 		kprintf("name: %s, inode: %d\n", dirent.name, dirent.inode);
 	}
+#endif
 
 	asm volatile("sti");