Makefile 2.3 KB

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