Makefile 2.6 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. locale \
  11. math \
  12. setjmp \
  13. signal \
  14. stdio/all \
  15. stdio/freopen \
  16. stdio/fwrite \
  17. stdio/getc_unget \
  18. stdio/printf \
  19. stdio/rename \
  20. stdio/scanf \
  21. stdio/sprintf \
  22. stdlib/a64l \
  23. stdlib/atof \
  24. stdlib/atoi \
  25. stdlib/env \
  26. stdlib/mkostemps \
  27. stdlib/rand \
  28. stdlib/strtol \
  29. stdlib/strtoul \
  30. stdlib/system \
  31. string/mem \
  32. string/strchr \
  33. string/strcspn \
  34. string/strncmp \
  35. string/strpbrk \
  36. string/strrchr \
  37. string/strspn \
  38. string/strstr \
  39. string/strtok \
  40. string/strtok_r \
  41. strings \
  42. time/asctime \
  43. time/gmtime \
  44. time/localtime \
  45. time/mktime \
  46. time/strftime \
  47. time/time \
  48. unistd/brk \
  49. unistd/dup \
  50. unistd/exec \
  51. unistd/fchdir \
  52. unistd/fsync \
  53. unistd/ftruncate \
  54. unistd/getopt \
  55. unistd/isatty \
  56. unistd/pipe \
  57. unistd/rmdir \
  58. unistd/sleep \
  59. unistd/write \
  60. waitpid \
  61. wchar/mbrtowc \
  62. wchar/mbsrtowcs \
  63. wchar/putwchar \
  64. wchar/wcrtomb
  65. # Binaries that may generate varied output
  66. BINS=\
  67. $(EXPECT_BINS) \
  68. dirent \
  69. pwd \
  70. resource/getrusage \
  71. stdlib/alloc \
  72. stdlib/bsearch \
  73. stdlib/mktemp \
  74. time/gettimeofday \
  75. unistd/chdir \
  76. unistd/gethostname \
  77. unistd/getid \
  78. unistd/link \
  79. unistd/setid \
  80. unistd/stat
  81. all: $(BINS)
  82. clean:
  83. rm -f $(BINS) *.out
  84. ignore: $(BINS)
  85. echo "# Automatically generated by 'make ignore'" > .gitignore
  86. echo "/*.out" >> .gitignore
  87. echo "/gen/" >> .gitignore
  88. for bin in $^; \
  89. do \
  90. echo "$${bin}" >> .gitignore; \
  91. done
  92. run: $(BINS)
  93. for bin in $^; \
  94. do \
  95. echo "# $${bin} #"; \
  96. "./$${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. "./$${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. "./$${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. gcc -fno-builtin -fno-stack-protector -Wall -g $(CFLAGS) $(HEADLIBS) "$<" $(TAILLIBS) -o "$@"