aboutsummaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
Diffstat (limited to 'mk')
-rwxr-xr-xmk57
1 files changed, 57 insertions, 0 deletions
diff --git a/mk b/mk
new file mode 100755
index 0000000..f4de64b
--- /dev/null
+++ b/mk
@@ -0,0 +1,57 @@
+#!./mach
+
+SUBDIRS := lib ${ARCH} devices src
+
+${ARCH}_LDFLAGS += -T ${ROOTDIR}${ARCH}/linker.ld
+
+TARGETBIN += glitch
+glitch.OBJS += ${ARCH}/arch.a src/kernel.a devices/devs.a lib/libk.a
+
+lib/libk.a:
+ @${MAKE} -C lib -f ../root.mk libk.a
+i686/arch.a:
+ @${MAKE} -C ${ARCH} -f ../root.mk arch.a
+devices/devs.a:
+ @${MAKE} -C devices -f ../root.mk devs.a
+src/kernel.a:
+ @${MAKE} -C src -f ../root.mk kernel.a
+kconfig:
+ @${MAKE} -C tools/kconfig -f ../../root.mk
+
+run: glitch.iso
+ qemu-system-i386 -accel kvm -machine pc -cdrom $^ -d cpu_reset -display gtk,zoom-to-fit=on
+
+# configure targets
+.config: Kconfig
+ @alldefconfig
+
+config.mk: .config ${ARCH}/toolchain.mk
+ @cat .config > $@
+ @echo -e '\n## toolchain.mk' >> $@
+ @cat ${ARCH}/toolchain.mk >> $@
+
+# iso image
+glitch.iso: glitch.elf grub/grub.cfg
+ @grub-file --is-x86-multiboot2 glitch.elf
+ @mkdir -p isodir/boot/grub
+ @mkdir -p isodir/boot/glitch
+ @grub-script-check grub/grub.cfg
+ @cp grub/grub.cfg isodir/boot/grub/grub.cfg
+ @cp glitch.elf isodir/boot/glitch/glitch.elf
+ @i686-elf-strip isodir/boot/glitch/glitch.elf
+ @rm -f isodir/boot/glitch/checksums
+ @sha512sum isodir/boot/glitch/* > isodir/boot/glitch/checksums
+ @sed -i s/isodir// isodir/boot/glitch/checksums
+ @grub-mkrescue -o glitch.iso isodir
+
+clean: clean_subdirs
+clean_subdirs:
+ @for d in ${SUBDIRS}; do make -C $$d -f ../root.mk clean; done
+
+test: test_subdirs
+test_subdirs:
+ @for d in ${SUBDIRS}; do make -C $$d -f ../root.mk test.quiet; done
+
+valgrind: valgrind_subdirs
+valgrind_subdirs:
+ @for d in ${SUBDIRS}; do make -C $$d -f ../root.mk valgrind.quiet; done