Makefile 3.5 KB

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