Makefile 2.6 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. 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. stdlib/alloc \
  70. stdlib/bsearch \
  71. stdlib/mktemp \
  72. time/gettimeofday \
  73. unistd/chdir \
  74. unistd/gethostname \
  75. unistd/getid \
  76. unistd/link \
  77. unistd/setid \
  78. unistd/stat
  79. all: $(BINS)
  80. clean:
  81. rm -f $(BINS) *.out
  82. ignore: $(BINS)
  83. echo "# Automatically generated by 'make ignore'" > .gitignore
  84. echo "/*.out" >> .gitignore
  85. echo "/gen/" >> .gitignore
  86. for bin in $^; \
  87. do \
  88. echo "$${bin}" >> .gitignore; \
  89. done
  90. run: $(BINS)
  91. for bin in $^; \
  92. do \
  93. echo "# $${bin} #"; \
  94. "./$${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. "./$${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. "./$${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. gcc -fno-builtin -fno-stack-protector -Wall -g $(CFLAGS) $(HEADLIBS) "$<" $(TAILLIBS) -o "$@"