Makefile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. TOPDIR=../
  2. include $(TOPDIR)Rules.make
  3. XCFLAGS = -Wall -Os -fomit-frame-pointer -fno-builtin -nostdinc \
  4. -I$(TOPDIR)include -I/usr/include/linux
  5. XLDFLAGS = -nostdlib -s -gc-sections
  6. EXTRA_LIBS=$(TOPDIR)libc.a
  7. YCFLAGS = -Wall -Os -fomit-frame-pointer
  8. YLDFLAGS = -s --static
  9. # Allow alternative stripping tools to be used...
  10. ifndef $(STRIPTOOL)
  11. STRIPTOOL = strip
  12. endif
  13. STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $@
  14. TARGETS=hello_source hello_glibc hello testmalloc_source testmalloc_glibc testmalloc
  15. all: $(TARGETS)
  16. hello_source:
  17. -@ rm -f $(TARGETS)
  18. -@ echo "-------"
  19. -@ echo "hello.c source: "
  20. -@ echo " "
  21. -@ cat hello.c
  22. -@ echo " "
  23. hello: hello.c Makefile $(TOPDIR)libc.a
  24. -@ echo "-------"
  25. -@ echo " "
  26. -@ echo "Compiling vs uC-Libc: "
  27. -@ echo " "
  28. $(CC) $(XCFLAGS) -c $< -o $@.o
  29. $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
  30. $(STRIP)
  31. ldd $@
  32. ls -sh $@
  33. -./$@
  34. -@ echo " "
  35. hello_glibc: hello.c Makefile $(TOPDIR)libc.a
  36. -@ echo "-------"
  37. -@ echo " "
  38. -@ echo "Compiling vs GNU libc: "
  39. -@ echo " "
  40. $(CC) $(YCFLAGS) -c $< -o $@.o
  41. $(CC) $(YLDFLAGS) --static $@.o -o $@
  42. $(STRIP)
  43. ldd $@
  44. ls -sh $@
  45. -./$@
  46. -@ echo " "
  47. testmalloc_source:
  48. -@ echo "-------"
  49. -@ echo "testmalloc.c source: "
  50. -@ echo " "
  51. -@ cat testmalloc.c
  52. -@ echo " "
  53. testmalloc: testmalloc.c Makefile $(TOPDIR)libc.a
  54. -@ echo "-------"
  55. -@ echo " "
  56. -@ echo "Compiling vs uC-Libc: "
  57. -@ echo " "
  58. $(CC) $(XCFLAGS) -c $< -o $@.o
  59. $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
  60. $(STRIP)
  61. ldd $@
  62. ls -sh $@
  63. -./$@
  64. -@ echo " "
  65. testmalloc_glibc: testmalloc.c Makefile $(TOPDIR)libc.a
  66. -@ echo "-------"
  67. -@ echo " "
  68. -@ echo "Compiling vs GNU libc: "
  69. -@ echo " "
  70. $(CC) $(YCFLAGS) -c $< -o $@.o
  71. $(CC) $(YLDFLAGS) --static $@.o -o $@
  72. $(STRIP)
  73. ldd $@
  74. ls -sh $@
  75. -./$@
  76. -@ echo " "
  77. clean:
  78. rm -f *.[oa] *~ core $(TARGETS)