makefile 4.4 KB

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