Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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/strtol \
  32. stdlib/strtoul \
  33. stdlib/system \
  34. string/mem \
  35. string/strchr \
  36. string/strcpy \
  37. string/strcspn \
  38. string/strncmp \
  39. string/strpbrk \
  40. string/strrchr \
  41. string/strspn \
  42. string/strstr \
  43. string/strtok \
  44. string/strtok_r \
  45. strings \
  46. time/asctime \
  47. time/gmtime \
  48. time/localtime \
  49. time/mktime \
  50. time/strftime \
  51. time/time \
  52. unistd/access \
  53. unistd/brk \
  54. unistd/dup \
  55. unistd/exec \
  56. unistd/fchdir \
  57. unistd/fsync \
  58. unistd/ftruncate \
  59. unistd/getopt \
  60. unistd/isatty \
  61. unistd/pipe \
  62. unistd/rmdir \
  63. unistd/sleep \
  64. unistd/write \
  65. waitpid \
  66. wchar/mbrtowc \
  67. wchar/mbsrtowcs \
  68. wchar/putwchar \
  69. wchar/wcrtomb
  70. # Binaries that may generate varied output
  71. BINS=\
  72. $(EXPECT_BINS) \
  73. dirent \
  74. pwd \
  75. resource/getrusage \
  76. stdlib/alloc \
  77. stdlib/bsearch \
  78. stdlib/mktemp \
  79. time/gettimeofday \
  80. time/times \
  81. unistd/chdir \
  82. unistd/getcwd \
  83. unistd/gethostname \
  84. unistd/getid \
  85. unistd/link \
  86. unistd/setid \
  87. unistd/stat
  88. all: $(BINS)
  89. clean:
  90. rm -f $(BINS) *.out
  91. run: $(BINS)
  92. for bin in $^; \
  93. do \
  94. echo "# $${bin} #"; \
  95. "bins/$${bin}" test args || exit $$?; \
  96. done
  97. expected: $(EXPECT_BINS)
  98. rm -rf expected
  99. mkdir -p expected
  100. for bin in $^; \
  101. do \
  102. echo "# $${bin} #"; \
  103. mkdir -p expected/`dirname $${bin}`; \
  104. "bins/$${bin}" test args > "expected/$${bin}.stdout" 2> "expected/$${bin}.stderr" || exit $$?; \
  105. done
  106. verify: $(EXPECT_BINS)
  107. rm -rf gen
  108. mkdir -p gen
  109. for bin in $^; \
  110. do \
  111. echo "# $${bin} #"; \
  112. mkdir -p gen/`dirname $${bin}`; \
  113. "bins/$${bin}" test args > "gen/$${bin}.stdout" 2> "gen/$${bin}.stderr" || exit $$?; \
  114. diff -u "gen/$${bin}.stdout" "expected/$${bin}.stdout" || exit $$?; \
  115. diff -u "gen/$${bin}.stderr" "expected/$${bin}.stderr" || exit $$?; \
  116. done
  117. CFLAGS=\
  118. -nostdinc \
  119. -nostdlib \
  120. -I ../include \
  121. -I ../target/include \
  122. -I ../target/openlibm/include \
  123. -I ../target/openlibm/src \
  124. HEADLIBS=\
  125. ../target/debug/crt0.o
  126. TAILLIBS=\
  127. ../target/debug/libc.a \
  128. ../target/openlibm/libopenlibm.a
  129. %: %.c $(HEADLIBS) $(TAILLIBS)
  130. mkdir -p "bins/$$(dirname "$@")"
  131. gcc -fno-builtin -fno-stack-protector -Wall -g $(CFLAGS) $(HEADLIBS) "$<" $(TAILLIBS) -o "bins/$@"