Makefile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. stdlib/alloc \
  71. stdlib/bsearch \
  72. stdlib/mktemp \
  73. time/gettimeofday \
  74. unistd/chdir \
  75. unistd/gethostname \
  76. unistd/getid \
  77. unistd/link \
  78. unistd/setid \
  79. unistd/stat
  80. all: $(BINS)
  81. clean:
  82. rm -f $(BINS) *.out
  83. ignore: $(BINS)
  84. echo "# Automatically generated by 'make ignore'" > .gitignore
  85. echo "/*.out" >> .gitignore
  86. echo "/gen/" >> .gitignore
  87. for bin in $^; \
  88. do \
  89. echo "$${bin}" >> .gitignore; \
  90. done
  91. run: $(BINS)
  92. for bin in $^; \
  93. do \
  94. echo "# $${bin} #"; \
  95. "./$${bin}" test args || exit $$?; \
  96. done
  97. expected: $(EXPECT_BINS)
  98. rm -rf expected
  99. mkdir -p expected
  100. for bin in $^; \
  101. do \
  102. echo "# $${bin} #"; \
  103. mkdir -p expected/`dirname $${bin}`; \
  104. "./$${bin}" test args > "expected/$${bin}.stdout" 2> "expected/$${bin}.stderr" || exit $$?; \
  105. done
  106. verify: $(EXPECT_BINS)
  107. rm -rf gen
  108. mkdir -p gen
  109. for bin in $^; \
  110. do \
  111. echo "# $${bin} #"; \
  112. mkdir -p gen/`dirname $${bin}`; \
  113. "./$${bin}" test args > "gen/$${bin}.stdout" 2> "gen/$${bin}.stderr" || exit $$?; \
  114. diff -u "gen/$${bin}.stdout" "expected/$${bin}.stdout" || exit $$?; \
  115. diff -u "gen/$${bin}.stderr" "expected/$${bin}.stderr" || exit $$?; \
  116. done
  117. CFLAGS=\
  118. -nostdinc \
  119. -nostdlib \
  120. -I ../include \
  121. -I ../target/include \
  122. -I ../target/openlibm/include \
  123. -I ../target/openlibm/src \
  124. HEADLIBS=\
  125. ../target/debug/crt0.o
  126. TAILLIBS=\
  127. ../target/debug/libc.a \
  128. ../target/openlibm/libopenlibm.a
  129. %: %.c $(HEADLIBS) $(TAILLIBS)
  130. gcc -fno-builtin -fno-stack-protector -Wall -g $(CFLAGS) $(HEADLIBS) "$<" $(TAILLIBS) -o "$@"