makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. PACKAGE = m2-planet
  19. # C compiler settings
  20. CC?=gcc
  21. CFLAGS:=$(CFLAGS) -D_GNU_SOURCE -O0 -std=c99 -ggdb -Wall -Wextra -Wstrict-prototypes -pedantic
  22. all: bin/M2-Planet
  23. .NOTPARALLEL:
  24. M2-Planet: bin/M2-Planet
  25. bin/M2-Planet: bin test/results cc.h cc_reader.c cc_strings.c cc_types.c cc_core.c cc.c cc_globals.c cc_globals.h cc_macro.c | bin
  26. $(CC) $(CFLAGS) \
  27. M2libc/bootstrappable.c \
  28. cc_reader.c \
  29. cc_strings.c \
  30. cc_types.c \
  31. cc_core.c \
  32. cc_macro.c \
  33. cc.c \
  34. cc.h \
  35. cc_globals.c \
  36. gcc_req.h \
  37. -o $@
  38. M2-minimal: bin/M2-minimal
  39. bin/M2-minimal: bin test/results cc.h cc_reader.c cc_strings.c cc_types.c cc_core.c cc-minimal.c
  40. $(CC) $(CFLAGS) \
  41. M2libc/bootstrappable.c \
  42. cc_reader.c \
  43. cc_strings.c \
  44. cc_types.c \
  45. cc_core.c \
  46. cc-minimal.c \
  47. cc.h \
  48. cc_globals.c \
  49. gcc_req.h \
  50. -o $@
  51. # Clean up after ourselves
  52. .PHONY: clean M2-Planet M2-minimal
  53. clean:
  54. rm -rf bin/ test/results/
  55. ./test/cleanup_test.sh 0000
  56. ./test/cleanup_test.sh 0001
  57. ./test/cleanup_test.sh 0002
  58. ./test/cleanup_test.sh 0003
  59. ./test/cleanup_test.sh 0004
  60. ./test/cleanup_test.sh 0005
  61. ./test/cleanup_test.sh 0006
  62. ./test/cleanup_test.sh 0007
  63. ./test/cleanup_test.sh 0008
  64. ./test/cleanup_test.sh 0009
  65. ./test/cleanup_test.sh 0010
  66. ./test/cleanup_test.sh 0011
  67. ./test/cleanup_test.sh 0012
  68. ./test/cleanup_test.sh 0013
  69. ./test/cleanup_test.sh 0014
  70. ./test/cleanup_test.sh 0015
  71. ./test/cleanup_test.sh 0016
  72. ./test/cleanup_test.sh 0017
  73. ./test/cleanup_test.sh 0018
  74. ./test/cleanup_test.sh 0019
  75. ./test/cleanup_test.sh 0020
  76. ./test/cleanup_test.sh 0021
  77. ./test/cleanup_test.sh 0022
  78. ./test/cleanup_test.sh 0023
  79. ./test/cleanup_test.sh 0024
  80. ./test/cleanup_test.sh 0025
  81. ./test/cleanup_test.sh 0026
  82. ./test/cleanup_test.sh 0027
  83. ./test/cleanup_test.sh 0028
  84. ./test/cleanup_test.sh 0029
  85. ./test/cleanup_test.sh 0030
  86. ./test/cleanup_test.sh 0031
  87. ./test/cleanup_test.sh 0100
  88. ./test/cleanup_test.sh 0101
  89. ./test/cleanup_test.sh 0102
  90. ./test/cleanup_test.sh 0103
  91. ./test/cleanup_test.sh 0104
  92. ./test/cleanup_test.sh 0105
  93. ./test/cleanup_test.sh 0106
  94. ./test/cleanup_test.sh 1000
  95. # Directories
  96. bin:
  97. mkdir -p bin
  98. test/results:
  99. mkdir -p test/results
  100. # tests
  101. test: bin/M2-Planet | bin test/results
  102. +make -f makefile-tests --output-sync
  103. sha256sum -c test/test.answers
  104. # Generate test answers
  105. .PHONY: Generate-test-answers
  106. Generate-test-answers:
  107. sha256sum test/results/* >| test/test.answers
  108. DESTDIR:=
  109. PREFIX:=/usr/local
  110. bindir:=$(DESTDIR)$(PREFIX)/bin
  111. .PHONY: install
  112. install: bin/M2-Planet
  113. mkdir -p $(bindir)
  114. cp $^ $(bindir)
  115. ### dist
  116. .PHONY: dist
  117. COMMIT=$(shell git describe --dirty)
  118. TARBALL_VERSION=$(COMMIT:Release_%=%)
  119. TARBALL_DIR:=$(PACKAGE)-$(TARBALL_VERSION)
  120. TARBALL=$(TARBALL_DIR).tar.gz
  121. # Be friendly to Debian; avoid using EPOCH
  122. MTIME=$(shell git show HEAD --format=%ct --no-patch)
  123. # Reproducible tarball
  124. TAR_FLAGS=--sort=name --mtime=@$(MTIME) --owner=0 --group=0 --numeric-owner --mode=go=rX,u+rw,a-s
  125. $(TARBALL):
  126. (git ls-files --recurse-submodules \
  127. --exclude=$(TARBALL_DIR); \
  128. echo $^ | tr ' ' '\n') \
  129. | tar $(TAR_FLAGS) \
  130. --transform=s,^,$(TARBALL_DIR)/,S -T- -cf- \
  131. | gzip -c --no-name > $@
  132. dist: $(TARBALL)