]> git.lizzy.rs Git - nyax.git/blobdiff - Makefile
Force make to use bash (#1)
[nyax.git] / Makefile
index af1e7af41db27708961bf874b9f5f375a3a1eca7..717302f448d0c3c91a0790a8e990bf772b278320 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,17 +1,31 @@
-OBJS = main.o framebuffer.o memory.o
+SHELL:=/bin/bash
 
-nyax.img: boot.out main.out
-       cat boot.out main.out > nyax.img
+STAGE3 = stage3/main.o stage3/framebuffer.o stage3/memory.o stage3/paging.o
 
-boot.out: boot.asm main.out
-       nasm -f bin boot.asm -o boot.out -dMAIN_SIZE=$$(stat -c%s main.out)
+nyax.img: stage1.out stage2.out stage3.out
+       cat stage{1,2,3}.out > nyax.img
 
-main.out: $(OBJS)
-       ld -o main.out -Ttext 0xD000 --oformat binary $(OBJS)
+stage1.out: stage1/main.asm stage1/print.asm stage2.out stage3.out
+       nasm -f bin stage1/main.asm -o stage1.out \
+               -dKSIZE=$$(du -cb stage{2,3}.out | tail -n1 | cut -f1)
 
-%.o: %.asm
+stage2.out: stage2/main.asm stage2/mmap.asm stage2/paging.asm stage2/vesa.asm stage1/print.asm
+       nasm -f bin stage2/main.asm -o stage2.out
+
+stage3.out: $(STAGE3) stage2.out
+       ld -o stage3.out --oformat binary $(STAGE3) \
+               -Ttext $$(printf "%x\n" $$(echo $$(du -b stage2.out | cut -f1)+32256 | bc))
+
+stage3/%.o: stage3/%.asm
        nasm -f elf64 $< -o $@
 
-.PHONY: run
+.PHONY: run clean flash
+
 run: nyax.img
        bochs -q
+
+clean:
+       rm -rf stage3/*.o *.out *.img
+
+flash: nyax.img
+       dd if=nyax.img of=$(DEV)