1 #
   2 # Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 ###############################################################################
  27 #
  28 # Setup version numbers
  29 #
  30 
  31 # Verify that a given string represents a valid version number, and assign it
  32 # to a variable.
  33 
  34 # Argument 1: the variable to assign to
  35 # Argument 2: the value given by the user
  36 AC_DEFUN([JDKVER_CHECK_AND_SET_NUMBER],
  37 [
  38   # Additional [] needed to keep m4 from mangling shell constructs.
  39   if [ ! [[ "$2" =~ ^0*([1-9][0-9]*)|(0)$ ]] ] ; then
  40     AC_MSG_ERROR(["$2" is not a valid numerical value for $1])
  41   fi
  42   # Extract the version number without leading zeros.
  43   cleaned_value=${BASH_REMATCH[[1]]}
  44   if test "x$cleaned_value" = x; then
  45     # Special case for zero
  46     cleaned_value=${BASH_REMATCH[[2]]}
  47   fi
  48 
  49   if test $cleaned_value -gt 255; then
  50     AC_MSG_ERROR([$1 is given as $2. This is greater than 255 which is not allowed.])
  51   fi
  52   if test "x$cleaned_value" != "x$2"; then
  53     AC_MSG_WARN([Value for $1 has been sanitized from '$2' to '$cleaned_value'])
  54   fi
  55   $1=$cleaned_value
  56 ])
  57 
  58 AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS],
  59 [
  60   # Warn user that old version arguments are deprecated.
  61   BASIC_DEPRECATED_ARG_WITH([milestone])
  62   BASIC_DEPRECATED_ARG_WITH([update-version])
  63   BASIC_DEPRECATED_ARG_WITH([user-release-suffix])
  64   BASIC_DEPRECATED_ARG_WITH([build-number])
  65   BASIC_DEPRECATED_ARG_WITH([version-major])
  66   BASIC_DEPRECATED_ARG_WITH([version-minor])
  67   BASIC_DEPRECATED_ARG_WITH([version-security])
  68 
  69   # Source the version numbers file
  70   . $AUTOCONF_DIR/version-numbers
  71 
  72   # Some non-version number information is set in that file
  73   AC_SUBST(LAUNCHER_NAME)
  74   AC_SUBST(PRODUCT_NAME)
  75   AC_SUBST(PRODUCT_SUFFIX)
  76   AC_SUBST(JDK_RC_PLATFORM_NAME)
  77   AC_SUBST(HOTSPOT_VM_DISTRO)
  78 
  79   # Set the MACOSX Bundle Name base
  80   AC_ARG_WITH(macosx-bundle-name-base, [AS_HELP_STRING([--with-macosx-bundle-name-base],
  81       [Set the MacOSX Bundle Name base. This is the base name for calculating MacOSX Bundle Names.
  82       @<:@not specified@:>@])])
  83   if test "x$with_macosx_bundle_name_base" = xyes; then
  84     AC_MSG_ERROR([--with-macosx-bundle-name-base must have a value])
  85   elif [ ! [[ $with_macosx_bundle_name_base =~ ^[[:print:]]*$ ]] ]; then
  86     AC_MSG_ERROR([--with-macosx-bundle-name-base contains non-printing characters: $with_macosx_bundle_name_base])
  87   elif test "x$with_macosx_bundle_name_base" != x; then
  88     # Set MACOSX_BUNDLE_NAME_BASE to the configured value.
  89     MACOSX_BUNDLE_NAME_BASE="$with_macosx_bundle_name_base"
  90   fi
  91   AC_SUBST(MACOSX_BUNDLE_NAME_BASE)
  92 
  93   # Set the MACOSX Bundle ID base
  94   AC_ARG_WITH(macosx-bundle-id-base, [AS_HELP_STRING([--with-macosx-bundle-id-base],
  95       [Set the MacOSX Bundle ID base. This is the base ID for calculating MacOSX Bundle IDs.
  96       @<:@not specified@:>@])])
  97   if test "x$with_macosx_bundle_id_base" = xyes; then
  98     AC_MSG_ERROR([--with-macosx-bundle-id-base must have a value])
  99   elif [ ! [[ $with_macosx_bundle_id_base =~ ^[[:print:]]*$ ]] ]; then
 100     AC_MSG_ERROR([--with-macosx-bundle-id-base contains non-printing characters: $with_macosx_bundle_id_base])
 101   elif test "x$with_macosx_bundle_id_base" != x; then
 102     # Set MACOSX_BUNDLE_ID_BASE to the configured value.
 103     MACOSX_BUNDLE_ID_BASE="$with_macosx_bundle_id_base"
 104   fi
 105   AC_SUBST(MACOSX_BUNDLE_ID_BASE)
 106 
 107   # Set the JDK RC name
 108   AC_ARG_WITH(jdk-rc-name, [AS_HELP_STRING([--with-jdk-rc-name],
 109       [Set JDK RC name. This is used for FileDescription and ProductName properties
 110        of MS Windows binaries. @<:@not specified@:>@])])
 111   if test "x$with_jdk_rc_name" = xyes; then
 112     AC_MSG_ERROR([--with-jdk-rc-name must have a value])
 113   elif [ ! [[ $with_jdk_rc_name =~ ^[[:print:]]*$ ]] ]; then
 114     AC_MSG_ERROR([--with-jdk-rc-name contains non-printing characters: $with_jdk_rc_name])
 115   elif test "x$with_jdk_rc_name" != x; then
 116     # Set JDK_RC_NAME to a custom value if '--with-jdk-rc-name' was used and is not empty.
 117     JDK_RC_NAME="$with_jdk_rc_name"
 118   else
 119     # Otherwise calculate from "version-numbers" included above.
 120     JDK_RC_NAME="$PRODUCT_NAME $JDK_RC_PLATFORM_NAME"
 121   fi
 122   AC_SUBST(JDK_RC_NAME)
 123 
 124   # The vendor name, if any
 125   AC_ARG_WITH(vendor-name, [AS_HELP_STRING([--with-vendor-name],
 126       [Set vendor name. Among others, used to set the 'java.vendor'
 127        and 'java.vm.vendor' system properties. @<:@not specified@:>@])])
 128   if test "x$with_vendor_name" = xyes; then
 129     AC_MSG_ERROR([--with-vendor-name must have a value])
 130   elif [ ! [[ $with_vendor_name =~ ^[[:print:]]*$ ]] ]; then
 131     AC_MSG_ERROR([--with-vendor-name contains non-printing characters: $with_vendor_name])
 132   elif test "x$with_vendor_name" != x; then
 133     # Only set COMPANY_NAME if '--with-vendor-name' was used and is not empty.
 134     # Otherwise we will use the value from "version-numbers" included above.
 135     COMPANY_NAME="$with_vendor_name"
 136   fi
 137   AC_SUBST(COMPANY_NAME)
 138 
 139   # The vendor URL, if any
 140   AC_ARG_WITH(vendor-url, [AS_HELP_STRING([--with-vendor-url],
 141       [Set the 'java.vendor.url' system property @<:@not specified@:>@])])
 142   if test "x$with_vendor_url" = xyes; then
 143     AC_MSG_ERROR([--with-vendor-url must have a value])
 144   elif [ ! [[ $with_vendor_url =~ ^[[:print:]]*$ ]] ]; then
 145     AC_MSG_ERROR([--with-vendor-url contains non-printing characters: $with_vendor_url])
 146   else
 147     VENDOR_URL="$with_vendor_url"
 148   fi
 149   AC_SUBST(VENDOR_URL)
 150 
 151   # The vendor bug URL, if any
 152   AC_ARG_WITH(vendor-bug-url, [AS_HELP_STRING([--with-vendor-bug-url],
 153       [Set the 'java.vendor.url.bug' system property @<:@not specified@:>@])])
 154   if test "x$with_vendor_bug_url" = xyes; then
 155     AC_MSG_ERROR([--with-vendor-bug-url must have a value])
 156   elif [ ! [[ $with_vendor_bug_url =~ ^[[:print:]]*$ ]] ]; then
 157     AC_MSG_ERROR([--with-vendor-bug-url contains non-printing characters: $with_vendor_bug_url])
 158   else
 159     VENDOR_URL_BUG="$with_vendor_bug_url"
 160   fi
 161   AC_SUBST(VENDOR_URL_BUG)
 162 
 163   # The vendor VM bug URL, if any
 164   AC_ARG_WITH(vendor-vm-bug-url, [AS_HELP_STRING([--with-vendor-vm-bug-url],
 165       [Sets the bug URL which will be displayed when the VM crashes @<:@not specified@:>@])])
 166   if test "x$with_vendor_vm_bug_url" = xyes; then
 167     AC_MSG_ERROR([--with-vendor-vm-bug-url must have a value])
 168   elif [ ! [[ $with_vendor_vm_bug_url =~ ^[[:print:]]*$ ]] ]; then
 169     AC_MSG_ERROR([--with-vendor-vm-bug-url contains non-printing characters: $with_vendor_vm_bug_url])
 170   else
 171     VENDOR_URL_VM_BUG="$with_vendor_vm_bug_url"
 172   fi
 173   AC_SUBST(VENDOR_URL_VM_BUG)
 174 
 175   # Override version from arguments
 176 
 177   # If --with-version-string is set, process it first. It is possible to
 178   # override parts with more specific flags, since these are processed later.
 179   AC_ARG_WITH(version-string, [AS_HELP_STRING([--with-version-string],
 180       [Set version string @<:@calculated@:>@])])
 181   if test "x$with_version_string" = xyes; then
 182     AC_MSG_ERROR([--with-version-string must have a value])
 183   elif test "x$with_version_string" != x; then
 184     # Additional [] needed to keep m4 from mangling shell constructs.
 185     if [ [[ $with_version_string =~ ^([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(-([a-zA-Z]+))?((\+)([0-9]+)?(-([-a-zA-Z0-9.]+))?)?$ ]] ]; then
 186       VERSION_FEATURE=${BASH_REMATCH[[1]]}
 187       VERSION_INTERIM=${BASH_REMATCH[[3]]}
 188       VERSION_UPDATE=${BASH_REMATCH[[5]]}
 189       VERSION_PATCH=${BASH_REMATCH[[7]]}
 190       VERSION_EXTRA1=${BASH_REMATCH[[9]]}
 191       VERSION_EXTRA2=${BASH_REMATCH[[11]]}
 192       VERSION_EXTRA3=${BASH_REMATCH[[13]]}
 193       VERSION_PRE=${BASH_REMATCH[[15]]}
 194       version_plus_separator=${BASH_REMATCH[[17]]}
 195       VERSION_BUILD=${BASH_REMATCH[[18]]}
 196       VERSION_OPT=${BASH_REMATCH[[20]]}
 197       # Unspecified numerical fields are interpreted as 0.
 198       if test "x$VERSION_INTERIM" = x; then
 199         VERSION_INTERIM=0
 200       fi
 201       if test "x$VERSION_UPDATE" = x; then
 202         VERSION_UPDATE=0
 203       fi
 204       if test "x$VERSION_PATCH" = x; then
 205         VERSION_PATCH=0
 206       fi
 207       if test "x$VERSION_EXTRA1" = x; then
 208         VERSION_EXTRA1=0
 209       fi
 210       if test "x$VERSION_EXTRA2" = x; then
 211         VERSION_EXTRA2=0
 212       fi
 213       if test "x$VERSION_EXTRA3" = x; then
 214         VERSION_EXTRA3=0
 215       fi
 216       if test "x$version_plus_separator" != x \
 217           && test "x$VERSION_BUILD$VERSION_OPT" = x; then
 218         AC_MSG_ERROR([Version string contains + but both 'BUILD' and 'OPT' are missing])
 219       fi
 220       # Stop the version part process from setting default values.
 221       # We still allow them to explicitly override though.
 222       NO_DEFAULT_VERSION_PARTS=true
 223     else
 224       AC_MSG_ERROR([--with-version-string fails to parse as a valid version string: $with_version_string])
 225     fi
 226   fi
 227 
 228   AC_ARG_WITH(version-pre, [AS_HELP_STRING([--with-version-pre],
 229       [Set the base part of the version 'PRE' field (pre-release identifier) @<:@'internal'@:>@])],
 230       [with_version_pre_present=true], [with_version_pre_present=false])
 231 
 232   if test "x$with_version_pre_present" = xtrue; then
 233     if test "x$with_version_pre" = xyes; then
 234       AC_MSG_ERROR([--with-version-pre must have a value])
 235     elif test "x$with_version_pre" = xno; then
 236       # Interpret --without-* as empty string instead of the literal "no"
 237       VERSION_PRE=
 238     else
 239       # Only [a-zA-Z] is allowed in the VERSION_PRE. Outer [ ] to quote m4.
 240       [ VERSION_PRE=`$ECHO "$with_version_pre" | $TR -c -d '[a-z][A-Z]'` ]
 241       if test "x$VERSION_PRE" != "x$with_version_pre"; then
 242         AC_MSG_WARN([--with-version-pre value has been sanitized from '$with_version_pre' to '$VERSION_PRE'])
 243       fi
 244     fi
 245   else
 246     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
 247       # Default is to use "internal" as pre
 248       VERSION_PRE="internal"
 249     fi
 250   fi
 251 
 252   AC_ARG_WITH(version-opt, [AS_HELP_STRING([--with-version-opt],
 253       [Set version 'OPT' field (build metadata) @<:@<timestamp>.<user>.<dirname>@:>@])],
 254       [with_version_opt_present=true], [with_version_opt_present=false])
 255 
 256   if test "x$with_version_opt_present" = xtrue; then
 257     if test "x$with_version_opt" = xyes; then
 258       AC_MSG_ERROR([--with-version-opt must have a value])
 259     elif test "x$with_version_opt" = xno; then
 260       # Interpret --without-* as empty string instead of the literal "no"
 261       VERSION_OPT=
 262     else
 263       # Only [-.a-zA-Z0-9] is allowed in the VERSION_OPT. Outer [ ] to quote m4.
 264       [ VERSION_OPT=`$ECHO "$with_version_opt" | $TR -c -d '[a-z][A-Z][0-9].-'` ]
 265       if test "x$VERSION_OPT" != "x$with_version_opt"; then
 266         AC_MSG_WARN([--with-version-opt value has been sanitized from '$with_version_opt' to '$VERSION_OPT'])
 267       fi
 268     fi
 269   else
 270     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
 271       # Default is to calculate a string like this 'adhoc.<username>.<base dir name>'
 272       # Outer [ ] to quote m4.
 273       [ basedirname=`$BASENAME "$TOPDIR" | $TR -d -c '[a-z][A-Z][0-9].-'` ]
 274       VERSION_OPT="adhoc.$USERNAME.$basedirname"
 275     fi
 276   fi
 277 
 278   AC_ARG_WITH(version-build, [AS_HELP_STRING([--with-version-build],
 279       [Set version 'BUILD' field (build number) @<:@not specified@:>@])],
 280       [with_version_build_present=true], [with_version_build_present=false])
 281 
 282   if test "x$with_version_build_present" = xtrue; then
 283     if test "x$with_version_build" = xyes; then
 284       AC_MSG_ERROR([--with-version-build must have a value])
 285     elif test "x$with_version_build" = xno; then
 286       # Interpret --without-* as empty string instead of the literal "no"
 287       VERSION_BUILD=
 288     elif test "x$with_version_build" = x; then
 289       VERSION_BUILD=
 290     else
 291       JDKVER_CHECK_AND_SET_NUMBER(VERSION_BUILD, $with_version_build)
 292     fi
 293   else
 294     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
 295       # Default is to not have a build number.
 296       VERSION_BUILD=""
 297       # FIXME: Until all code can cope with an empty VERSION_BUILD, set it to 0.
 298       VERSION_BUILD=0
 299     fi
 300   fi
 301 
 302   AC_ARG_WITH(version-feature, [AS_HELP_STRING([--with-version-feature],
 303       [Set version 'FEATURE' field (first number) @<:@current source value@:>@])],
 304       [with_version_feature_present=true], [with_version_feature_present=false])
 305 
 306   if test "x$with_version_feature_present" = xtrue; then
 307     if test "x$with_version_feature" = xyes; then
 308       AC_MSG_ERROR([--with-version-feature must have a value])
 309     else
 310       JDKVER_CHECK_AND_SET_NUMBER(VERSION_FEATURE, $with_version_feature)
 311     fi
 312   else
 313     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
 314       # Default is to get value from version-numbers
 315       VERSION_FEATURE="$DEFAULT_VERSION_FEATURE"
 316     fi
 317   fi
 318 
 319   AC_ARG_WITH(version-interim, [AS_HELP_STRING([--with-version-interim],
 320       [Set version 'INTERIM' field (second number) @<:@current source value@:>@])],
 321       [with_version_interim_present=true], [with_version_interim_present=false])
 322 
 323   if test "x$with_version_interim_present" = xtrue; then
 324     if test "x$with_version_interim" = xyes; then
 325       AC_MSG_ERROR([--with-version-interim must have a value])
 326     elif test "x$with_version_interim" = xno; then
 327       # Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
 328       VERSION_INTERIM=0
 329     elif test "x$with_version_interim" = x; then
 330       VERSION_INTERIM=0
 331     else
 332       JDKVER_CHECK_AND_SET_NUMBER(VERSION_INTERIM, $with_version_interim)
 333     fi
 334   else
 335     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
 336       # Default is 0, if unspecified
 337       VERSION_INTERIM=$DEFAULT_VERSION_INTERIM
 338     fi
 339   fi
 340 
 341   AC_ARG_WITH(version-update, [AS_HELP_STRING([--with-version-update],
 342       [Set version 'UPDATE' field (third number) @<:@current source value@:>@])],
 343       [with_version_update_present=true], [with_version_update_present=false])
 344 
 345   if test "x$with_version_update_present" = xtrue; then
 346     if test "x$with_version_update" = xyes; then
 347       AC_MSG_ERROR([--with-version-update must have a value])
 348     elif test "x$with_version_update" = xno; then
 349       # Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
 350       VERSION_UPDATE=0
 351     elif test "x$with_version_update" = x; then
 352       VERSION_UPDATE=0
 353     else
 354       JDKVER_CHECK_AND_SET_NUMBER(VERSION_UPDATE, $with_version_update)
 355     fi
 356   else
 357     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
 358       # Default is 0, if unspecified
 359       VERSION_UPDATE=$DEFAULT_VERSION_UPDATE
 360     fi
 361   fi
 362 
 363   AC_ARG_WITH(version-patch, [AS_HELP_STRING([--with-version-patch],
 364       [Set version 'PATCH' field (fourth number) @<:@not specified@:>@])],
 365       [with_version_patch_present=true], [with_version_patch_present=false])
 366 
 367   if test "x$with_version_patch_present" = xtrue; then
 368     if test "x$with_version_patch" = xyes; then
 369       AC_MSG_ERROR([--with-version-patch must have a value])
 370     elif test "x$with_version_patch" = xno; then
 371       # Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
 372       VERSION_PATCH=0
 373     elif test "x$with_version_patch" = x; then
 374       VERSION_PATCH=0
 375     else
 376       JDKVER_CHECK_AND_SET_NUMBER(VERSION_PATCH, $with_version_patch)
 377     fi
 378   else
 379     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
 380       # Default is 0, if unspecified
 381       VERSION_PATCH=$DEFAULT_VERSION_PATCH
 382     fi
 383   fi
 384 
 385   # The 1st version extra number, if any
 386   AC_ARG_WITH(version-extra1, [AS_HELP_STRING([--with-version-extra1],
 387       [Set 1st version extra number @<:@not specified@:>@])],
 388       [with_version_extra1_present=true], [with_version_extra1_present=false])
 389 
 390   if test "x$with_version_extra1_present" = xtrue; then
 391     if test "x$with_version_extra1" = xyes; then
 392       AC_MSG_ERROR([--with-version-extra1 must have a value])
 393     elif test "x$with_version_extra1" = xno; then
 394       # Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
 395       VERSION_EXTRA1=0
 396     elif test "x$with_version_extra1" = x; then
 397       VERSION_EXTRA1=0
 398     else
 399       JDKVER_CHECK_AND_SET_NUMBER(VERSION_EXTRA1, $with_version_extra1)
 400     fi
 401   else
 402     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
 403       VERSION_EXTRA1=$DEFAULT_VERSION_EXTRA1
 404     fi
 405   fi
 406 
 407   # The 2nd version extra number, if any
 408   AC_ARG_WITH(version-extra2, [AS_HELP_STRING([--with-version-extra2],
 409       [Set 2nd version extra number @<:@not specified@:>@])],
 410       [with_version_extra2_present=true], [with_version_extra2_present=false])
 411 
 412   if test "x$with_version_extra2_present" = xtrue; then
 413     if test "x$with_version_extra2" = xyes; then
 414       AC_MSG_ERROR([--with-version-extra2 must have a value])
 415     elif test "x$with_version_extra2" = xno; then
 416       # Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
 417       VERSION_EXTRA2=0
 418     elif test "x$with_version_extra2" = x; then
 419       VERSION_EXTRA2=0
 420     else
 421       JDKVER_CHECK_AND_SET_NUMBER(VERSION_EXTRA2, $with_version_extra2)
 422     fi
 423   else
 424     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
 425       VERSION_EXTRA2=$DEFAULT_VERSION_EXTRA2
 426     fi
 427   fi
 428 
 429   # The 3rd version extra number, if any
 430   AC_ARG_WITH(version-extra3, [AS_HELP_STRING([--with-version-extra3],
 431       [Set 3rd version extra number @<:@not specified@:>@])],
 432       [with_version_extra3_present=true], [with_version_extra3_present=false])
 433 
 434   if test "x$with_version_extra3_present" = xtrue; then
 435     if test "x$with_version_extra3" = xyes; then
 436       AC_MSG_ERROR([--with-version-extra3 must have a value])
 437     elif test "x$with_version_extra3" = xno; then
 438       # Interpret --without-* as empty string (i.e. 0) instead of the literal "no"
 439       VERSION_EXTRA3=0
 440     elif test "x$with_version_extra3" = x; then
 441       VERSION_EXTRA3=0
 442     else
 443       JDKVER_CHECK_AND_SET_NUMBER(VERSION_EXTRA3, $with_version_extra3)
 444     fi
 445   else
 446     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
 447       VERSION_EXTRA3=$DEFAULT_VERSION_EXTRA3
 448     fi
 449   fi
 450 
 451   # Calculate derived version properties
 452 
 453   # Set VERSION_IS_GA based on if VERSION_PRE has a value
 454   if test "x$VERSION_PRE" = x; then
 455     VERSION_IS_GA=true
 456   else
 457     VERSION_IS_GA=false
 458   fi
 459 
 460   # VERSION_NUMBER but always with exactly 4 positions, with 0 for empty positions.
 461   VERSION_NUMBER_FOUR_POSITIONS=$VERSION_FEATURE.$VERSION_INTERIM.$VERSION_UPDATE.$VERSION_PATCH
 462 
 463   # VERSION_NUMBER but always with all positions, with 0 for empty positions.
 464   VERSION_NUMBER_ALL_POSITIONS=$VERSION_NUMBER_FOUR_POSITIONS.$VERSION_EXTRA1.$VERSION_EXTRA2.$VERSION_EXTRA3
 465 
 466   stripped_version_number=$VERSION_NUMBER_ALL_POSITIONS
 467   # Strip trailing zeroes from stripped_version_number
 468   for i in 1 2 3 4 5 6 ; do stripped_version_number=${stripped_version_number%.0} ; done
 469   VERSION_NUMBER=$stripped_version_number
 470 
 471   # The complete version string, with additional build information
 472   if test "x$VERSION_BUILD$VERSION_OPT" = x; then
 473     VERSION_STRING=$VERSION_NUMBER${VERSION_PRE:+-$VERSION_PRE}
 474   else
 475     # If either build or opt is set, we need a + separator
 476     VERSION_STRING=$VERSION_NUMBER${VERSION_PRE:+-$VERSION_PRE}+$VERSION_BUILD${VERSION_OPT:+-$VERSION_OPT}
 477   fi
 478 
 479   # The short version string, just VERSION_NUMBER and PRE, if present.
 480   VERSION_SHORT=$VERSION_NUMBER${VERSION_PRE:+-$VERSION_PRE}
 481 
 482   # The version date
 483   AC_ARG_WITH(version-date, [AS_HELP_STRING([--with-version-date],
 484       [Set version date @<:@current source value@:>@])])
 485   if test "x$with_version_date" = xyes; then
 486     AC_MSG_ERROR([--with-version-date must have a value])
 487   elif test "x$with_version_date" != x; then
 488     if [ ! [[ $with_version_date =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] ]; then
 489       AC_MSG_ERROR(["$with_version_date" is not a valid version date]) 
 490     else
 491       VERSION_DATE="$with_version_date"
 492     fi
 493   else
 494     VERSION_DATE="$DEFAULT_VERSION_DATE"
 495   fi
 496 
 497   # The vendor version string, if any
 498   AC_ARG_WITH(vendor-version-string, [AS_HELP_STRING([--with-vendor-version-string],
 499       [Set vendor version string @<:@not specified@:>@])])
 500   if test "x$with_vendor_version_string" = xyes; then
 501     AC_MSG_ERROR([--with-vendor-version-string must have a value])
 502   elif [ ! [[ $with_vendor_version_string =~ ^[[:graph:]]*$ ]] ]; then
 503     AC_MSG_ERROR([--with--vendor-version-string contains non-graphical characters: $with_vendor_version_string])
 504   else
 505     VENDOR_VERSION_STRING="$with_vendor_version_string"
 506   fi
 507 
 508   # We could define --with flags for these, if really needed
 509   VERSION_CLASSFILE_MAJOR="$DEFAULT_VERSION_CLASSFILE_MAJOR"
 510   VERSION_CLASSFILE_MINOR="$DEFAULT_VERSION_CLASSFILE_MINOR"
 511 
 512   AC_MSG_CHECKING([for version string])
 513   AC_MSG_RESULT([$VERSION_STRING])
 514 
 515   AC_SUBST(VERSION_FEATURE)
 516   AC_SUBST(VERSION_INTERIM)
 517   AC_SUBST(VERSION_UPDATE)
 518   AC_SUBST(VERSION_PATCH)
 519   AC_SUBST(VERSION_EXTRA1)
 520   AC_SUBST(VERSION_EXTRA2)
 521   AC_SUBST(VERSION_EXTRA3)
 522   AC_SUBST(VERSION_PRE)
 523   AC_SUBST(VERSION_BUILD)
 524   AC_SUBST(VERSION_OPT)
 525   AC_SUBST(VERSION_NUMBER)
 526   AC_SUBST(VERSION_NUMBER_FOUR_POSITIONS)
 527   AC_SUBST(VERSION_STRING)
 528   AC_SUBST(VERSION_SHORT)
 529   AC_SUBST(VERSION_IS_GA)
 530   AC_SUBST(VERSION_DATE)
 531   AC_SUBST(VENDOR_VERSION_STRING)
 532   AC_SUBST(VERSION_CLASSFILE_MAJOR)
 533   AC_SUBST(VERSION_CLASSFILE_MINOR)
 534 
 535 ])