makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. ## Copyright (C) 2017 Jeremiah Orians
  2. ## Copyright (C) 2020-2021 deesix <deesix@tuta.io>
  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. # Prevent rebuilding
  18. VPATH = bin:test:test/results
  19. PACKAGE = m2-planet
  20. # C compiler settings
  21. CC?=gcc
  22. CFLAGS:=$(CFLAGS) -D_GNU_SOURCE -O0 -std=c99 -ggdb
  23. all: M2-Planet
  24. .NOTPARALLEL:
  25. M2-Planet: bin results cc.h cc_reader.c cc_strings.c cc_types.c cc_core.c cc.c cc_globals.c cc_globals.h
  26. $(CC) $(CFLAGS) \
  27. functions/match.c \
  28. functions/in_set.c \
  29. functions/numerate_number.c \
  30. functions/file_print.c \
  31. functions/number_pack.c \
  32. functions/string.c \
  33. functions/require.c \
  34. functions/fixup.c \
  35. cc_reader.c \
  36. cc_strings.c \
  37. cc_types.c \
  38. cc_core.c \
  39. cc_macro.c \
  40. cc.c \
  41. cc.h \
  42. cc_globals.c \
  43. gcc_req.h \
  44. -o bin/M2-Planet
  45. M2-minimal: bin results cc.h cc_reader.c cc_strings.c cc_types.c cc_core.c cc-minimal.c
  46. $(CC) $(CFLAGS) \
  47. functions/match.c \
  48. functions/in_set.c \
  49. functions/numerate_number.c \
  50. functions/file_print.c \
  51. functions/number_pack.c \
  52. functions/string.c \
  53. functions/require.c \
  54. functions/fixup.c \
  55. cc_reader.c \
  56. cc_strings.c \
  57. cc_types.c \
  58. cc_core.c \
  59. cc-minimal.c \
  60. cc.h \
  61. cc_globals.c \
  62. gcc_req.h \
  63. -o bin/M2-minimal
  64. # Clean up after ourselves
  65. .PHONY: clean
  66. clean:
  67. rm -rf bin/ test/results/
  68. ./test/cleanup_test.sh 0000
  69. ./test/cleanup_test.sh 0001
  70. ./test/cleanup_test.sh 0002
  71. ./test/cleanup_test.sh 0003
  72. ./test/cleanup_test.sh 0004
  73. ./test/cleanup_test.sh 0005
  74. ./test/cleanup_test.sh 0006
  75. ./test/cleanup_test.sh 0007
  76. ./test/cleanup_test.sh 0008
  77. ./test/cleanup_test.sh 0009
  78. ./test/cleanup_test.sh 0010
  79. ./test/cleanup_test.sh 0011
  80. ./test/cleanup_test.sh 0012
  81. ./test/cleanup_test.sh 0013
  82. ./test/cleanup_test.sh 0014
  83. ./test/cleanup_test.sh 0015
  84. ./test/cleanup_test.sh 0016
  85. ./test/cleanup_test.sh 0017
  86. ./test/cleanup_test.sh 0018
  87. ./test/cleanup_test.sh 0019
  88. ./test/cleanup_test.sh 0020
  89. ./test/cleanup_test.sh 0021
  90. ./test/cleanup_test.sh 0022
  91. ./test/cleanup_test.sh 0023
  92. ./test/cleanup_test.sh 0024
  93. ./test/cleanup_test.sh 0025
  94. ./test/cleanup_test.sh 0100
  95. ./test/cleanup_test.sh 0101
  96. ./test/cleanup_test.sh 0102
  97. ./test/cleanup_test.sh 0103
  98. ./test/cleanup_test.sh 0104
  99. ./test/cleanup_test.sh 0105
  100. ./test/cleanup_test.sh 0106
  101. ./test/cleanup_test.sh 1000
  102. # Directories
  103. bin:
  104. mkdir -p bin
  105. results:
  106. mkdir -p test/results
  107. # tests
  108. test: M2-Planet | bin results
  109. +make -f makefile-tests --output-sync
  110. sha256sum -c test/test.answers
  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: M2-Planet
  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)