makefile 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. ## Copyright (C) 2016 Jeremiah Orians
  2. ## This file is part of stage0.
  3. ##
  4. ## stage0 is free software: you can redistribute it and/or modify
  5. ## it under the terms of the GNU General Public License as published by
  6. ## the Free Software Foundation, either version 3 of the License, or
  7. ## (at your option) any later version.
  8. ##
  9. ## stage0 is distributed in the hope that it will be useful,
  10. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ## GNU General Public License for more details.
  13. ##
  14. ## You should have received a copy of the GNU General Public License
  15. ## along with stage0. If not, see <http://www.gnu.org/licenses/>.
  16. # Don't rebuild the built things in bin or roms
  17. VPATH = bin:roms:prototypes:stage1/High_level_prototypes:stage2/High_level_prototypes
  18. # Collections of tools
  19. all: libvm.so vm ALL-ROMS ALL-PROTOTYPES
  20. production: libvm-production.so vm-production asm dis ALL-ROMS
  21. development: vm libvm.so asm dis ALL-ROMS
  22. # VM Builds
  23. vm-minimal: vm.h vm_minimal.c vm_instructions.c vm_decode.c | bin
  24. $(CC) -DVM32=true vm_minimal.c vm_instructions.c vm_decode.c -o bin/vm-minimal
  25. vm: vm.h vm.c vm_instructions.c vm_decode.c tty.c | bin
  26. $(CC) -ggdb -DVM32=true -Dtty_lib=true vm.c vm_instructions.c vm_decode.c tty.c -o bin/vm
  27. vm-production: vm.h vm.c vm_instructions.c vm_decode.c | bin
  28. $(CC) -DVM32=true vm.c vm_instructions.c vm_decode.c -o bin/vm-production
  29. vm-trace: vm.h vm.c vm_instructions.c vm_decode.c tty.c dynamic_execution_trace.c | bin
  30. $(CC) -DVM32=true -ggdb -Dtty_lib=true -DTRACE=true vm.c vm_instructions.c vm_decode.c tty.c dynamic_execution_trace.c -o bin/vm
  31. # Build the roms
  32. ALL-ROMS: stage0_monitor stage1_assembler-0 SET DEHEX stage1_assembler-1 stage1_assembler-2 M0 CAT lisp cc_x86 forth
  33. stage0_monitor: hex stage0/stage0_monitor.hex0 | roms
  34. ./bin/hex < stage0/stage0_monitor.hex0 > roms/stage0_monitor
  35. stage1_assembler-0: hex stage1/stage1_assembler-0.hex0 | roms
  36. ./bin/hex < stage1/stage1_assembler-0.hex0 > roms/stage1_assembler-0
  37. SET: stage1_assembler-2 vm stage1/SET.hex2 | roms
  38. ./bin/vm --rom roms/stage1_assembler-2 --tape_01 stage1/SET.hex2 --tape_02 roms/SET
  39. DEHEX: stage1_assembler-0 vm stage1/dehex.hex0 | roms
  40. ./bin/vm --rom roms/stage1_assembler-0 --tape_01 stage1/dehex.hex0 --tape_02 roms/DEHEX
  41. stage1_assembler-1: stage1_assembler-0 vm stage1/stage1_assembler-1.hex0 | roms
  42. ./bin/vm --rom roms/stage1_assembler-0 --tape_01 stage1/stage1_assembler-1.hex0 --tape_02 roms/stage1_assembler-1
  43. stage1_assembler-2: stage1_assembler-1 vm stage1/stage1_assembler-2.hex1 | roms
  44. ./bin/vm --rom roms/stage1_assembler-1 --tape_01 stage1/stage1_assembler-2.hex1 --tape_02 roms/stage1_assembler-2
  45. M0: stage1_assembler-2 vm stage1/M0-macro.hex2 | roms
  46. ./bin/vm --rom roms/stage1_assembler-2 --tape_01 stage1/M0-macro.hex2 --tape_02 roms/M0 --memory 48K
  47. CAT: M0 stage1_assembler-2 vm High_level_prototypes/defs stage1/CAT.s | roms
  48. cat High_level_prototypes/defs stage1/CAT.s >| CAT_TEMP
  49. ./bin/vm --rom roms/M0 --tape_01 CAT_TEMP --tape_02 CAT_TEMP2 --memory 48K
  50. ./bin/vm --rom roms/stage1_assembler-2 --tape_01 CAT_TEMP2 --tape_02 roms/CAT --memory 48K
  51. rm CAT_TEMP CAT_TEMP2
  52. lisp: M0 stage1_assembler-2 vm High_level_prototypes/defs stage2/lisp.s | roms
  53. cat High_level_prototypes/defs stage2/lisp.s > lisp_TEMP
  54. ./bin/vm --rom roms/M0 --tape_01 lisp_TEMP --tape_02 lisp_TEMP2 --memory 256K
  55. ./bin/vm --rom roms/stage1_assembler-2 --tape_01 lisp_TEMP2 --tape_02 roms/lisp --memory 48K
  56. rm lisp_TEMP lisp_TEMP2
  57. cc_x86: M0 stage1_assembler-2 vm High_level_prototypes/defs stage2/cc_x86.s | roms
  58. cat High_level_prototypes/defs stage2/cc_x86.s > cc_TEMP
  59. ./bin/vm --rom roms/M0 --tape_01 cc_TEMP --tape_02 cc_TEMP2 --memory 256K
  60. ./bin/vm --rom roms/stage1_assembler-2 --tape_01 cc_TEMP2 --tape_02 roms/cc_x86 --memory 48K
  61. rm cc_TEMP cc_TEMP2
  62. forth: M0 stage1_assembler-2 vm High_level_prototypes/defs stage2/forth.s | roms
  63. cat High_level_prototypes/defs stage2/forth.s > forth_TEMP
  64. ./bin/vm --rom roms/M0 --tape_01 forth_TEMP --tape_02 forth_TEMP2 --memory 128K
  65. ./bin/vm --rom roms/stage1_assembler-2 --tape_01 forth_TEMP2 --tape_02 roms/forth --memory 48K
  66. rm forth_TEMP forth_TEMP2
  67. # Primitive development tools, not required but it was handy
  68. asm: High_level_prototypes/asm.c | bin
  69. $(CC) -ggdb High_level_prototypes/asm.c -o bin/asm
  70. dis: High_level_prototypes/disasm.c | bin
  71. $(CC) -ggdb High_level_prototypes/disasm.c -o bin/dis
  72. hex: Linux\ Bootstrap/Legacy_pieces/hex.c | bin
  73. $(CC) Linux\ Bootstrap/Legacy_pieces/hex.c -o bin/hex
  74. xeh: Linux\ Bootstrap/Legacy_pieces/xeh.c | bin
  75. $(CC) Linux\ Bootstrap/Legacy_pieces/xeh.c -o bin/xeh
  76. # libVM Builds for Development tools
  77. libvm.so: wrapper.c vm_instructions.c vm_decode.c vm.h tty.c
  78. $(CC) -ggdb -DVM32=true -Dtty_lib=true -shared -Wl,-soname,libvm.so -o libvm.so -fPIC wrapper.c vm_instructions.c vm_decode.c tty.c
  79. libvm-production.so: wrapper.c vm_instructions.c vm_decode.c vm.h
  80. $(CC) -DVM32=true -shared -Wl,-soname,libvm.so -o libvm-production.so -fPIC wrapper.c vm_instructions.c vm_decode.c
  81. # Tests
  82. Generate-rom-test: ALL-ROMS
  83. mkdir -p test
  84. sha256sum roms/* | sort -k2 >| test/SHA256SUMS
  85. test_stage0_monitor_asm_match: asm stage0_monitor
  86. mkdir -p test/stage0_test_scratch
  87. sed 's/^[^#]*# //' stage0/stage0_monitor.hex0 > test/stage0_test_scratch/stage0_monitor.hex0.s
  88. bin/asm test/stage0_test_scratch/stage0_monitor.hex0.s > test/stage0_test_scratch/stage0_monitor.hex0.hex0
  89. bin/hex < test/stage0_test_scratch/stage0_monitor.hex0.hex0 > test/stage0_test_scratch/stage0_monitor.hex0.bin
  90. bin/asm stage0/stage0_monitor.s > test/stage0_test_scratch/stage0_monitor.s.hex0
  91. bin/hex < test/stage0_test_scratch/stage0_monitor.s.hex0 > test/stage0_test_scratch/stage0_monitor.s.bin
  92. sha256sum roms/stage0_monitor | sed 's@roms/stage0_monitor@test/stage0_test_scratch/stage0_monitor.s.bin@' > test/stage0_test_scratch/stage0_monitor.s.expected_sum
  93. sha256sum -c test/stage0_test_scratch/stage0_monitor.s.expected_sum
  94. sha256sum roms/stage0_monitor | sed 's@roms/stage0_monitor@test/stage0_test_scratch/stage0_monitor.hex0.bin@' > test/stage0_test_scratch/stage0_monitor.hex0.expected_sum
  95. sha256sum -c test/stage0_test_scratch/stage0_monitor.hex0.expected_sum
  96. test: ALL-ROMS test/SHA256SUMS test_stage0_monitor_asm_match
  97. sha256sum -c test/SHA256SUMS
  98. # Prototypes
  99. ALL-PROTOTYPES: prototype_dehex prototype_M0 prototype_more prototype_SET prototype_stage1_assembler-1 prototype_stage1_assembler-2 prototype_lisp
  100. prototype_dehex: dehex.c | prototypes
  101. gcc stage1/High_level_prototypes/dehex.c -o prototypes/prototype_dehex
  102. prototype_M0: M0-macro.c | prototypes
  103. gcc stage1/High_level_prototypes/M0-macro.c -o prototypes/prototype_M0
  104. prototype_more: more.c tty.c | prototypes
  105. gcc stage1/High_level_prototypes/more.c tty.c -o prototypes/prototype_more
  106. prototype_SET: SET.c tty.c | prototypes
  107. gcc stage1/High_level_prototypes/SET.c tty.c -o prototypes/prototype_SET
  108. prototype_stage1_assembler-1: stage1_assembler-1.c | prototypes
  109. gcc stage1/High_level_prototypes/stage1_assembler-1.c -o prototypes/prototype_stage1_assembler-1
  110. prototype_stage1_assembler-2: stage1_assembler-2.c | prototypes
  111. gcc stage1/High_level_prototypes/stage1_assembler-2.c -o prototypes/prototype_stage1_assembler-2
  112. prototype_lisp: lisp.c lisp.h lisp_cell.c lisp_eval.c lisp_print.c lisp_read.c | prototypes
  113. gcc -O2 stage2/High_level_prototypes/lisp.h \
  114. stage2/High_level_prototypes/lisp.c \
  115. stage2/High_level_prototypes/lisp_cell.c \
  116. stage2/High_level_prototypes/lisp_eval.c \
  117. stage2/High_level_prototypes/lisp_print.c \
  118. stage2/High_level_prototypes/lisp_read.c \
  119. -o prototypes/prototype_lisp
  120. # Clean up after ourselves
  121. .PHONY: clean
  122. clean:
  123. rm -f libvm.so libvm-production.so bin/vm bin/vm-production
  124. rm -rf test/stage0_test_scratch
  125. .PHONY: clean-hard
  126. clean-hard: clean
  127. rm -rf bin/ roms/ prototypes/
  128. .PHONY: clean-hardest
  129. clean-hardest:
  130. git reset --hard
  131. git clean -fd
  132. rm -rf bin/ roms/ prototypes/
  133. clean-SO-hard-You-probably-do-NOT-want-this-option-because-it-will-destory-everything:
  134. @echo "I REALLY REALLY HOPE you know what you are doing"
  135. git reset --hard
  136. git clean -xdf
  137. rm -rf bin/ roms/ prototypes/
  138. # Our essential folders
  139. bin:
  140. mkdir -p bin
  141. roms:
  142. mkdir -p roms
  143. prototypes:
  144. mkdir -p prototypes