jdk-version.m4 revision 1758:b0f70258d774
1# 2# Copyright (c) 2015, 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 36AC_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 58AC_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 66 # Source the version numbers file 67 . $AUTOCONF_DIR/version-numbers 68 69 # Some non-version number information is set in that file 70 AC_SUBST(LAUNCHER_NAME) 71 AC_SUBST(PRODUCT_NAME) 72 AC_SUBST(PRODUCT_SUFFIX) 73 AC_SUBST(JDK_RC_PLATFORM_NAME) 74 AC_SUBST(COMPANY_NAME) 75 AC_SUBST(MACOSX_BUNDLE_NAME_BASE) 76 AC_SUBST(MACOSX_BUNDLE_ID_BASE) 77 78 # Override version from arguments 79 80 # If --with-version-string is set, process it first. It is possible to 81 # override parts with more specific flags, since these are processed later. 82 AC_ARG_WITH(version-string, [AS_HELP_STRING([--with-version-string], 83 [Set version string @<:@calculated@:>@])]) 84 if test "x$with_version_string" = xyes; then 85 AC_MSG_ERROR([--with-version-string must have a value]) 86 elif test "x$with_version_string" != x; then 87 # Additional [] needed to keep m4 from mangling shell constructs. 88 if [ [[ $with_version_string =~ ^([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(-([a-zA-Z]+))?((\+)([0-9]+)?(-([-a-zA-Z0-9.]+))?(_([a-zA-Z]+))?)?$ ]] ]; then 89 VERSION_MAJOR=${BASH_REMATCH[[1]]} 90 VERSION_MINOR=${BASH_REMATCH[[3]]} 91 VERSION_SECURITY=${BASH_REMATCH[[5]]} 92 VERSION_PATCH=${BASH_REMATCH[[7]]} 93 VERSION_PRE=${BASH_REMATCH[[9]]} 94 version_plus_separator=${BASH_REMATCH[[11]]} 95 VERSION_BUILD=${BASH_REMATCH[[12]]} 96 VERSION_OPT_BASE=${BASH_REMATCH[[14]]} 97 VERSION_OPT_DEBUGLEVEL=${BASH_REMATCH[[16]]} 98 # Unspecified numerical fields are interpreted as 0. 99 if test "x$VERSION_MINOR" = x; then 100 VERSION_MINOR=0 101 fi 102 if test "x$VERSION_SECURITY" = x; then 103 VERSION_SECURITY=0 104 fi 105 if test "x$VERSION_PATCH" = x; then 106 VERSION_PATCH=0 107 fi 108 if test "x$version_plus_separator" != x \ 109 && test "x$VERSION_BUILD$VERSION_OPT_BASE$VERSION_OPT_DEBUGLEVEL" = x; then 110 AC_MSG_ERROR([Version string contains + but both 'BUILD' and 'OPT' are missing]) 111 fi 112 # Stop the version part process from setting default values. 113 # We still allow them to explicitely override though. 114 NO_DEFAULT_VERSION_PARTS=true 115 else 116 AC_MSG_ERROR([--with-version-string fails to parse as a valid version string: $with_version_string]) 117 fi 118 fi 119 120 AC_ARG_WITH(version-pre, [AS_HELP_STRING([--with-version-pre], 121 [Set the base part of the version 'PRE' field (pre-release identifier) @<:@'internal'@:>@])], 122 [with_version_pre_present=true], [with_version_pre_present=false]) 123 124 if test "x$with_version_pre_present" = xtrue; then 125 if test "x$with_version_pre" = xyes; then 126 AC_MSG_ERROR([--with-version-pre must have a value]) 127 elif test "x$with_version_pre" = xno; then 128 # Interpret --without-* as empty string instead of the literal "no" 129 VERSION_PRE= 130 else 131 # Only [a-zA-Z] is allowed in the VERSION_PRE. Outer [ ] to quote m4. 132 [ VERSION_PRE=`$ECHO "$with_version_pre" | $TR -c -d '[a-z][A-Z]'` ] 133 if test "x$VERSION_PRE" != "x$with_version_pre"; then 134 AC_MSG_WARN([--with-version-pre value has been sanitized from '$with_version_pre' to '$VERSION_PRE']) 135 fi 136 fi 137 else 138 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 139 # Default is to use "internal" as pre 140 VERSION_PRE="internal" 141 fi 142 fi 143 144 AC_ARG_WITH(version-opt-base, [AS_HELP_STRING([--with-version-opt-base], 145 [Set version 'OPT' base field. Debug level will be appended. (build metadata) @<:@<timestamp>.<user>.<dirname>@:>@])], 146 [with_version_opt_base_present=true], [with_version_opt_base_present=false]) 147 148 if test "x$with_version_opt_base_present" = xtrue; then 149 if test "x$with_version_opt_base" = xyes; then 150 AC_MSG_ERROR([--with-version-opt-base must have a value]) 151 elif test "x$with_version_opt_base" = xno; then 152 # Interpret --without-* as empty string instead of the literal "no" 153 VERSION_OPT_BASE= 154 else 155 # Only [-.a-zA-Z0-9] is allowed in the VERSION_OPT_BASE. Outer [ ] to quote m4. 156 [ VERSION_OPT_BASE=`$ECHO "$with_version_opt_base" | $TR -c -d '[a-z][A-Z][0-9].-'` ] 157 if test "x$VERSION_OPT_BASE" != "x$with_version_opt_base"; then 158 AC_MSG_WARN([--with-version-opt-base value has been sanitized from '$with_version_opt_base' to '$VERSION_OPT_BASE']) 159 fi 160 fi 161 else 162 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 163 # Default is to calculate a string like this <timestamp>.<username>.<base dir name> 164 timestamp=`$DATE '+%Y-%m-%d-%H%M%S'` 165 # Outer [ ] to quote m4. 166 [ username=`$ECHO "$USER" | $TR -d -c '[a-z][A-Z][0-9]'` ] 167 [ basedirname=`$BASENAME "$TOPDIR" | $TR -d -c '[a-z][A-Z][0-9].-'` ] 168 VERSION_OPT_BASE="$timestamp.$username.$basedirname" 169 fi 170 fi 171 172 AC_ARG_WITH(version-opt-debuglevel, [AS_HELP_STRING([--with-version-opt-debuglevel], 173 [Set version 'OPT' field (build metadata) @<:@<timestamp>.<user>.<dirname>@:>@])], 174 [with_version_opt_debuglevel_present=true], [with_version_opt_debuglevel_present=false]) 175 176 if test "x$with_version_opt_debuglevel_present" = xtrue; then 177 if test "x$with_version_opt_debuglevel" = xyes; then 178 AC_MSG_ERROR([--with-version-opt-debuglevel must have a value]) 179 elif test "x$with_version_opt_debuglevel" = xno; then 180 # Interpret --without-* as empty string instead of the literal "no" 181 VERSION_OPT_DEBUGLEVEL= 182 else 183 # Only [-.a-zA-Z0-9] is allowed in the VERSION_OPT_DEBUGLEVEL. Outer [ ] to quote m4. 184 [ VERSION_OPT_DEBUGLEVEL=`$ECHO "$with_version_opt_debuglevel" | $TR -c -d '[a-z][A-Z][0-9].-'` ] 185 if test "x$VERSION_OPT_DEBUGLEVEL" != "x$with_version_opt_debuglevel"; then 186 AC_MSG_WARN([--with-version-opt-debuglevel value has been sanitized from '$with_version_opt_debuglevel' to '$VERSION_OPT_DEBUGLEVEL']) 187 fi 188 fi 189 else 190 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 191 # Default is to use the debug level name, except for release which is empty. 192 if test "x$DEBUG_LEVEL" != "xrelease"; then 193 VERSION_OPT_DEBUGLEVEL="$DEBUG_LEVEL" 194 else 195 VERSION_OPT_DEBUGLEVEL="" 196 fi 197 fi 198 fi 199 AC_ARG_WITH(version-build, [AS_HELP_STRING([--with-version-build], 200 [Set version 'BUILD' field (build number) @<:@not specified@:>@])], 201 [with_version_build_present=true], [with_version_build_present=false]) 202 203 if test "x$with_version_build_present" = xtrue; then 204 if test "x$with_version_build" = xyes; then 205 AC_MSG_ERROR([--with-version-build must have a value]) 206 elif test "x$with_version_build" = xno; then 207 # Interpret --without-* as empty string instead of the literal "no" 208 VERSION_BUILD= 209 elif test "x$with_version_build" = x; then 210 VERSION_BUILD= 211 else 212 JDKVER_CHECK_AND_SET_NUMBER(VERSION_BUILD, $with_version_build) 213 fi 214 else 215 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 216 # Default is to not have a build number. 217 VERSION_BUILD="" 218 # FIXME: Until all code can cope with an empty VERSION_BUILD, set it to 0. 219 VERSION_BUILD=0 220 fi 221 fi 222 223 AC_ARG_WITH(version-major, [AS_HELP_STRING([--with-version-major], 224 [Set version 'MAJOR' field (first number) @<:@current source value@:>@])], 225 [with_version_major_present=true], [with_version_major_present=false]) 226 227 if test "x$with_version_major_present" = xtrue; then 228 if test "x$with_version_major" = xyes; then 229 AC_MSG_ERROR([--with-version-major must have a value]) 230 else 231 JDKVER_CHECK_AND_SET_NUMBER(VERSION_MAJOR, $with_version_major) 232 fi 233 else 234 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 235 # Default is to get value from version-numbers 236 VERSION_MAJOR="$DEFAULT_VERSION_MAJOR" 237 fi 238 fi 239 240 AC_ARG_WITH(version-minor, [AS_HELP_STRING([--with-version-minor], 241 [Set version 'MINOR' field (second number) @<:@current source value@:>@])], 242 [with_version_minor_present=true], [with_version_minor_present=false]) 243 244 if test "x$with_version_minor_present" = xtrue; then 245 if test "x$with_version_minor" = xyes; then 246 AC_MSG_ERROR([--with-version-minor must have a value]) 247 elif test "x$with_version_minor" = xno; then 248 # Interpret --without-* as empty string (i.e. 0) instead of the literal "no" 249 VERSION_MINOR=0 250 elif test "x$with_version_minor" = x; then 251 VERSION_MINOR=0 252 else 253 JDKVER_CHECK_AND_SET_NUMBER(VERSION_MINOR, $with_version_minor) 254 fi 255 else 256 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 257 # Default is 0, if unspecified 258 VERSION_MINOR=0 259 fi 260 fi 261 262 AC_ARG_WITH(version-security, [AS_HELP_STRING([--with-version-security], 263 [Set version 'SECURITY' field (third number) @<:@current source value@:>@])], 264 [with_version_security_present=true], [with_version_security_present=false]) 265 266 if test "x$with_version_security_present" = xtrue; then 267 if test "x$with_version_security" = xyes; then 268 AC_MSG_ERROR([--with-version-security must have a value]) 269 elif test "x$with_version_security" = xno; then 270 # Interpret --without-* as empty string (i.e. 0) instead of the literal "no" 271 VERSION_SECURITY=0 272 elif test "x$with_version_security" = x; then 273 VERSION_SECURITY=0 274 else 275 JDKVER_CHECK_AND_SET_NUMBER(VERSION_SECURITY, $with_version_security) 276 fi 277 else 278 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 279 # Default is 0, if unspecified 280 VERSION_SECURITY=0 281 fi 282 fi 283 284 AC_ARG_WITH(version-patch, [AS_HELP_STRING([--with-version-patch], 285 [Set version 'PATCH' field (fourth number) @<:@not specified@:>@])], 286 [with_version_patch_present=true], [with_version_patch_present=false]) 287 288 if test "x$with_version_patch_present" = xtrue; then 289 if test "x$with_version_patch" = xyes; then 290 AC_MSG_ERROR([--with-version-patch must have a value]) 291 elif test "x$with_version_patch" = xno; then 292 # Interpret --without-* as empty string (i.e. 0) instead of the literal "no" 293 VERSION_PATCH=0 294 elif test "x$with_version_patch" = x; then 295 VERSION_PATCH=0 296 else 297 JDKVER_CHECK_AND_SET_NUMBER(VERSION_PATCH, $with_version_patch) 298 fi 299 else 300 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then 301 # Default is 0, if unspecified 302 VERSION_PATCH=0 303 fi 304 fi 305 306 # Calculate derived version properties 307 308 # Set opt to "opt-base" if debug level is empty (i.e. release), or 309 # "opt-base_debug-level" otherwise. 310 VERSION_OPT=$VERSION_OPT_BASE${VERSION_OPT_DEBUGLEVEL:+_$VERSION_OPT_DEBUGLEVEL} 311 312 # VERSION_NUMBER but always with exactly 4 positions, with 0 for empty positions. 313 VERSION_NUMBER_FOUR_POSITIONS=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_SECURITY.$VERSION_PATCH 314 315 stripped_version_number=$VERSION_NUMBER_FOUR_POSITIONS 316 # Strip trailing zeroes from stripped_version_number 317 for i in 1 2 3 ; do stripped_version_number=${stripped_version_number%.0} ; done 318 VERSION_NUMBER=$stripped_version_number 319 320 # The complete version string, with additional build information 321 if test "x$VERSION_BUILD$VERSION_OPT" = x; then 322 VERSION_STRING=$VERSION_NUMBER${VERSION_PRE:+-$VERSION_PRE} 323 else 324 # If either build or opt is set, we need a + separator 325 VERSION_STRING=$VERSION_NUMBER${VERSION_PRE:+-$VERSION_PRE}+$VERSION_BUILD${VERSION_OPT:+-$VERSION_OPT} 326 fi 327 328 # The short version string, just VERSION_NUMBER and PRE, if present. 329 VERSION_SHORT=$VERSION_NUMBER${VERSION_PRE:+-$VERSION_PRE} 330 331 AC_MSG_CHECKING([for version string]) 332 AC_MSG_RESULT([$VERSION_STRING]) 333 334 AC_SUBST(VERSION_MAJOR) 335 AC_SUBST(VERSION_MINOR) 336 AC_SUBST(VERSION_SECURITY) 337 AC_SUBST(VERSION_PATCH) 338 AC_SUBST(VERSION_PRE) 339 AC_SUBST(VERSION_BUILD) 340 AC_SUBST(VERSION_OPT) 341 AC_SUBST(VERSION_NUMBER) 342 AC_SUBST(VERSION_NUMBER_FOUR_POSITIONS) 343 AC_SUBST(VERSION_STRING) 344 AC_SUBST(VERSION_SHORT) 345]) 346