Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. # Binaries that should generate the same output every time
  2. EXPECT_BINS=\
  3. args \
  4. arpainet \
  5. assert \
  6. ctype \
  7. error \
  8. fcntl/create \
  9. fcntl/fcntl \
  10. fnmatch \
  11. locale \
  12. math \
  13. select \
  14. setjmp \
  15. signal \
  16. stdio/all \
  17. stdio/setvbuf \
  18. stdio/freopen \
  19. stdio/fwrite \
  20. stdio/getc_unget \
  21. stdio/printf \
  22. stdio/rename \
  23. stdio/scanf \
  24. stdio/sprintf \
  25. stdlib/a64l \
  26. stdlib/atof \
  27. stdlib/atoi \
  28. stdlib/env \
  29. stdlib/mkostemps \
  30. stdlib/rand \
  31. stdlib/strtod \
  32. stdlib/strtol \
  33. stdlib/strtoul \
  34. stdlib/system \
  35. string/mem \
  36. string/strchr \
  37. string/strcpy \
  38. string/strcspn \
  39. string/strncmp \
  40. string/strpbrk \
  41. string/strrchr \
  42. string/strspn \
  43. string/strstr \
  44. string/strtok \
  45. string/strtok_r \
  46. strings \
  47. time/asctime \
  48. time/gmtime \
  49. time/localtime \
  50. time/mktime \
  51. time/strftime \
  52. time/time \
  53. unistd/access \
  54. unistd/brk \
  55. unistd/dup \
  56. unistd/exec \
  57. unistd/fchdir \
  58. unistd/fsync \
  59. unistd/ftruncate \
  60. unistd/getopt \
  61. unistd/isatty \
  62. unistd/pipe \
  63. unistd/rmdir \
  64. unistd/sleep \
  65. unistd/write \
  66. waitpid \
  67. wchar/mbrtowc \
  68. wchar/mbsrtowcs \
  69. wchar/putwchar \
  70. wchar/wcrtomb
  71. # Binaries that may generate varied output
  72. BINS=\
  73. $(EXPECT_BINS) \
  74. dirent \
  75. pwd \
  76. resource/getrusage \
  77. stdlib/alloc \
  78. stdlib/bsearch \
  79. stdlib/mktemp \
  80. time/gettimeofday \
  81. time/times \
  82. unistd/chdir \
  83. unistd/getcwd \
  84. unistd/gethostname \
  85. unistd/getid \
  86. unistd/link \
  87. unistd/setid \
  88. unistd/stat
  89. all: $(BINS)
  90. clean:
  91. rm -f $(BINS) *.out
  92. run: $(BINS)
  93. for bin in $^; \
  94. do \
  95. echo "# $${bin} #"; \
  96. "bins/$${bin}" test args || exit $$?; \
  97. done
  98. expected: $(EXPECT_BINS)
  99. rm -rf expected
  100. mkdir -p expected
  101. for bin in $^; \
  102. do \
  103. echo "# $${bin} #"; \
  104. mkdir -p expected/`dirname $${bin}`; \
  105. "bins/$${bin}" test args > "expected/$${bin}.stdout" 2> "expected/$${bin}.stderr" || exit $$?; \
  106. done
  107. verify: $(EXPECT_BINS)
  108. rm -rf gen
  109. mkdir -p gen
  110. for bin in $^; \
  111. do \
  112. echo "# $${bin} #"; \
  113. mkdir -p gen/`dirname $${bin}`; \
  114. "bins/$${bin}" test args > "gen/$${bin}.stdout" 2> "gen/$${bin}.stderr" || exit $$?; \
  115. diff -u "gen/$${bin}.stdout" "expected/$${bin}.stdout" || exit $$?; \
  116. diff -u "gen/$${bin}.stderr" "expected/$${bin}.stderr" || exit $$?; \
  117. done
  118. CFLAGS=\
  119. -nostdinc \
  120. -nostdlib \
  121. -I ../include \
  122. -I ../target/include \
  123. -I ../target/openlibm/include \
  124. -I ../target/openlibm/src \
  125. HEADLIBS=\
  126. ../target/debug/crt0.o
  127. TAILLIBS=\
  128. ../target/debug/libc.a \
  129. ../target/openlibm/libopenlibm.a
  130. %: %.c $(HEADLIBS) $(TAILLIBS)
  131. mkdir -p "bins/$$(dirname "$@")"
  132. gcc -fno-builtin -fno-stack-protector -Wall -g $(CFLAGS) $(HEADLIBS) "$<" $(TAILLIBS) -o "bins/$@"