Makefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. manifests = gcc g++ gcc-huge g++-huge gcc-local g++-local
  2. all debug: $(addsuffix .manifest, $(manifests))
  3. c_targets = helloworld gzip oggenc.m single-gcc
  4. test_targets = $(c_targets) $(make_targets)
  5. test: all $(test_targets)
  6. %.manifest: %.manifest.template
  7. make -C .. gcc/$@ appdir=gcc/
  8. $(c_targets): %: %.c
  9. echo "$@ (native):" >> result
  10. rm -rf $@
  11. time -a -o result -p gcc -o $@ $^ \
  12. $(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
  13. sleep 0.5
  14. echo "$@ (graphene):" >> result
  15. rm -rf $@
  16. time -a -o result -p ./gcc.manifest -o $@ $^ \
  17. $(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
  18. $(make_targets): %:
  19. echo "$@ (native2):" >> result
  20. make -C $(dir $@) clean
  21. time -a -o result -p make -C $(dir $@) $(notdir $@) CC=g++
  22. echo "$@ (graphene):" >> result
  23. make -C $(dir $@) clean
  24. time -a -o result -p make -C $(dir $@) $(notdir $@) CC=$(shell pwd)/g++.manifest
  25. gcc-local: obj/bin/gcc
  26. GCC_VER = 4.4.5
  27. BINUTILS_VER = 2.20.1
  28. GMP_SRC = gmp-4.3.2
  29. GMP_OBJ = libgmp.so.3
  30. PPL_SRC = ppl-0.10.2
  31. PPL_OBJ = libppl_c.so.2
  32. MPFR_SRC = mpfr-2.4.2
  33. MPFR_OBJ = libmpfr.so.1
  34. MPC_SRC = mpc-0.8.1
  35. MPC_OBJ = libmpc.so.2
  36. LINK_LIBC =
  37. MAKE = make #-j$(shell grep -c processor /proc/cpuinfo)
  38. GCC_FLAGS = \
  39. --with-build-libsubdir=$(PWD)/../../../../build \
  40. --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-gnu-ld \
  41. --enable-languages=c,c++ --disable-shared --disable-multilib \
  42. --with-gmp=$(PWD)/obj --with-mpfr=$(PWD)/obj --with-mpc=$(PWD)/obj --without-cloog \
  43. --without-htmldir --without-pdfdir --without-docdir --without-datarootdir \
  44. --disable-cloog-version-check --disable-stage1-languages --disable-objc-gc \
  45. --disable-bootstrap --disable-maintainer-mode --disable-werror \
  46. $(LINK_LIBC)
  47. GCC_MAKE_FLAGS = \
  48. LD_LIBRARY_PATH="$(PWD)/obj/lib:/usr/lib:/lib"
  49. obj/bin/gcc: src/gcc-$(GCC_VER) obj/bin/ld $(addprefix obj/lib/,$(GMP_OBJ) $(PPL_OBJ) $(MPFR_OBJ) $(MPC_OBJ))
  50. cd $< && ./configure --prefix=$(PWD)/obj $(GCC_FLAGS)
  51. $(MAKE) -C $< $(GCC_MAKE_FLAGS) $(if $(CFLAGS),CFLAGS="$(CFLAGS)",)
  52. $(MAKE) -C $< install
  53. src/gcc-$(GCC_VER): gcc-$(GCC_VER).tar.bz2 src
  54. cd src && tar -xjf ../$<
  55. obj/bin/ld: src/binutils-$(BINUTILS_VER)
  56. cd $< && ./configure --prefix=$(PWD)/obj $(GCC_FLAGS)
  57. $(MAKE) -C $< $(GCC_MAKE_FLAGS) $(if $(CFLAGS),CFLAGS="$(CFLAGS)",)
  58. $(MAKE) -C $< install
  59. src/binutils-$(BINUTILS_VER): binutils-$(BINUTILS_VER).tar.bz2 src
  60. cd src && tar -xjf ../$<
  61. obj/lib/$(GMP_OBJ): src/$(GMP_SRC)
  62. cd $< && ./configure --prefix=$(PWD)/obj --enable-cxx \
  63. $(LINK_LIBC)
  64. $(MAKE) -C $< $(if $(CFLAGS),CFLAGS="$(CFLAGS)",)
  65. $(MAKE) -C $< install
  66. src/$(GMP_SRC): $(GMP_SRC).tar.bz2 src
  67. cd src && tar -xjf ../$<
  68. obj/lib/$(PPL_OBJ): src/$(PPL_SRC) obj/lib/$(GMP_OBJ)
  69. cd $< && ./configure --prefix=$(PWD)/obj --with-libgmp-prefix=$(PWD)/obj \
  70. $(LINK_LIBC)
  71. $(MAKE) -C $< $(if $(CFLAGS),CFLAGS="$(CFLAGS)",)
  72. $(MAKE) -C $< install
  73. src/$(PPL_SRC): $(PPL_SRC).tar.gz src
  74. cd src && tar -xzf ../$<
  75. obj/lib/$(MPFR_OBJ): src/$(MPFR_SRC) obj/lib/$(GMP_OBJ)
  76. cd $< && ./configure --prefix=$(PWD)/obj \
  77. $(LINK_LIBC)
  78. $(MAKE) -C $< $(if $(CFLAGS),CFLAGS="$(CFLAGS)",)
  79. $(MAKE) -C $< install
  80. src/$(MPFR_SRC): $(MPFR_SRC).tar.bz2 src
  81. cd src && tar -xjf ../$<
  82. obj/lib/$(MPC_OBJ): src/$(MPC_SRC)
  83. cd $< && ./configure --prefix=$(PWD)/obj --with-gmp=$(PWD)/obj \
  84. $(LINK_LIBC)
  85. $(MAKE) -C $< $(if $(CFLAGS),CFLAGS="$(CFLAGS)",)
  86. $(MAKE) -C $< install
  87. src/$(MPC_SRC): $(MPC_SRC).tar.gz src
  88. cd src && tar -xzf ../$<
  89. src:
  90. mkdir -p src
  91. test-native:
  92. echo "Result for helloworld(native)" >> result
  93. /usr/bin/time -a -o result -p gcc helloworld.c
  94. echo "Result for gzip.c(native)" >> result
  95. /usr/bin/time -a -o result -p gcc gzip.c
  96. echo "Result for oggenc.m.c(native)" >> result
  97. /usr/bin/time -a -o result -p gcc oggenc.m.c -lm
  98. echo "Result for single-gcc.c(native)" >> result
  99. /usr/bin/time -a -o result -p gcc single-gcc.c
  100. test-graphene:
  101. echo "Result for helloworld(graphene)" >> result
  102. /usr/bin/time -a -o result -p ./gcc.manifest helloworld.c
  103. echo "Result for gzip.c(graphene)" >> result
  104. /usr/bin/time -a -o result -p ./gcc-huge.manifest gzip.c
  105. echo "Result for oggenc.m.c(graphene)" >> result
  106. /usr/bin/time -a -o result -p ./gcc-huge.manifest oggenc.m.c -lm
  107. echo "Result for single-gcc.c(graphene)" >> result
  108. /usr/bin/time -a -o result -p ./gcc-huge.manifest single-gcc.c
  109. distclean: clean
  110. rm -rf src obj
  111. clean: clean-manifests clean-garbages
  112. rm -rf result $(test_targets)
  113. clean-manifests:
  114. rm -rf $(addsuffix .manifest, $(manifests))
  115. clean-garbages:
  116. rm -rf cc*.s cc*.c cc*.ld cc*.le cc*.o