Makefile 2.5 KB

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