openjdk.mk 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. ################################################################################
  2. #
  3. # openjdk
  4. #
  5. ################################################################################
  6. ifeq ($(BR2_PACKAGE_OPENJDK_VERSION_21),y)
  7. OPENJDK_VERSION_MAJOR = 21
  8. OPENJDK_VERSION_MINOR = 0.1+12
  9. else
  10. OPENJDK_VERSION_MAJOR = 17
  11. OPENJDK_VERSION_MINOR = 0.9+9
  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-manpages \
  79. --disable-warnings-as-errors \
  80. --enable-headless-only \
  81. --enable-openjdk-only \
  82. --enable-unlimited-crypto \
  83. --openjdk-target=$(GNU_TARGET_NAME) \
  84. --with-boot-jdk=$(HOST_OPENJDK_BIN_ROOT_DIR) \
  85. --with-stdc++lib=dynamic \
  86. --with-debug-level=release \
  87. --with-devkit=$(HOST_DIR) \
  88. --with-extra-cflags="$(TARGET_CFLAGS)" \
  89. --with-extra-cxxflags="$(TARGET_CXXFLAGS)" \
  90. --with-extra-ldflags="-Wl,-rpath,$(OPENJDK_INSTALL_BASE)/lib,-rpath,$(OPENJDK_INSTALL_BASE)/lib/$(OPENJDK_JVM_VARIANT)" \
  91. --with-giflib=system \
  92. --with-jobs=$(PARALLEL_JOBS) \
  93. --with-jvm-variants=$(OPENJDK_JVM_VARIANT) \
  94. --with-lcms=system \
  95. --with-libjpeg=system \
  96. --with-libpng=system \
  97. --with-zlib=system \
  98. --with-native-debug-symbols=none \
  99. --without-version-pre \
  100. --with-sysroot=$(STAGING_DIR) \
  101. --with-version-build="$(OPENJDK_VERSION_MAJOR)" \
  102. --with-version-string="$(OPENJDK_VERSION_MAJOR)"
  103. # If building for AArch64, use the provided CPU port.
  104. ifeq ($(BR2_aarch64),y)
  105. OPENJDK_CONF_OPTS += --with-abi-profile=aarch64
  106. endif
  107. ifeq ($(BR2_CCACHE),y)
  108. OPENJDK_CONF_OPTS += \
  109. --enable-ccache \
  110. --with-ccache-dir=$(BR2_CCACHE_DIR)
  111. endif
  112. # Autogen and configure are performed in a single step.
  113. define OPENJDK_CONFIGURE_CMDS
  114. chmod +x $(@D)/configure
  115. cd $(@D); $(OPENJDK_CONF_ENV) ./configure autogen $(OPENJDK_CONF_OPTS)
  116. endef
  117. # Make -jn is unsupported. Instead, set the "--with-jobs=" configure option,
  118. # and use $(MAKE1).
  119. define OPENJDK_BUILD_CMDS
  120. $(TARGET_MAKE_ENV) $(OPENJDK_CONF_ENV) $(MAKE1) -C $(@D) $(OPENJDK_MAKE_TARGET)
  121. endef
  122. # Calling make install always builds and installs the JDK instead of the JRE,
  123. # which makes manual installation necessary.
  124. define OPENJDK_INSTALL_TARGET_CMDS
  125. mkdir -p $(TARGET_DIR)$(OPENJDK_INSTALL_BASE)
  126. cp -dpfr $(@D)/build/linux-*-release/images/$(OPENJDK_VARIANT)/* \
  127. $(TARGET_DIR)$(OPENJDK_INSTALL_BASE)/
  128. cd $(TARGET_DIR)/usr/bin && ln -snf ../..$(OPENJDK_INSTALL_BASE)/bin/* .
  129. endef
  130. define OPENJDK_INSTALL_STAGING_CMDS
  131. mkdir -p $(STAGING_DIR)/usr/include/jvm
  132. cp -dpfr $(@D)/build/linux-*-release/jdk/include/* \
  133. $(STAGING_DIR)/usr/include/jvm
  134. endef
  135. # Demos and includes are not needed on the target
  136. ifeq ($(BR2_PACKAGE_OPENJDK_FULL_JDK),y)
  137. define OPENJDK_REMOVE_UNEEDED_JDK_DIRECTORIES
  138. $(RM) -r $(TARGET_DIR)$(OPENJDK_INSTALL_BASE)/include/
  139. $(RM) -r $(TARGET_DIR)$(OPENJDK_INSTALL_BASE)/demo/
  140. endef
  141. OPENJDK_TARGET_FINALIZE_HOOKS += OPENJDK_REMOVE_UNEEDED_JDK_DIRECTORIES
  142. endif
  143. $(eval $(generic-package))