openjdk.mk 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. ################################################################################
  2. #
  3. # openjdk
  4. #
  5. ################################################################################
  6. ifeq ($(BR2_OPENJDK_VERSION_LATEST),y)
  7. OPENJDK_VERSION_MAJOR = 14.0.1
  8. OPENJDK_VERSION_MINOR = 7
  9. OPENJDK_VERSION = $(OPENJDK_VERSION_MAJOR)+$(OPENJDK_VERSION_MINOR)
  10. OPENJDK_SOURCE = jdk-$(OPENJDK_VERSION).tar.gz
  11. OPENJDK_SITE = https://hg.openjdk.java.net/jdk-updates/jdk14u/archive
  12. else
  13. OPENJDK_VERSION_MAJOR = 11.0.7
  14. OPENJDK_VERSION_MINOR = 10
  15. OPENJDK_VERSION = $(OPENJDK_VERSION_MAJOR)+$(OPENJDK_VERSION_MINOR)
  16. OPENJDK_SOURCE = jdk-$(OPENJDK_VERSION).tar.gz
  17. OPENJDK_SITE = https://hg.openjdk.java.net/jdk-updates/jdk11u/archive
  18. endif
  19. OPENJDK_LICENSE = GPL-2.0+ with exception
  20. OPENJDK_LICENSE_FILES = LICENSE
  21. # OpenJDK requires Alsa, cups, and X11 even for a headless build.
  22. # host-zip is needed for the zip executable.
  23. OPENJDK_DEPENDENCIES = \
  24. host-gawk \
  25. host-openjdk-bin \
  26. host-pkgconf \
  27. host-zip \
  28. host-zlib \
  29. alsa-lib \
  30. cups \
  31. fontconfig \
  32. giflib \
  33. jpeg \
  34. lcms2 \
  35. libpng \
  36. libusb \
  37. xlib_libXrandr \
  38. xlib_libXrender \
  39. xlib_libXt \
  40. xlib_libXtst \
  41. zlib
  42. # JVM variants
  43. ifeq ($(BR2_PACKAGE_OPENJDK_JVM_VARIANT_CLIENT),y)
  44. OPENJDK_JVM_VARIANT = client
  45. endif
  46. ifeq ($(BR2_PACKAGE_OPENJDK_JVM_VARIANT_SERVER),y)
  47. OPENJDK_JVM_VARIANT = server
  48. endif
  49. ifeq ($(BR2_PACKAGE_OPENJDK_JVM_VARIANT_ZERO),y)
  50. OPENJDK_JVM_VARIANT = zero
  51. OPENJDK_DEPENDENCIES += libffi
  52. endif
  53. ifeq ($(BR2_PACKAGE_OPENJDK_FULL_JDK),y)
  54. OPENJDK_VARIANT = jdk
  55. OPENJDK_MAKE_TARGET = jdk-image
  56. else
  57. OPENJDK_VARIANT = jre
  58. OPENJDK_MAKE_TARGET = legacy-jre-image
  59. endif
  60. # OpenJDK installs a file named 'modules' in jre/lib, which gets installed as
  61. # /usr/lib/modules. However, with a merged /usr, this conflicts with the
  62. # directory named 'modules' installed by the kernel. If OpenJDK gets built
  63. # after the kernel, this manifests itself with: "cp: cannot overwrite
  64. # directory '/usr/lib/modules with non-directory."
  65. OPENJDK_INSTALL_BASE = /usr/lib/jvm
  66. # OpenJDK ignores some variables unless passed via the environment.
  67. # These variables are PATH, LD, CC, CXX, and CPP.
  68. # OpenJDK defaults ld to the ld binary but passes -Xlinker and -z as
  69. # arguments during the linking process, which causes compilation failures.
  70. # To fix this issue, LD is set to point to gcc.
  71. OPENJDK_CONF_ENV = \
  72. PATH=$(BR_PATH) \
  73. CC=$(TARGET_CC) \
  74. CPP=$(TARGET_CPP) \
  75. CXX=$(TARGET_CXX) \
  76. LD=$(TARGET_CC) \
  77. BUILD_SYSROOT_CFLAGS="$(HOST_CFLAGS)" \
  78. BUILD_SYSROOT_LDFLAGS="$(HOST_LDFLAGS)"
  79. OPENJDK_CONF_OPTS = \
  80. --disable-full-docs \
  81. --disable-hotspot-gtest \
  82. --disable-manpages \
  83. --disable-warnings-as-errors \
  84. --enable-headless-only \
  85. --enable-openjdk-only \
  86. --enable-unlimited-crypto \
  87. --openjdk-target=$(GNU_TARGET_NAME) \
  88. --with-boot-jdk=$(HOST_OPENJDK_BIN_ROOT_DIR) \
  89. --with-stdc++lib=dynamic \
  90. --with-debug-level=release \
  91. --with-devkit=$(HOST_DIR) \
  92. --with-extra-cflags="$(TARGET_CFLAGS)" \
  93. --with-extra-cxxflags="$(TARGET_CXXFLAGS)" \
  94. --with-extra-ldflags="-Wl,-rpath,$(OPENJDK_INSTALL_BASE)/lib,-rpath,$(OPENJDK_INSTALL_BASE)/lib/$(OPENJDK_JVM_VARIANT)" \
  95. --with-giflib=system \
  96. --with-jobs=$(PARALLEL_JOBS) \
  97. --with-jvm-variants=$(OPENJDK_JVM_VARIANT) \
  98. --with-lcms=system \
  99. --with-libjpeg=system \
  100. --with-libpng=system \
  101. --with-zlib=system \
  102. --with-native-debug-symbols=none \
  103. --without-version-pre \
  104. --with-sysroot=$(STAGING_DIR) \
  105. --with-version-build="$(OPENJDK_VERSION_MAJOR)" \
  106. --with-version-string="$(OPENJDK_VERSION_MAJOR)"
  107. # If building for AArch64, use the provided CPU port.
  108. ifeq ($(BR2_aarch64),y)
  109. OPENJDK_CONF_OPTS += --with-abi-profile=aarch64
  110. endif
  111. ifeq ($(BR2_CCACHE),y)
  112. OPENJDK_CONF_OPTS += \
  113. --enable-ccache \
  114. --with-ccache-dir=$(BR2_CCACHE_DIR)
  115. endif
  116. # Autogen and configure are performed in a single step.
  117. define OPENJDK_CONFIGURE_CMDS
  118. chmod +x $(@D)/configure
  119. cd $(@D); $(OPENJDK_CONF_ENV) ./configure autogen $(OPENJDK_CONF_OPTS)
  120. endef
  121. # Make -jn is unsupported. Instead, set the "--with-jobs=" configure option,
  122. # and use $(MAKE1).
  123. define OPENJDK_BUILD_CMDS
  124. $(TARGET_MAKE_ENV) $(OPENJDK_CONF_ENV) $(MAKE1) -C $(@D) $(OPENJDK_MAKE_TARGET)
  125. endef
  126. # Calling make install always builds and installs the JDK instead of the JRE,
  127. # which makes manual installation necessary.
  128. define OPENJDK_INSTALL_TARGET_CMDS
  129. mkdir -p $(TARGET_DIR)$(OPENJDK_INSTALL_BASE)
  130. cp -dpfr $(@D)/build/linux-*-release/images/$(OPENJDK_VARIANT)/* \
  131. $(TARGET_DIR)$(OPENJDK_INSTALL_BASE)/
  132. cd $(TARGET_DIR)/usr/bin && ln -snf ../..$(OPENJDK_INSTALL_BASE)/bin/* .
  133. endef
  134. # Demos and includes are not needed on the target
  135. ifeq ($(BR2_PACKAGE_OPENJDK_FULL_JDK),y)
  136. define OPENJDK_REMOVE_UNEEDED_JDK_DIRECTORIES
  137. $(RM) -r $(TARGET_DIR)$(OPENJDK_INSTALL_BASE)/include/
  138. $(RM) -r $(TARGET_DIR)$(OPENJDK_INSTALL_BASE)/demo/
  139. endef
  140. OPENJDK_TARGET_FINALIZE_HOOKS += OPENJDK_REMOVE_UNEEDED_JDK_DIRECTORIES
  141. endif
  142. $(eval $(generic-package))