hello-amd64.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #! /bin/sh
  2. ## Copyright (C) 2017 Jeremiah Orians
  3. ## This file is part of M2-Planet.
  4. ##
  5. ## M2-Planet is free software: you can redistribute it and/or modify
  6. ## it under the terms of the GNU General Public License as published by
  7. ## the Free Software Foundation, either version 3 of the License, or
  8. ## (at your option) any later version.
  9. ##
  10. ## M2-Planet is distributed in the hope that it will be useful,
  11. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ## GNU General Public License for more details.
  14. ##
  15. ## You should have received a copy of the GNU General Public License
  16. ## along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
  17. set -x
  18. # Build the test
  19. ./bin/M2-Planet --architecture amd64 -f test/test0105/lisp.h \
  20. -f test/common_amd64/functions/malloc.c \
  21. -f functions/calloc.c \
  22. -f functions/in_set.c \
  23. -f test/common_amd64/functions/file.c \
  24. -f test/common_amd64/functions/exit.c \
  25. -f functions/numerate_number.c \
  26. -f functions/match.c \
  27. -f functions/file_print.c \
  28. -f test/test0105/lisp.c \
  29. -f test/test0105/lisp_cell.c \
  30. -f test/test0105/lisp_eval.c \
  31. -f test/test0105/lisp_print.c \
  32. -f test/test0105/lisp_read.c \
  33. --debug \
  34. --bootstrap-mode \
  35. -o test/test0105/lisp.M1 || exit 1
  36. # Build debug footer
  37. blood-elf --64 -f test/test0105/lisp.M1 \
  38. --entry _start \
  39. -o test/test0105/lisp-footer.M1 || exit 2
  40. # Macro assemble with libc written in M1-Macro
  41. M1 -f test/common_amd64/amd64_defs.M1 \
  42. -f test/common_amd64/libc-core.M1 \
  43. -f test/test0105/lisp.M1 \
  44. -f test/test0105/lisp-footer.M1 \
  45. --LittleEndian \
  46. --architecture amd64 \
  47. -o test/test0105/lisp.hex2 || exit 3
  48. # Resolve all linkages
  49. hex2 -f test/common_amd64/ELF-amd64-debug.hex2 \
  50. -f test/test0105/lisp.hex2 \
  51. --LittleEndian \
  52. --architecture amd64 \
  53. --BaseAddress 0x00600000 \
  54. -o test/results/test0105-amd64-binary \
  55. --exec_enable || exit 4
  56. # Ensure binary works if host machine supports test
  57. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "amd64" ]
  58. then
  59. # Verify that the compiled program returns the correct result
  60. out=$(./test/results/test0105-amd64-binary --version 2>&1 )
  61. [ 0 = $? ] || exit 5
  62. [ "$out" = "Slow_Lisp 0.1" ] || exit 6
  63. # Verify that the resulting file works
  64. out=$(./test/results/test0105-amd64-binary --file test/test0105/test.scm)
  65. [ "$out" = "42" ] || exit 7
  66. fi
  67. exit 0