Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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/pipe \
  56. unistd/rmdir \
  57. unistd/sleep \
  58. unistd/write \
  59. waitpid \
  60. wchar/mbrtowc \
  61. wchar/mbsrtowcs \
  62. wchar/putwchar \
  63. wchar/wcrtomb
  64. # Binaries that may generate varied output
  65. BINS=\
  66. $(EXPECT_BINS) \
  67. stdlib/alloc \
  68. stdlib/bsearch \
  69. stdlib/mktemp \
  70. unistd/chdir \
  71. unistd/gethostname \
  72. unistd/getid \
  73. unistd/link \
  74. unistd/setid \
  75. unistd/unlink
  76. all: $(BINS)
  77. clean:
  78. rm -f $(BINS) *.out
  79. ignore: $(BINS)
  80. echo "# Automatically generated by 'make ignore'" > .gitignore
  81. echo "/*.out" >> .gitignore
  82. echo "/gen/" >> .gitignore
  83. for bin in $^; \
  84. do \
  85. echo "$${bin}" >> .gitignore; \
  86. done
  87. run: $(BINS)
  88. for bin in $^; \
  89. do \
  90. echo "# $${bin} #"; \
  91. "./$${bin}" test args || exit $$?; \
  92. done
  93. expected: $(EXPECT_BINS)
  94. rm -rf expected
  95. mkdir -p expected
  96. for bin in $^; \
  97. do \
  98. echo "# $${bin} #"; \
  99. mkdir -p expected/`dirname $${bin}`; \
  100. "./$${bin}" test args > "expected/$${bin}.stdout" 2> "expected/$${bin}.stderr" || exit $$?; \
  101. done
  102. verify: $(EXPECT_BINS)
  103. rm -rf gen
  104. mkdir -p gen
  105. for bin in $^; \
  106. do \
  107. echo "# $${bin} #"; \
  108. mkdir -p gen/`dirname $${bin}`; \
  109. "./$${bin}" test args > "gen/$${bin}.stdout" 2> "gen/$${bin}.stderr" || exit $$?; \
  110. diff -u "gen/$${bin}.stdout" "expected/$${bin}.stdout" || exit $$?; \
  111. diff -u "gen/$${bin}.stderr" "expected/$${bin}.stderr" || exit $$?; \
  112. done
  113. CFLAGS=\
  114. -nostdinc \
  115. -nostdlib \
  116. -I ../include \
  117. -I ../target/include \
  118. -I ../target/openlibm/include \
  119. -I ../target/openlibm/src \
  120. HEADLIBS=\
  121. ../target/debug/crt0.o
  122. TAILLIBS=\
  123. ../target/debug/libc.a \
  124. ../target/openlibm/libopenlibm.a
  125. %: %.c $(HEADLIBS) $(TAILLIBS)
  126. gcc -fno-builtin -fno-stack-protector -Wall -g $(CFLAGS) $(HEADLIBS) "$<" $(TAILLIBS) -o "$@"