openjdk.mk 5.0 KB

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