Makefile 1.8 KB

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