1 # 2 # Copyright (c) 2015, 2017, 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 # Source the version numbers file 61 . $AUTOCONF_DIR/version-numbers 62 63 # Some non-version number information is set in that file 64 AC_SUBST(LAUNCHER_NAME) 65 AC_SUBST(PRODUCT_NAME) 66 AC_SUBST(PRODUCT_SUFFIX) 67 AC_SUBST(JDK_RC_PLATFORM_NAME) 68 AC_SUBST(HOTSPOT_VM_DISTRO) 69 AC_SUBST(MACOSX_BUNDLE_NAME_BASE) 70 AC_SUBST(MACOSX_BUNDLE_ID_BASE) 71 72 # The vendor name, if any 73 AC_ARG_WITH(vendor-name, [AS_HELP_STRING([--with-vendor-name], 74 [Set vendor name. Among others, used to set the 'java.vendor' 75 and 'java.vm.vendor' system properties. @<:@not specified@:>@])]) 76 if test "x$with_vendor_name" = xyes; then 77 AC_MSG_ERROR([--with-vendor-name must have a value]) 78 elif [ ! [[ $with_vendor_name =~ ^[[:print:]]*$ ]] ]; then 79 AC_MSG_ERROR([--with-vendor-name contains non-printing characters: $with_vendor_name]) 80 elif test "x$with_vendor_name" != x; then 81 # Only set COMPANY_NAME if '--with-vendor-name' was used and is not empty. 82 # Otherwise we will use the value from "version-numbers" included above. 83 COMPANY_NAME="$with_vendor_name" 84 fi 85 AC_SUBST(COMPANY_NAME) 86 87 # The vendor URL, if any 88 AC_ARG_WITH(vendor-url, [AS_HELP_STRING([--with-vendor-url], 89 [Set the 'java.vendor.url' system property @<:@not specified@:>@])]) 90 if test "x$with_vendor_url" = xyes; then 91 AC_MSG_ERROR([--with-vendor-url must have a value]) 92 elif [ ! [[ $with_vendor_url =~ ^[[:print:]]*$ ]] ]; then 93 AC_MSG_ERROR([--with-vendor-url contains non-printing characters: $with_vendor_url]) 94 else 95 VENDOR_URL="$with_vendor_url" 96 fi 97 AC_SUBST(VENDOR_URL) 98 99 # The vendor bug URL, if any 100 AC_ARG_WITH(vendor-bug-url, [AS_HELP_STRING([--with-vendor-bug-url], 101 [Set the 'java.vendor.url.bug' system property @<:@not specified@:>@])]) 102 if test "x$with_vendor_bug_url" = xyes; then 103 AC_MSG_ERROR([--with-vendor-bug-url must have a value]) 104 elif [ ! [[ $with_vendor_bug_url =~ ^[[:print:]]*$ ]] ]; then 105 AC_MSG_ERROR([--with-vendor-bug-url contains non-printing characters: $with_vendor_bug_url]) 106 else 107 VENDOR_URL_BUG="$with_vendor_bug_url" 108 fi 109 AC_SUBST(VENDOR_URL_BUG) 110 111 # The vendor VM bug URL, if any 112 AC_ARG_WITH(vendor-vm-bug-url, [AS_HELP_STRING([--with-vendor-vm-bug-url], 113 [Sets the bug URL which will be displayed when the VM crashes @<:@not specified@:>@])]) 114 if test "x$with_vendor_vm_bug_url" = xyes; then 115 AC_MSG_ERROR([--with-vendor-vm-bug-url must have a value]) 116 elif [ ! [[ $with_vendor_vm_bug_url =~ ^[[:print:]]*$ ]] ]; then 117 AC_MSG_ERROR([--with-vendor-vm-bug-url contains non-printing characters: $with_vendor_vm_bug_url]) 118 else 119 VENDOR_URL_VM_BUG="$with_vendor_vm_bug_url" 120 fi 121 AC_SUBST(VENDOR_URL_VM_BUG) 122 123 # Override version from arguments 124 125 # If --with-version-string is set, process it first. It is possible to 126 # override parts with more specific flags, since these are processed later. 127 AC_ARG_WITH(version-string, [AS_HELP_STRING([--with-version-string], 128 [Set version string @<:@calculated@:>@])]) 129 if test "x$with_version_string" = xyes; then 130 AC_MSG_ERROR([--with-version-string must have a value]) 131 elif test "x$with_version_string" != x; then 132 # Additional [] needed to keep m4 from mangling shell constructs. 133 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 134 VERSION_FEATURE=${BASH_REMATCH[[1]]} 135 VERSION_INTERIM=${BASH_REMATCH[[3]]} 136 VERSION_UPDATE=${BASH_REMATCH[[5]]} 137 VERSION_PATCH=${BASH_REMATCH[[7]]} 138 VERSION_EXTRA1=${BASH_REMATCH[[9]]} 139 VERSION_EXTRA2=${BASH_REMATCH[[11]]} 140 VERSION_EXTRA3=${BASH_REMATCH[[13]]} 141 VERSION_PRE=${BASH_REMATCH[[15]]} 142 version_plus_separator=${BASH_REMATCH[[17]]} 143 VERSION_BUILD=${BASH_REMATCH[[18]]} 144 VERSION_OPT=${BASH_REMATCH[[20]]} 145 # Unspecified numerical fields are interpreted as 0. 146 if test "x$VERSION_INTERIM" = x; then 147 VERSION_INTERIM=0 148 fi 149 if test "x$VERSION_UPDATE" = x; then 150 VERSION_UPDATE=0 151 fi 152 if test "x$VERSION_PATCH" = x; then 153 VERSION_PATCH=0 154 fi 155 if test "x$VERSION_EXTRA1" = x; then 156 VERSION_EXTRA1=0 157 fi 158 if test "x$VERSION_EXTRA2" = x; then 159 VERSION_EXTRA2=0 160 fi 161 if test "x$VERSION_EXTRA3" = x; then 162 VERSION_EXTRA3=0 163 fi 164 if test "x$version_plus_separator" != x \ 165 && test "x$VERSION_BUILD$VERSION_OPT" = x; then 166 AC_MSG_ERROR([Version string contains + but both 'BUILD' and 'OPT' are missing]) 167 fi 168 # Stop the version part process from setting default values. 169 # We still allow them to explicitly override though. 170 NO_DEFAULT_VERSION_PARTS=true 171 else 172 AC_MSG_ERROR([--with-version-string fails to parse as a valid version string: $with_version_string]) 173 fi 174 fi 175 176 AC_ARG_WITH(version-pre, [AS_HELP_STRING([--with-version-pre], 177 [Set the base part of the version 'PRE' field (pre-release identifier) @<:@'internal'@:>@])], 178 [with_version_pre_present=true], [with_version_pre_present=false]) 179 180 if test "x$with_version_pre_present" = xtrue; then 181 if test "x$with_version_pre" = xyes; then 182 AC_MSG_ERROR([--with-version-pre must have a value]) 183 elif test "x$with_version_pre" = xno; then 184 # Interpret --without-* as empty string instead of the literal "no" 185 VERSION_PRE= 186 else 187 # Only [a-zA-Z] is allowed in the VERSION_PRE. Outer [ ] to quote m4. 188 [ VERSION_PRE=`$ECHO "$with_version_pre" | $TR -c -d '[a-z][A-Z]'` ] 189 if test "x$VERSION_PRE" != "x$with_version_pre"; then 190 AC_MSG_WARN([--with-version-pre value has been sanitized from '$with_version_pre' to '$VERSION_PRE']) 191 fi 192 fi 193 else 194 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 195 # Default is to use "internal" as pre 196 VERSION_PRE="internal" 197 fi 198 fi 199 200 AC_ARG_WITH(version-opt, [AS_HELP_STRING([--with-version-opt], 201 [Set version 'OPT' field (build metadata) @<:@<timestamp>.<user>.<dirname>@:>@])], 202 [with_version_opt_present=true], [with_version_opt_present=false]) 203 204 if test "x$with_version_opt_present" = xtrue; then 205 if test "x$with_version_opt" = xyes; then 206 AC_MSG_ERROR([--with-version-opt must have a value]) 207 elif test "x$with_version_opt" = xno; then 208 # Interpret --without-* as empty string instead of the literal "no" 209 VERSION_OPT= 210 else 211 # Only [-.a-zA-Z0-9] is allowed in the VERSION_OPT. Outer [ ] to quote m4. 212 [ VERSION_OPT=`$ECHO "$with_version_opt" | $TR -c -d '[a-z][A-Z][0-9].-'` ] 213 if test "x$VERSION_OPT" != "x$with_version_opt"; then 214 AC_MSG_WARN([--with-version-opt value has been sanitized from '$with_version_opt' to '$VERSION_OPT']) 215 fi 216 fi 217 else 218 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 219 # Default is to calculate a string like this 'adhoc.<username>.<base dir name>' 220 # Outer [ ] to quote m4. 221 [ basedirname=`$BASENAME "$TOPDIR" | $TR -d -c '[a-z][A-Z][0-9].-'` ] 222 VERSION_OPT="adhoc.$USERNAME.$basedirname" 223 fi 224 fi 225 226 AC_ARG_WITH(version-build, [AS_HELP_STRING([--with-version-build], 227 [Set version 'BUILD' field (build number) @<:@not specified@:>@])], 228 [with_version_build_present=true], [with_version_build_present=false]) 229 230 if test "x$with_version_build_present" = xtrue; then 231 if test "x$with_version_build" = xyes; then 232 AC_MSG_ERROR([--with-version-build must have a value]) 233 elif test "x$with_version_build" = xno; then 234 # Interpret --without-* as empty string instead of the literal "no" 235 VERSION_BUILD= 236 elif test "x$with_version_build" = x; then 237 VERSION_BUILD= 238 else 239 JDKVER_CHECK_AND_SET_NUMBER(VERSION_BUILD, $with_version_build) 240 fi 241 else 242 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 243 # Default is to not have a build number. 244 VERSION_BUILD="" 245 # FIXME: Until all code can cope with an empty VERSION_BUILD, set it to 0. 246 VERSION_BUILD=0 247 fi 248 fi 249 250 AC_ARG_WITH(version-feature, [AS_HELP_STRING([--with-version-feature], 251 [Set version 'FEATURE' field (first number) @<:@current source value@:>@])], 252 [with_version_feature_present=true], [with_version_feature_present=false]) 253 254 if test "x$with_version_feature_present" = xtrue; then 255 if test "x$with_version_feature" = xyes; then 256 AC_MSG_ERROR([--with-version-feature must have a value]) 257 else 258 JDKVER_CHECK_AND_SET_NUMBER(VERSION_FEATURE, $with_version_feature) 259 fi 260 else 261 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 262 # Default is to get value from version-numbers 263 VERSION_FEATURE="$DEFAULT_VERSION_FEATURE" 264 fi 265 fi 266 267 AC_ARG_WITH(version-interim, [AS_HELP_STRING([--with-version-interim], 268 [Set version 'INTERIM' field (second number) @<:@current source value@:>@])], 269 [with_version_interim_present=true], [with_version_interim_present=false]) 270 271 if test "x$with_version_interim_present" = xtrue; then 272 if test "x$with_version_interim" = xyes; then 273 AC_MSG_ERROR([--with-version-interim must have a value]) 274 elif test "x$with_version_interim" = xno; then 275 # Interpret --without-* as empty string (i.e. 0) instead of the literal "no" 276 VERSION_INTERIM=0 277 elif test "x$with_version_interim" = x; then 278 VERSION_INTERIM=0 279 else 280 JDKVER_CHECK_AND_SET_NUMBER(VERSION_INTERIM, $with_version_interim) 281 fi 282 else 283 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 284 # Default is 0, if unspecified 285 VERSION_INTERIM=$DEFAULT_VERSION_INTERIM 286 fi 287 fi 288 289 AC_ARG_WITH(version-update, [AS_HELP_STRING([--with-version-update], 290 [Set version 'UPDATE' field (third number) @<:@current source value@:>@])], 291 [with_version_update_present=true], [with_version_update_present=false]) 292 293 if test "x$with_version_update_present" = xtrue; then 294 if test "x$with_version_update" = xyes; then 295 AC_MSG_ERROR([--with-version-update must have a value]) 296 elif test "x$with_version_update" = xno; then 297 # Interpret --without-* as empty string (i.e. 0) instead of the literal "no" 298 VERSION_UPDATE=0 299 elif test "x$with_version_update" = x; then 300 VERSION_UPDATE=0 301 else 302 JDKVER_CHECK_AND_SET_NUMBER(VERSION_UPDATE, $with_version_update) 303 fi 304 else 305 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 306 # Default is 0, if unspecified 307 VERSION_UPDATE=$DEFAULT_VERSION_UPDATE 308 fi 309 fi 310 311 AC_ARG_WITH(version-patch, [AS_HELP_STRING([--with-version-patch], 312 [Set version 'PATCH' field (fourth number) @<:@not specified@:>@])], 313 [with_version_patch_present=true], [with_version_patch_present=false]) 314 315 if test "x$with_version_patch_present" = xtrue; then 316 if test "x$with_version_patch" = xyes; then 317 AC_MSG_ERROR([--with-version-patch must have a value]) 318 elif test "x$with_version_patch" = xno; then 319 # Interpret --without-* as empty string (i.e. 0) instead of the literal "no" 320 VERSION_PATCH=0 321 elif test "x$with_version_patch" = x; then 322 VERSION_PATCH=0 323 else 324 JDKVER_CHECK_AND_SET_NUMBER(VERSION_PATCH, $with_version_patch) 325 fi 326 else 327 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 328 # Default is 0, if unspecified 329 VERSION_PATCH=$DEFAULT_VERSION_PATCH 330 fi 331 fi 332 333 # The 1st version extra number, if any 334 AC_ARG_WITH(version-extra1, [AS_HELP_STRING([--with-version-extra1], 335 [Set 1st version extra number @<:@not specified@:>@])], 336 [with_version_extra1_present=true], [with_version_extra1_present=false]) 337 338 if test "x$with_version_extra1_present" = xtrue; then 339 if test "x$with_version_extra1" = xyes; then 340 AC_MSG_ERROR([--with-version-extra1 must have a value]) 341 elif test "x$with_version_extra1" = xno; then 342 # Interpret --without-* as empty string (i.e. 0) instead of the literal "no" 343 VERSION_EXTRA1=0 344 elif test "x$with_version_extra1" = x; then 345 VERSION_EXTRA1=0 346 else 347 JDKVER_CHECK_AND_SET_NUMBER(VERSION_EXTRA1, $with_version_extra1) 348 fi 349 else 350 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 351 VERSION_EXTRA1=$DEFAULT_VERSION_EXTRA1 352 fi 353 fi 354 355 # The 2nd version extra number, if any 356 AC_ARG_WITH(version-extra2, [AS_HELP_STRING([--with-version-extra2], 357 [Set 2nd version extra number @<:@not specified@:>@])], 358 [with_version_extra2_present=true], [with_version_extra2_present=false]) 359 360 if test "x$with_version_extra2_present" = xtrue; then 361 if test "x$with_version_extra2" = xyes; then 362 AC_MSG_ERROR([--with-version-extra2 must have a value]) 363 elif test "x$with_version_extra2" = xno; then 364 # Interpret --without-* as empty string (i.e. 0) instead of the literal "no" 365 VERSION_EXTRA2=0 366 elif test "x$with_version_extra2" = x; then 367 VERSION_EXTRA2=0 368 else 369 JDKVER_CHECK_AND_SET_NUMBER(VERSION_EXTRA2, $with_version_extra2) 370 fi 371 else 372 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 373 VERSION_EXTRA2=$DEFAULT_VERSION_EXTRA2 374 fi 375 fi 376 377 # The 3rd version extra number, if any 378 AC_ARG_WITH(version-extra3, [AS_HELP_STRING([--with-version-extra3], 379 [Set 3rd version extra number @<:@not specified@:>@])], 380 [with_version_extra3_present=true], [with_version_extra3_present=false]) 381 382 if test "x$with_version_extra3_present" = xtrue; then 383 if test "x$with_version_extra3" = xyes; then 384 AC_MSG_ERROR([--with-version-extra3 must have a value]) 385 elif test "x$with_version_extra3" = xno; then 386 # Interpret --without-* as empty string (i.e. 0) instead of the literal "no" 387 VERSION_EXTRA3=0 388 elif test "x$with_version_extra3" = x; then 389 VERSION_EXTRA3=0 390 else 391 JDKVER_CHECK_AND_SET_NUMBER(VERSION_EXTRA3, $with_version_extra3) 392 fi 393 else 394 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 395 VERSION_EXTRA3=$DEFAULT_VERSION_EXTRA3 396 fi 397 fi 398 399 # Calculate derived version properties 400 401 # Set VERSION_IS_GA based on if VERSION_PRE has a value 402 if test "x$VERSION_PRE" = x; then 403 VERSION_IS_GA=true 404 else 405 VERSION_IS_GA=false 406 fi 407 408 # VERSION_NUMBER but always with exactly 4 positions, with 0 for empty positions. 409 VERSION_NUMBER_FOUR_POSITIONS=$VERSION_FEATURE.$VERSION_INTERIM.$VERSION_UPDATE.$VERSION_PATCH 410 411 # VERSION_NUMBER but always with all positions, with 0 for empty positions. 412 VERSION_NUMBER_ALL_POSITIONS=$VERSION_NUMBER_FOUR_POSITIONS.$VERSION_EXTRA1.$VERSION_EXTRA2.$VERSION_EXTRA3 413 414 stripped_version_number=$VERSION_NUMBER_ALL_POSITIONS 415 # Strip trailing zeroes from stripped_version_number 416 for i in 1 2 3 4 5 6 ; do stripped_version_number=${stripped_version_number%.0} ; done 417 VERSION_NUMBER=$stripped_version_number 418 419 # The complete version string, with additional build information 420 if test "x$VERSION_BUILD$VERSION_OPT" = x; then 421 VERSION_STRING=$VERSION_NUMBER${VERSION_PRE:+-$VERSION_PRE} 422 else 423 # If either build or opt is set, we need a + separator 424 VERSION_STRING=$VERSION_NUMBER${VERSION_PRE:+-$VERSION_PRE}+$VERSION_BUILD${VERSION_OPT:+-$VERSION_OPT} 425 fi 426 427 # The short version string, just VERSION_NUMBER and PRE, if present. 428 VERSION_SHORT=$VERSION_NUMBER${VERSION_PRE:+-$VERSION_PRE} 429 430 # The version date 431 AC_ARG_WITH(version-date, [AS_HELP_STRING([--with-version-date], 432 [Set version date @<:@current source value@:>@])]) 433 if test "x$with_version_date" = xyes; then 434 AC_MSG_ERROR([--with-version-date must have a value]) 435 elif test "x$with_version_date" != x; then 436 if [ ! [[ $with_version_date =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] ]; then 437 AC_MSG_ERROR(["$with_version_date" is not a valid version date]) 438 else 439 VERSION_DATE="$with_version_date" 440 fi 441 else 442 VERSION_DATE="$DEFAULT_VERSION_DATE" 443 fi 444 445 # The vendor version string, if any 446 AC_ARG_WITH(vendor-version-string, [AS_HELP_STRING([--with-vendor-version-string], 447 [Set vendor version string @<:@not specified@:>@])]) 448 if test "x$with_vendor_version_string" = xyes; then 449 AC_MSG_ERROR([--with-vendor-version-string must have a value]) 450 elif [ ! [[ $with_vendor_version_string =~ ^[[:graph:]]*$ ]] ]; then 451 AC_MSG_ERROR([--with--vendor-version-string contains non-graphical characters: $with_vendor_version_string]) 452 else 453 VENDOR_VERSION_STRING="$with_vendor_version_string" 454 fi 455 456 # We could define --with flags for these, if really needed 457 VERSION_CLASSFILE_MAJOR="$DEFAULT_VERSION_CLASSFILE_MAJOR" 458 VERSION_CLASSFILE_MINOR="$DEFAULT_VERSION_CLASSFILE_MINOR" 459 460 AC_MSG_CHECKING([for version string]) 461 AC_MSG_RESULT([$VERSION_STRING]) 462 463 AC_SUBST(VERSION_FEATURE) 464 AC_SUBST(VERSION_INTERIM) 465 AC_SUBST(VERSION_UPDATE) 466 AC_SUBST(VERSION_PATCH) 467 AC_SUBST(VERSION_EXTRA1) 468 AC_SUBST(VERSION_EXTRA2) 469 AC_SUBST(VERSION_EXTRA3) 470 AC_SUBST(VERSION_PRE) 471 AC_SUBST(VERSION_BUILD) 472 AC_SUBST(VERSION_OPT) 473 AC_SUBST(VERSION_NUMBER) 474 AC_SUBST(VERSION_NUMBER_FOUR_POSITIONS) 475 AC_SUBST(VERSION_STRING) 476 AC_SUBST(VERSION_SHORT) 477 AC_SUBST(VERSION_IS_GA) 478 AC_SUBST(VERSION_DATE) 479 AC_SUBST(VENDOR_VERSION_STRING) 480 AC_SUBST(VERSION_CLASSFILE_MAJOR) 481 AC_SUBST(VERSION_CLASSFILE_MINOR) 482 483 ])