Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. test_files = test_files
  2. exec_target = $(addsuffix .manifest,gcc as ld cc1 collect2)
  3. clean-extra = clean-garbages
  4. huge_rule = sys.stack.size = 64M\nsys.brk.size = 256M\nglibc.heap_size = 16M\nsgx.enclave_size = 2G
  5. extra_rules = \
  6. -e 's:\$$(DEBUGTYPE):$(if $(DEBUG),inline,none):g' \
  7. -e 's:\$$(GCCDIR):$(patsubst %/cc1,%,$(shell gcc -print-file-name=cc1)):g' \
  8. -e 's:\$$(HUGERULE):$(if $(HUGE),$(huge_rule),):g'
  9. level = ../../
  10. include ../../Makefile
  11. GCC_VER = 4.8.4
  12. BINUTILS_VER = 2.20.1
  13. GMP_SRC = gmp-5.1.3
  14. GMP_OBJ = libgmp.so.3
  15. GMPXX_OBJ = libgmpxx.so.4
  16. PPL_SRC = ppl-1.1
  17. PPL_OBJ = libppl_c.so.2
  18. MPFR_SRC = mpfr-3.1.2
  19. MPFR_OBJ = libmpfr.so.1
  20. MPC_SRC = mpc-1.0.1
  21. MPC_OBJ = libmpc.so.2
  22. LINK_LIBC =
  23. GCC_FLAGS = \
  24. --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-gnu-ld \
  25. --enable-languages=c,c++ --disable-shared --disable-multilib \
  26. --with-gmp=$(PWD)/obj --with-mpfr=$(PWD)/obj --with-mpc=$(PWD)/obj --without-cloog \
  27. --without-htmldir --without-pdfdir --without-docdir --without-datarootdir \
  28. --disable-cloog-version-check --disable-stage1-languages --disable-objc-gc \
  29. --disable-bootstrap --disable-maintainer-mode --disable-werror \
  30. $(LINK_LIBC)
  31. GCC_MAKE_FLAGS = \
  32. LD_LIBRARY_PATH="$(PWD)/obj/lib:/usr/lib:/lib"
  33. obj/bin/gcc: src/gcc-$(GCC_VER) obj/bin/ld $(addprefix obj/lib/,$(GMP_OBJ) $(GMPXX_OBJ) $(PPL_OBJ) $(MPFR_OBJ) $(MPC_OBJ))
  34. cd $< && ./configure --prefix=$(PWD)/obj $(GCC_FLAGS)
  35. $(MAKE) -C $< $(GCC_MAKE_FLAGS)
  36. $(MAKE) -C $< install
  37. src/gcc-$(GCC_VER): gcc-$(GCC_VER).tar.bz2 src
  38. cd src && tar -xjf ../$<
  39. obj/bin/ld: src/binutils-$(BINUTILS_VER)
  40. cd $< && ./configure --prefix=$(PWD)/obj $(GCC_FLAGS) --enable-shared
  41. $(MAKE) -C $< $(GCC_MAKE_FLAGS)
  42. $(MAKE) -C $< install
  43. src/binutils-$(BINUTILS_VER): binutils-$(BINUTILS_VER).tar.bz2 src
  44. cd src && tar -xjf ../$<
  45. obj/lib/$(GMP_OBJ) obj/lib/$(GMPXX_OBJ): src/$(GMP_SRC)
  46. cd $< && ./configure --prefix=$(PWD)/obj --enable-cxx --enable-shared \
  47. $(LINK_LIBC)
  48. $(MAKE) -C $<
  49. $(MAKE) -C $< install
  50. src/$(GMP_SRC): $(GMP_SRC).tar.bz2 src
  51. cd src && tar -xjf ../$<
  52. obj/lib/$(PPL_OBJ): src/$(PPL_SRC) obj/lib/$(GMP_OBJ)
  53. cd $< && ./configure --prefix=$(PWD)/obj --with-libgmp-prefix=$(PWD)/obj --enable-shared \
  54. $(LINK_LIBC) CXXFLAGS=-fpermissive
  55. $(MAKE) -C $<
  56. $(MAKE) -C $< install
  57. src/$(PPL_SRC): $(PPL_SRC).tar.gz src
  58. cd src && tar -xzf ../$<
  59. obj/lib/$(MPFR_OBJ): src/$(MPFR_SRC) obj/lib/$(GMP_OBJ)
  60. cd $< && ./configure --prefix=$(PWD)/obj --enable-shared \
  61. $(LINK_LIBC) CXXFLAGS=-D__gmp_const=const
  62. $(MAKE) -C $<
  63. $(MAKE) -C $< install
  64. src/$(MPFR_SRC): $(MPFR_SRC).tar.bz2 src
  65. cd src && tar -xjf ../$<
  66. obj/lib/$(MPC_OBJ): src/$(MPC_SRC)
  67. cd $< && ./configure --prefix=$(PWD)/obj --with-gmp=$(PWD)/obj --enable-shared \
  68. $(LINK_LIBC)
  69. $(MAKE) -C $<
  70. $(MAKE) -C $< install
  71. src/$(MPC_SRC): $(MPC_SRC).tar.gz src
  72. cd src && tar -xzf ../$<
  73. regression:
  74. @echo "\n\nBuilding GCC..."
  75. @$(MAKE) >> /dev/null 2>&1
  76. @echo "\n\nCompile hello.c:"
  77. -./gcc.manifest test_files/helloworld.c -o test_files/hello
  78. @chmod 755 test_files/hello
  79. -./test_files/hello
  80. @rm -f test_files/hello
  81. @echo "\n\nCompile bzip2.c:"
  82. -./gcc.manifest test_files/bzip2.c -o test_files/bzip2
  83. @chmod 755 test_files/bzip2
  84. @[ ! -f bzip2.tmp ] || rm -f bzip2.tmp
  85. @cp -f test_files/bzip2 test_files/bzip2.copy
  86. -./test_files/bzip2 -z test_files/bzip2.copy
  87. -./test_files/bzip2 -d test_files/bzip2.copy.bz2
  88. diff -q test_files/bzip2 test_files/bzip2.copy
  89. @rm -f test_files/bzip2 test_file/bzip2.copy
  90. @echo "\n\nCompile gzip.c:"
  91. -./gcc.manifest test_files/gzip.c -o test_files/gzip
  92. @chmod 755 test_files/gzip
  93. @cp -f test_files/gzip test_files/gzip.copy
  94. -./test_files/gzip test_files/gzip.copy
  95. -./test_files/gzip -d test_files/gzip.copy.gz
  96. diff -q test_files/gzip test_files/gzip.copy
  97. @rm -f test_files/gzip test_files/gzip.copy
  98. src:
  99. mkdir -p src
  100. distclean: clean
  101. rm -rf src obj
  102. clean-garbages:
  103. rm -rf cc*.s cc*.c cc*.ld cc*.le cc*.o a.out