1
0

Makefile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. all: build build/boot_asmg.x86.qcow2 build/boot_asmg_dbg.x86.qcow2 build/boot_asmg0.x86
  2. # Trivial things
  3. build:
  4. mkdir $@
  5. diskfs:
  6. mkdir $@
  7. # Bootloader
  8. build/atapio16.asm: lib/atapio.asm
  9. cat $^ | sed -e 's|atapio_|atapio16_|g' -e 's|ATAPIO_|ATAPIO16_|g' -e 's|platform_|platform16_|g' > $@
  10. build/bootloader.asm: boot/stage1.asm boot/a20.asm boot/strings.asm build/atapio16.asm boot/stage2.asm lib/atapio.asm boot/idt.asm
  11. cat $^ > $@
  12. build/bootloader.x86.exe: build/bootloader.asm
  13. nasm -f bin -I lib/ -o $@ $<
  14. build/bootloader.x86.mbr: build/bootloader.x86.exe
  15. head -c 512 $< > $@
  16. build/bootloader.x86.stage2: build/bootloader.x86.exe
  17. tail -c +513 $< > $@
  18. # Diskfs image
  19. diskfs/mescc/x86_defs.m1:
  20. mkdir -p diskfs/mescc
  21. cp contrib/M2-Planet/test/common_x86/x86_defs.M1 $@
  22. # Unfortunately the order of the files is relevant here, otherwise
  23. # some internal offsets wrap around because they are store in single
  24. # words
  25. diskfs/fasm/fasm.asm: contrib/fasm/source/version.inc contrib/fasm/source/errors.inc contrib/fasm/source/symbdump.inc contrib/fasm/source/preproce.inc contrib/fasm/source/parser.inc contrib/fasm/source/exprpars.inc contrib/fasm/source/assemble.inc contrib/fasm/source/exprcalc.inc contrib/fasm/source/formats.inc contrib/fasm/source/x86_64.inc contrib/fasm/source/avx.inc contrib/fasm/source/tables.inc contrib/fasm/source/messages.inc contrib/fasm/source/variable.inc contrib/fasm/source/asmc/system.inc contrib/fasm/source/asmc/fasm.asm
  26. mkdir -p diskfs/fasm
  27. cat $^ > $@
  28. diskfs/sch3.scm: diskfs/sc/src/init.scm diskfs/sc/src/preprocessor.scm diskfs/sc/src/std.scm diskfs/sc/t/scheme-tests/minikanren.scm
  29. cat $^ > $@
  30. build/diskfs.list: diskfs/* diskfs/mescc/x86_defs.m1 diskfs/fasm/fasm.asm diskfs/sch3.scm
  31. (cd diskfs/ ; find -L . -type f) | cut -c3- | sed -e 's|\(.*\)|\1 diskfs/\1|' > $@
  32. build/diskfs.img: build/diskfs.list
  33. ./create_diskfs.py < $< > $@
  34. # Asmg kernel
  35. build/full-asmg.asm: lib/mb_header.asm lib/kernel.asm lib/io.asm lib/shutdown.asm lib/initrd.asm lib/library.asm lib/setjmp.asm asmg/asmg.asm asmg/kernel-asmg.asm lib/top.asm
  36. #cat $^ | grep -v "^ *section " > $@
  37. cat $^ | sed -e 's|section .bss|section .data|' > $@
  38. #cat $^ > $@
  39. build/initrd-asmg.list: asmg/*.g diskfs/mm0/examples/set.mm0
  40. ls $^ | sed -e 's|\(.*\)/\([^/]*\)|\2 \1/\2|g' > $@
  41. build/initrd-asmg.diskfs: build/initrd-asmg.list
  42. ./create_diskfs.py < $< > $@
  43. build/asmg.x86.exe: build/full-asmg.asm
  44. nasm -f bin -o $@ $<
  45. build/asmg_dbg.x86.exe: build/full-asmg.asm
  46. nasm -D DEBUG -f bin -o $@ $<
  47. build/asmg.x86: build/asmg.x86.exe build/initrd-asmg.diskfs
  48. cat $^ > $@
  49. build/asmg_dbg.x86: build/asmg_dbg.x86.exe build/initrd-asmg.diskfs
  50. cat $^ > $@
  51. build/debugfs.img:
  52. echo -n 'DEBUGFS ' > $@
  53. dd if=/dev/zero of=$@ bs=1048576 count=10 oflag=append conv=notrunc
  54. build/boot_asmg.x86: build/bootloader.x86.mbr build/bootloader.x86.stage2 build/asmg.x86 build/diskfs.img build/debugfs.img
  55. ./create_partition.py $^ > $@
  56. build/boot_asmg_dbg.x86: build/bootloader.x86.mbr build/bootloader.x86.stage2 build/asmg_dbg.x86 build/diskfs.img build/debugfs.img
  57. ./create_partition.py $^ > $@
  58. build/boot_asmg.x86.qcow2: build/boot_asmg.x86
  59. qemu-img convert -O qcow2 $^ $@
  60. build/boot_asmg_dbg.x86.qcow2: build/boot_asmg_dbg.x86
  61. qemu-img convert -O qcow2 $^ $@
  62. # Asmg0 kernel
  63. build/full-asmg0.asm: lib/mb_header.asm asmg0/asmg0.asm lib/shutdown.asm asmg0/debug.asm lib/top.asm
  64. cat $^ | grep -v "^ *section " > $@
  65. build/asmg0.x86.exe: build/full-asmg0.asm
  66. nasm -f bin -o $@ $<
  67. build/asmg0.x86: build/asmg0.x86.exe asmg0/main.g0
  68. cat $^ > $@
  69. build/boot_asmg0.x86: build/bootloader.x86.mbr build/bootloader.x86.stage2 build/asmg0.x86
  70. ./create_partition.py $^ > $@