openjdk.mk 4.8 KB

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