From 59040a3951dfdf21ba646cc9510739f175751469 Mon Sep 17 00:00:00 2001
Date: Wed, 21 Sep 2022 09:54:04 +0800
Subject: [PATCH 2/5] add configuration option of huawei internal version shown in release file

---
 common/autoconf/generated-configure.sh | 17 +++++++++++++++++
 common/autoconf/jdk-options.m4         | 11 +++++++++++
 common/autoconf/spec.gmk.in            |  3 +++
 jdk/make/Images.gmk                    |  1 +
 4 files changed, 32 insertions(+)

diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh
index 53e6cf18..a6ba1ac9 100644
--- a/common/autoconf/generated-configure.sh
+++ b/common/autoconf/generated-configure.sh
@@ -831,6 +831,7 @@ COPYRIGHT_YEAR
 VENDOR_URL_VM_BUG
 VENDOR_URL_BUG
 VENDOR_URL
+INTERNAL_VERSION
 COMPANY_NAME
 MACOSX_BUNDLE_ID_BASE
 MACOSX_BUNDLE_NAME_BASE
@@ -1077,6 +1078,7 @@ with_vendor_url
 with_vendor_bug_url
 with_vendor_vm_bug_url
 with_copyright_year
+with_internal_version
 with_boot_jdk
 with_boot_jdk_jvmargs
 with_add_source_root
@@ -1937,6 +1939,9 @@ Optional Packages:
   --with-vendor-vm-bug-url
                           Sets the bug URL which will be displayed when the VM
                           crashes [not specified]
+  --with-internal-version
+                          Sets the internal version which will be
+                          displayed in the release file [not specified]
   --with-copyright-year   Set copyright year value for build [current year]
   --with-boot-jdk         path to Boot JDK (used to bootstrap build) [probed]
   --with-boot-jdk-jvmargs specify JVM arguments to be passed to all
@@ -20301,6 +20306,18 @@ fi
     COPYRIGHT_YEAR=`date +'%Y'`
   fi
 
+# Check whether --with-internal-version was given.
+if test "${with_internal_version+set}" = set; then :
+  withval=$with_internal_version;
+fi
+
+  if test "x$with_internal_version" = xyes; then
+    as_fn_error $? "--with-internal-version must have a value" "$LINENO" 5
+  elif  ! [[ $with_internal_version =~ ^[[:print:]]*$ ]] ; then
+    as_fn_error $? "--with-internal-version contains non-printing characters: $with_internal_version" "$LINENO" 5
+  else
+    INTERNAL_VERSION="$with_internal_version"
+  fi
 
   if test "x$JDK_UPDATE_VERSION" != x; then
     JDK_VERSION="${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_MICRO_VERSION}_${JDK_UPDATE_VERSION}"
diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4
index c506086d..b9f25175 100644
--- a/common/autoconf/jdk-options.m4
+++ b/common/autoconf/jdk-options.m4
@@ -627,6 +627,17 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_VERSION_NUMBERS],
   fi
   AC_SUBST(COPYRIGHT_YEAR)
 
+  AC_ARG_WITH(internal-version, [AS_HELP_STRING([--with-internal-version],
+      [Sets the internal version which will be displayed in the release file @<:@not specified@:>@])])
+  if test "x$with_internal_version" = xyes; then
+    AC_MSG_ERROR([--with-internal-version must have a value])
+  elif [ ! [[ $with_internal_version =~ ^[[:print:]]*$ ]] ]; then
+    AC_MSG_ERROR([--with-internal-version contains non-printing characters: $with_internal_version])
+  else
+    INTERNAL_VERSION="$with_internal_version"
+  fi
+  AC_SUBST(INTERNAL_VERSION)
+
   if test "x$JDK_UPDATE_VERSION" != x; then
     JDK_VERSION="${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_MICRO_VERSION}_${JDK_UPDATE_VERSION}"
   else
diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in
index 79248cbf..ca5e2d74 100644
--- a/common/autoconf/spec.gmk.in
+++ b/common/autoconf/spec.gmk.in
@@ -162,6 +162,9 @@ VENDOR_URL:=@VENDOR_URL@
 VENDOR_URL_BUG:=@VENDOR_URL_BUG@
 VENDOR_URL_VM_BUG:=@VENDOR_URL_VM_BUG@
 
+# Huawei internal version for use in release file. 
+INTERNAL_VERSION:=@INTERNAL_VERSION@
+
 # Location where build customization files may be found
 CUSTOM_MAKE_DIR:=@CUSTOM_MAKE_DIR@
 
diff --git a/jdk/make/Images.gmk b/jdk/make/Images.gmk
index ac39ad33..233ce703 100644
--- a/jdk/make/Images.gmk
+++ b/jdk/make/Images.gmk
@@ -618,6 +618,7 @@ define create-info-file
 	$(call info-file-item, "OS_ARCH", "$(OPENJDK_TARGET_CPU_LEGACY)")
 	if [ -n "$(JDK_ARCH_ABI_PROP_NAME)" ]; then $(call info-file-item, "SUN_ARCH_ABI", "$(JDK_ARCH_ABI_PROP_NAME)"); fi
 	$(call info-file-item, "SOURCE", "$(strip $(SOURCE_REVISION))")
+	if [ -n "$(INTERNAL_VERSION)" ]; then $(call info-file-item, "INTERNAL_VERSION", "$(INTERNAL_VERSION)"); fi
 endef
 
 SOURCE_REVISION = $(shell \
-- 
2.22.0

