Makefile 2.5 KB

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