Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. NPROCS := 1
  2. OS := $(shell uname -s)
  3. ifeq ($(OS),Linux)
  4. NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
  5. endif
  6. target = $(patsubst %.java,%.class,$(wildcard classes/*.java))
  7. exec_target = java.manifest
  8. clean-extra = clean-classes
  9. JAVA_HOST_HOME = $(shell readlink -f /usr/bin/java | xargs dirname | xargs dirname)
  10. compact_rule = sys.stack.size = 1M\nsys.brk.size = 16M\nglibc.heap_size = 4M\nsgx.enclave_size = 4G\nsgx.thread_num = 16\nsgx.heap_min = 0x80000000
  11. large_rule = sys.stack.size = 4M\nsys.brk.size = 64M\nglibc.heap_size = 16M\nsgx.enclave_size = 8G\nsgx.thread_num = 32\nsgx.heap_min = 0x40000000
  12. ABSPATH_IN_MANIFEST = yes
  13. extra_rules = \
  14. -e 's:\$$(DEBUGTYPE):$(if $(DEBUG),inline,none):g' \
  15. -e 's:\$$(JAVA_HOME):$(JAVA_HOST_HOME):g' \
  16. -e 's:\$$(RESOURCE_RULE):$(if $(COMPACT),$(compact_rule),$(large_rule)):g'
  17. level = ../../
  18. include ../../Makefile
  19. TEST_CLASS = $(patsubst %.java,%,$(wildcard classes/*.java))
  20. USE_UBUNTU_SRC = no
  21. VERSION := 7
  22. ifeq ($(USE_UBUNTU_SRC),yes)
  23. ifeq ($(JRE_VERSION),7)
  24. JAVA_DIR = openjdk-7-7u79-2.5.5
  25. JAVA_HOME = openjdk-7-jre
  26. endif
  27. ifeq ($(JRE_VERSION),6)
  28. JAVA_DIR = openjdk-6-6b32-1.13.4
  29. JAVA_HOME = openjdk-6-jre
  30. endif
  31. ifndef JAVA_DIR
  32. $(error Unknown JRE Version)
  33. endif
  34. INSTALL_DIR = $(JAVA_DIR)/openjdk.build
  35. JRE_DIR = $(INSTALL_DIR)/j2sdk-image/jre
  36. JDK_DIR = $(INSTALL_DIR)/j2sdk-image
  37. JAVAC = $(JDK_DIR)/bin/javac
  38. TARGET = $(JAVA_HOME)/bin/java $(JAVAC)
  39. %/Makefile: %.tar.gz
  40. tar -xzf $<
  41. cd $(dir $@) && ./configure \
  42. --prefix=$(shell readlink -f $(INSTALL_DIR)) \
  43. --disable-docs \
  44. --enable-optimizations
  45. $(JRE_DIR)/bin/java $(JAVAC): $(JAVA_DIR)/Makefile
  46. cd $(JAVA_DIR) && make -j$(NPROCS) all $(MAKE_FLAGS)
  47. $(JAVA_HOME)/bin/java: $(JRE_DIR)/bin/java
  48. rm -rf $(JAVA_HOME)
  49. cp -rf $(JRE_DIR) $(JAVA_HOME)
  50. find $(JAVA_HOME) -type f -executable -exec strip --strip-debug {} \;
  51. distclean: clean
  52. rm -rf $(INSTALL_DIR) $(JAVA_HOME)
  53. else # USE_UBUNTU_SRC = no
  54. ifeq ($(VERSION),7)
  55. ICEDTEA_URL = http://icedtea.wildebeest.org/download/drops/icedtea7/2.7.0/
  56. JAVA_DIR = openjdk-7
  57. JAVA_SRC = $(JAVA_DIR) $(JAVA_DIR)/hotspot $(JAVA_DIR)/jdk $(JAVA_DIR)/jdk/src/share/lib/security/nss.cfg
  58. JAVA_HOME = openjdk-7-jre
  59. $(JAVA_DIR): openjdk.tar.bz2
  60. tar -xjf $<
  61. rm -rf $@
  62. mv $(shell tar -tjf $< | sed -e 's@/.*@@' | head -n 1) $@
  63. $(JAVA_DIR)/hotspot: hotspot.tar.bz2 | $(JAVA_DIR)
  64. tar -xjf $<
  65. rm -rf $@
  66. mv $(shell tar -tjf $< | sed -e 's@/.*@@' | head -n 1) $@
  67. $(JAVA_DIR)/jdk: jdk.tar.bz2 | $(JAVA_DIR)
  68. tar -xjf $<
  69. rm -rf $@
  70. cd $(shell tar -tjf $< | sed -e 's@/.*@@' | head -n 1) && patch -p1 < ../smaller-jdk.patch
  71. mv $(shell tar -tjf $< | sed -e 's@/.*@@' | head -n 1) $@
  72. openjdk.tar.bz2 hotspot.tar.bz2 jdk.tar.bz2:
  73. wget $(ICEDTEA_URL)$@
  74. $(JAVA_DIR)/jdk/src/share/lib/security/nss.cfg: $(JAVA_DIR)/jdk/src/share/lib/security/nss.cfg.in | $(JAVA_DIR)/jdk
  75. sed 's:@NSS_LIBDIR@:/usr/lib/x86_64-linux-gnu:g' $< > $@
  76. endif
  77. HOST_JAVA_HOME=$(subst /jre/bin/java,,$(shell readlink -f $(shell which java)))
  78. INSTALL_DIR = $(JAVA_DIR)/build/linux-amd64
  79. JRE_DIR = $(INSTALL_DIR)/j2sdk-image/jre
  80. JDK_DIR = $(INSTALL_DIR)/j2sdk-image
  81. JAVAC = $(JDK_DIR)/bin/javac
  82. $(JRE_DIR)/bin/java $(JAVAC): $(JAVA_SRC)
  83. cd $(JAVA_DIR) && \
  84. make \
  85. ALT_BOOTDIR=$(HOST_JAVA_HOME) \
  86. ALT_JDK_IMPORT_PATH=$(HOST_JAVA_HOME) \
  87. ANT=/usr/bin/ant \
  88. INSANE="true" \
  89. FT2_CFLAGS=$(shell pkg-config --cflags freetype2) \
  90. FT2_LIBS=$(shell pkg-config --libs freetype2) \
  91. STATIC_CXX="false" \
  92. EXTRA_CFLAGS="-fPIC" \
  93. NO_DOCS="true" \
  94. BUILD_HEADLESS_ONLY="true" \
  95. BUILD_HOTSPOT="true" BUILD_JDK="true" \
  96. BUILD_LANGTOOLS="false" \
  97. BUILD_JAXP="false" BUILD_JAXWS="false" BUILD_CORBA="false" \
  98. HOTSPOT_BUILD_JOBS="$(NPROCS)" \
  99. TEST_IN_BUILD="false" \
  100. product_build
  101. $(JAVA_HOME)/bin/java: $(JRE_DIR)/bin/java
  102. rm -rf $(JAVA_HOME)
  103. cp -rf $(JRE_DIR) $(JAVA_HOME)
  104. find $(JAVA_HOME) -type f -executable -exec strip --strip-debug {} \;
  105. distclean: clean
  106. rm -rf $(JAVA_DIR) $(JAVA_HOME)
  107. endif
  108. build-java: $(JAVA_HOME)/bin/java
  109. java_home:
  110. @echo $(JAVA_HOME)
  111. %.class: %.java
  112. javac $<
  113. clean-classes:
  114. rm -f $(addsuffix .class,$(TEST_CLASS))