makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. ## Copyright (C) 2017 Jeremiah Orians
  2. ## This file is part of mescc-tools.
  3. ##
  4. ## mescc-tools 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. ## mescc-tools 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 mescc-tools. If not, see <http://www.gnu.org/licenses/>.
  16. # Prevent rebuilding
  17. PACKAGE = mescc-tools
  18. all: M1 hex2 get_machine blood-elf kaem catm
  19. .NOTPARALLEL:
  20. CC=gcc
  21. CFLAGS:=$(CFLAGS) -D_GNU_SOURCE -std=c99 -ggdb -fno-common
  22. M1: bin/M1
  23. bin/M1: M1-macro.c stringify.c M2libc/bootstrappable.c | bin
  24. $(CC) $(CFLAGS) M1-macro.c \
  25. stringify.c \
  26. M2libc/bootstrappable.c \
  27. -o $@
  28. hex2: bin/hex2
  29. bin/hex2: hex2.c hex2_linker.c hex2_word.c M2libc/bootstrappable.c | bin
  30. $(CC) $(CFLAGS) hex2.c \
  31. hex2_linker.c \
  32. hex2_word.c \
  33. M2libc/bootstrappable.c \
  34. -o $@
  35. get_machine: bin/get_machine
  36. bin/get_machine: get_machine.c M2libc/bootstrappable.c | bin
  37. $(CC) $(CFLAGS) get_machine.c \
  38. M2libc/bootstrappable.c \
  39. -o $@
  40. blood-elf: bin/blood-elf
  41. bin/blood-elf: blood-elf.c stringify.c M2libc/bootstrappable.c | bin
  42. $(CC) $(CFLAGS) blood-elf.c \
  43. stringify.c \
  44. M2libc/bootstrappable.c \
  45. -o $@
  46. kaem: bin/kaem
  47. bin/kaem: Kaem/kaem.c Kaem/variable.c Kaem/kaem_globals.c M2libc/bootstrappable.c | bin
  48. $(MAKE) -C Kaem kaem
  49. catm: bin/catm
  50. bin/catm: catm.c | bin
  51. $(CC) $(CFLAGS) catm.c -o $@
  52. # Clean up after ourselves
  53. .PHONY: clean M1 hex2 get_machine blood-elf kaem catm
  54. clean:
  55. rm -rf bin/ test/results/
  56. ./test/test1/cleanup.sh
  57. ./test/test2/cleanup.sh
  58. ./test/test3/cleanup.sh
  59. ./test/test4/cleanup.sh
  60. ./test/test5/cleanup.sh
  61. ./test/test6/cleanup.sh
  62. ./test/test7/cleanup.sh
  63. ./test/test8/cleanup.sh
  64. ./test/test9/cleanup.sh
  65. ./test/test10/cleanup.sh
  66. ./test/test11/cleanup.sh
  67. ./test/test12/cleanup.sh
  68. ./test/test13/cleanup.sh
  69. $(MAKE) -C Kaem clean
  70. # A cleanup option we probably don't need
  71. .PHONY: clean-hard
  72. clean-hard: clean
  73. git reset --hard
  74. git clean -fd
  75. # Directories
  76. bin:
  77. mkdir -p bin
  78. results:
  79. mkdir -p test/results
  80. # tests
  81. test: test0-binary \
  82. test1-binary \
  83. test2-binary \
  84. test3-binary \
  85. test4-binary \
  86. test5-binary \
  87. test6-binary \
  88. test7-binary \
  89. test8-binary \
  90. test9-binary \
  91. test10-binary \
  92. test11-binary \
  93. test12-binary \
  94. test13-binary | results
  95. ./test.sh
  96. test0-binary: results hex2 get_machine | results
  97. test/test0/hello.sh
  98. test1-binary: results hex2 M1 get_machine | results
  99. test/test1/hello.sh
  100. test2-binary: results hex2 M1 get_machine | results
  101. test/test2/hello.sh
  102. test3-binary: results hex2 M1 get_machine | results
  103. test/test3/hello.sh
  104. test4-binary: results hex2 M1 get_machine | results
  105. test/test4/hello.sh
  106. test5-binary: results hex2 M1 get_machine | results
  107. test/test5/hello.sh
  108. test6-binary: results hex2 M1 get_machine | results
  109. test/test6/hello.sh
  110. test7-binary: results hex2 M1 get_machine | results
  111. test/test7/hello.sh
  112. test8-binary: results hex2 M1 get_machine | results
  113. test/test8/hello.sh
  114. test9-binary: results hex2 M1 blood-elf get_machine | results
  115. test/test9/hello.sh
  116. test10-binary: results hex2 M1 get_machine | results
  117. test/test10/hello.sh
  118. test11-binary: results hex2 M1 blood-elf get_machine | results
  119. test/test11/hello.sh
  120. test12-binary: results hex2 M1 blood-elf get_machine | results
  121. test/test12/hello.sh
  122. test13-binary: results hex2 M1 blood-elf get_machine | results
  123. test/test13/hello.sh
  124. # Generate test answers
  125. .PHONY: Generate-test-answers
  126. Generate-test-answers:
  127. sha256sum test/results/* >| test/test.answers
  128. DESTDIR:=
  129. PREFIX:=/usr/local
  130. bindir:=$(DESTDIR)$(PREFIX)/bin
  131. .PHONY: install
  132. install: bin/M1 bin/hex2 bin/blood-elf bin/kaem bin/get_machine
  133. mkdir -p $(bindir)
  134. cp $^ $(bindir)
  135. ### dist
  136. .PHONY: dist
  137. COMMIT=$(shell git describe --dirty)
  138. TARBALL_VERSION=$(COMMIT:Release_%=%)
  139. TARBALL_DIR:=$(PACKAGE)-$(TARBALL_VERSION)
  140. TARBALL=$(TARBALL_DIR).tar.gz
  141. # Be friendly to Debian; avoid using EPOCH
  142. MTIME=$(shell git show HEAD --format=%ct --no-patch)
  143. # Reproducible tarball
  144. TAR_FLAGS=--sort=name --mtime=@$(MTIME) --owner=0 --group=0 --numeric-owner --mode=go=rX,u+rw,a-s
  145. $(TARBALL):
  146. (git ls-files --recurse-submodules \
  147. --exclude=$(TARBALL_DIR); \
  148. echo $^ | tr ' ' '\n') \
  149. | tar $(TAR_FLAGS) \
  150. --transform=s,^,$(TARBALL_DIR)/,S -T- -cf- \
  151. | gzip -c --no-name > $@
  152. dist: $(TARBALL)