Makefile 2.5 KB

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