openjdk.mk 4.5 KB

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