makefile 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. ## Copyright (C) 2016 Jeremiah Orians
  2. ## This file is part of stage0.
  3. ##
  4. ## stage0 is free software: you an 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. gcc vm.h 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. gcc -ggdb -DVM32=true -Dtty_lib=true vm.h 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. gcc vm.h 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. gcc -ggdb -Dtty_lib=true -DTRACE=true vm.h 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 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. forth: M0 stage1_assembler-2 vm High_level_prototypes/defs stage2/forth.s | roms
  58. cat High_level_prototypes/defs stage2/forth.s > forth_TEMP
  59. ./bin/vm --rom roms/M0 --tape_01 forth_TEMP --tape_02 forth_TEMP2 --memory 128K
  60. ./bin/vm --rom roms/stage1_assembler-2 --tape_01 forth_TEMP2 --tape_02 roms/forth --memory 48K
  61. rm forth_TEMP forth_TEMP2
  62. # Primitive development tools, not required but it was handy
  63. asm: High_level_prototypes/asm.c | bin
  64. gcc -ggdb High_level_prototypes/asm.c -o bin/asm
  65. dis: High_level_prototypes/disasm.c | bin
  66. gcc -ggdb High_level_prototypes/disasm.c -o bin/dis
  67. hex: Linux\ Bootstrap/hex.c | bin
  68. gcc Linux\ Bootstrap/hex.c -o bin/hex
  69. xeh: Linux\ Bootstrap/xeh.c | bin
  70. gcc Linux\ Bootstrap/xeh.c -o bin/xeh
  71. # libVM Builds for Development tools
  72. libvm.so: wrapper.c vm_instructions.c vm_decode.c vm.h tty.c
  73. gcc -ggdb -DVM32=true -Dtty_lib=true -shared -Wl,-soname,libvm.so -o libvm.so -fPIC wrapper.c vm_instructions.c vm_decode.c vm.h tty.c
  74. libvm-production.so: wrapper.c vm_instructions.c vm_decode.c vm.h
  75. gcc -DVM32=true -shared -Wl,-soname,libvm.so -o libvm-production.so -fPIC wrapper.c vm_instructions.c vm_decode.c vm.h
  76. # Tests
  77. Generate-rom-test: ALL-ROMS
  78. mkdir -p test
  79. sha256sum roms/* | sort -k2 >| test/SHA256SUMS
  80. test: ALL-ROMS test/SHA256SUMS
  81. sha256sum -c test/SHA256SUMS
  82. # Prototypes
  83. ALL-PROTOTYPES: prototype_dehex prototype_M0 prototype_more prototype_SET prototype_stage1_assembler-1 prototype_stage1_assembler-2 prototype_lisp
  84. prototype_dehex: dehex.c | prototypes
  85. gcc stage1/High_level_prototypes/dehex.c -o prototypes/prototype_dehex
  86. prototype_M0: M0-macro.c | prototypes
  87. gcc stage1/High_level_prototypes/M0-macro.c -o prototypes/prototype_M0
  88. prototype_more: more.c tty.c | prototypes
  89. gcc stage1/High_level_prototypes/more.c tty.c -o prototypes/prototype_more
  90. prototype_SET: SET.c tty.c | prototypes
  91. gcc stage1/High_level_prototypes/SET.c tty.c -o prototypes/prototype_SET
  92. prototype_stage1_assembler-1: stage1_assembler-1.c | prototypes
  93. gcc stage1/High_level_prototypes/stage1_assembler-1.c -o prototypes/prototype_stage1_assembler-1
  94. prototype_stage1_assembler-2: stage1_assembler-2.c | prototypes
  95. gcc stage1/High_level_prototypes/stage1_assembler-2.c -o prototypes/prototype_stage1_assembler-2
  96. prototype_lisp: lisp.c lisp.h lisp_cell.c lisp_eval.c lisp_print.c lisp_read.c | prototypes
  97. gcc -O2 stage2/High_level_prototypes/lisp.h \
  98. stage2/High_level_prototypes/lisp.c \
  99. stage2/High_level_prototypes/lisp_cell.c \
  100. stage2/High_level_prototypes/lisp_eval.c \
  101. stage2/High_level_prototypes/lisp_print.c \
  102. stage2/High_level_prototypes/lisp_read.c \
  103. -o prototypes/prototype_lisp
  104. # Clean up after ourselves
  105. .PHONY: clean
  106. clean:
  107. rm -rf bin/ roms/ prototypes/ *.so
  108. .PHONY: clean-hardest
  109. clean-hard:
  110. git reset --hard
  111. git clean -fd
  112. rm -rf bin/ roms/ prototypes/
  113. clean-SO-hard-You-probably-do-NOT-want-this-option-because-it-will-destory-everything:
  114. @echo "I REALLY REALLY HOPE you know what you are doing"
  115. git reset --hard
  116. git clean -xdf
  117. rm -rf bin/ roms/ prototypes/
  118. # Our essential folders
  119. bin:
  120. mkdir -p bin
  121. roms:
  122. mkdir -p roms
  123. prototypes:
  124. mkdir -p prototypes