openjdk.mk 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. ################################################################################
  2. #
  3. # openjdk
  4. #
  5. ################################################################################
  6. ifeq ($(BR2_PACKAGE_OPENJDK_VERSION_21),y)
  7. OPENJDK_VERSION_MAJOR = 21
  8. OPENJDK_VERSION_MINOR = 35
  9. OPENJDK_VERSION = $(OPENJDK_VERSION_MAJOR)+$(OPENJDK_VERSION_MINOR)
  10. else
  11. OPENJDK_VERSION_MAJOR = 17
  12. OPENJDK_VERSION_MINOR = 0.8.1+1
  13. OPENJDK_VERSION = $(OPENJDK_VERSION_MAJOR).$(OPENJDK_VERSION_MINOR)
  14. endif
  15. OPENJDK_SITE = $(call github,openjdk,jdk$(OPENJDK_VERSION_MAJOR)u,jdk-$(OPENJDK_VERSION))
  16. OPENJDK_LICENSE = GPL-2.0+ with exception
  17. OPENJDK_LICENSE_FILES = LICENSE
  18. OPENJDK_INSTALL_STAGING = YES
  19. # OpenJDK requires Alsa, cups, and X11 even for a headless build.
  20. # host-zip is needed for the zip executable.
  21. OPENJDK_DEPENDENCIES = \
  22. host-gawk \
  23. host-openjdk-bin \
  24. host-pkgconf \
  25. host-zip \
  26. host-zlib \
  27. alsa-lib \
  28. cups \
  29. fontconfig \
  30. giflib \
  31. jpeg \
  32. lcms2 \
  33. libpng \
  34. libusb \
  35. xlib_libXrandr \
  36. xlib_libXrender \
  37. xlib_libXt \
  38. xlib_libXtst \
  39. zlib
  40. # JVM variants
  41. ifeq ($(BR2_PACKAGE_OPENJDK_JVM_VARIANT_CLIENT),y)
  42. OPENJDK_JVM_VARIANT = client
  43. endif
  44. ifeq ($(BR2_PACKAGE_OPENJDK_JVM_VARIANT_SERVER),y)
  45. OPENJDK_JVM_VARIANT = server
  46. endif
  47. ifeq ($(BR2_PACKAGE_OPENJDK_JVM_VARIANT_ZERO),y)
  48. OPENJDK_JVM_VARIANT = zero
  49. OPENJDK_DEPENDENCIES += libffi
  50. endif
  51. ifeq ($(BR2_PACKAGE_OPENJDK_FULL_JDK),y)
  52. OPENJDK_VARIANT = jdk
  53. OPENJDK_MAKE_TARGET = jdk-image
  54. else
  55. OPENJDK_VARIANT = jre
  56. OPENJDK_MAKE_TARGET = legacy-jre-image
  57. endif
  58. # OpenJDK installs a file named 'modules' in jre/lib, which gets installed as
  59. # /usr/lib/modules. However, with a merged /usr, this conflicts with the
  60. # directory named 'modules' installed by the kernel. If OpenJDK gets built
  61. # after the kernel, this manifests itself with: "cp: cannot overwrite
  62. # directory '/usr/lib/modules with non-directory."
  63. OPENJDK_INSTALL_BASE = /usr/lib/jvm
  64. # OpenJDK ignores some variables unless passed via the environment.
  65. # These variables are PATH, LD, CC, CXX, and CPP.
  66. # OpenJDK defaults ld to the ld binary but passes -Xlinker and -z as
  67. # arguments during the linking process, which causes compilation failures.
  68. # To fix this issue, LD is set to point to gcc.
  69. OPENJDK_CONF_ENV = \
  70. PATH=$(BR_PATH) \
  71. CC=$(TARGET_CC) \
  72. CPP=$(TARGET_CPP) \
  73. CXX=$(TARGET_CXX) \
  74. LD=$(TARGET_CC) \
  75. BUILD_SYSROOT_CFLAGS="$(HOST_CFLAGS)" \
  76. BUILD_SYSROOT_LDFLAGS="$(HOST_LDFLAGS)"
  77. OPENJDK_CONF_OPTS = \
  78. --disable-full-docs \
  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))