Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. TOPDIR=../../
  2. include $(TOPDIR)Rules.mak
  3. # Check if 'ls -sh' works or not
  4. LSFLAGS = $(shell if ls -sh >/dev/null 2>&1; \
  5. then echo "-sh"; else echo "-s" ; fi)
  6. XCFLAGS = -Wall -Os -fomit-frame-pointer -fno-builtin -nostdinc \
  7. -I$(TOPDIR)include -I/usr/include/linux
  8. XLDFLAGS = -nostdlib -s -gc-sections
  9. EXTRA_LIBS=$(TOPDIR)libc.a
  10. YCFLAGS = -Wall -Os -fomit-frame-pointer
  11. YLDFLAGS = -s --static
  12. # Allow alternative stripping tools to be used...
  13. ifndef $(STRIPTOOL)
  14. STRIPTOOL = strip
  15. endif
  16. STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $@
  17. TARGETS=testmalloc testmalloc_glibc
  18. TARGETS=mallocbug mallocbug_glibc
  19. TARGETS+=teststrtol teststrtol_glibc teststrtol_diff
  20. all: $(TARGETS)
  21. testmalloc_source:
  22. -@ echo "-------"
  23. -@ echo "testmalloc.c source: "
  24. -@ echo " "
  25. -@ cat testmalloc.c
  26. -@ echo " "
  27. testmalloc: testmalloc.c Makefile $(TOPDIR)libc.a
  28. -@ echo "-------"
  29. -@ echo " "
  30. -@ echo "Compiling vs uC-Libc: "
  31. -@ echo " "
  32. $(CC) $(XCFLAGS) -c $< -o $@.o
  33. $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
  34. $(STRIP)
  35. -ldd $@
  36. ls $(LSFLAGS) $@
  37. -./$@
  38. -@ echo " "
  39. testmalloc_glibc: testmalloc.c Makefile $(TOPDIR)libc.a
  40. -@ echo "-------"
  41. -@ echo " "
  42. -@ echo "Compiling vs GNU libc: "
  43. -@ echo " "
  44. $(CC) $(YCFLAGS) -c $< -o $@.o
  45. $(CC) $(YLDFLAGS) --static $@.o -o $@
  46. $(STRIP)
  47. -ldd $@
  48. ls $(LSFLAGS) $@
  49. -./$@
  50. -@ echo " "
  51. mallocbug: mallocbug.c Makefile $(TOPDIR)libc.a
  52. -@ echo "-------"
  53. -@ echo " "
  54. -@ echo "Compiling vs uC-Libc: "
  55. -@ echo " "
  56. $(CC) -g $(XCFLAGS) -c $< -o $@.o
  57. $(CC) -g $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
  58. $(STRIP)
  59. -ldd $@
  60. ls $(LSFLAGS) $@
  61. -./$@
  62. -@ echo " "
  63. mallocbug_glibc: mallocbug.c Makefile $(TOPDIR)libc.a
  64. -@ echo "-------"
  65. -@ echo " "
  66. -@ echo "Compiling vs GNU libc: "
  67. -@ echo " "
  68. $(CC) $(YCFLAGS) -c $< -o $@.o
  69. $(CC) $(YLDFLAGS) --static $@.o -o $@
  70. $(STRIP)
  71. -ldd $@
  72. ls $(LSFLAGS) $@
  73. -./$@
  74. -@ echo " "
  75. teststrtol_source:
  76. -@ echo "-------"
  77. -@ echo "teststrtol.c source: "
  78. -@ echo " "
  79. -@ cat teststrtol.c
  80. -@ echo " "
  81. teststrtol: teststrtol.c Makefile $(TOPDIR)libc.a
  82. -@ echo "-------"
  83. -@ echo " "
  84. -@ echo "Compiling vs uC-Libc: "
  85. -@ echo " "
  86. $(CC) $(XCFLAGS) -c $< -o $@.o
  87. $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
  88. $(STRIP)
  89. ldd $@
  90. ls -sh $@
  91. -./$@ > $@.out
  92. -@ echo " "
  93. teststrtol_glibc: teststrtol.c Makefile $(TOPDIR)libc.a
  94. -@ echo "-------"
  95. -@ echo " "
  96. -@ echo "Compiling vs GNU libc: "
  97. -@ echo " "
  98. $(CC) $(YCFLAGS) -c $< -o $@.o
  99. $(CC) $(YLDFLAGS) --static $@.o -o $@
  100. $(STRIP)
  101. ldd $@
  102. ls -sh $@
  103. -./$@ > $@.out
  104. -@ echo " "
  105. teststrtol_diff: teststrtol_glibc teststrtol
  106. -@ echo "-------"
  107. -@ echo " "
  108. -@ echo "Diffing output: "
  109. -@ echo " "
  110. -diff -u teststrtol_glibc.out teststrtol.out
  111. -@ echo " "
  112. clean:
  113. rm -f *.[oa] *~ core $(TARGETS)