83 [Set version string @<:@calculated@:>@])]) |
83 [Set version string @<:@calculated@:>@])]) |
84 if test "x$with_version_string" = xyes; then |
84 if test "x$with_version_string" = xyes; then |
85 AC_MSG_ERROR([--with-version-string must have a value]) |
85 AC_MSG_ERROR([--with-version-string must have a value]) |
86 elif test "x$with_version_string" != x; then |
86 elif test "x$with_version_string" != x; then |
87 # Additional [] needed to keep m4 from mangling shell constructs. |
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]+))?(\.([a-zA-Z]+))?((\+)([0-9]+)?(-([-a-zA-Z0-9.]+))?)?$ ]] ]; then |
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]]} |
89 VERSION_MAJOR=${BASH_REMATCH[[1]]} |
90 VERSION_MINOR=${BASH_REMATCH[[3]]} |
90 VERSION_MINOR=${BASH_REMATCH[[3]]} |
91 VERSION_SECURITY=${BASH_REMATCH[[5]]} |
91 VERSION_SECURITY=${BASH_REMATCH[[5]]} |
92 VERSION_PATCH=${BASH_REMATCH[[7]]} |
92 VERSION_PATCH=${BASH_REMATCH[[7]]} |
93 VERSION_PRE_BASE=${BASH_REMATCH[[9]]} |
93 VERSION_PRE=${BASH_REMATCH[[9]]} |
94 VERSION_PRE_DEBUGLEVEL=${BASH_REMATCH[[11]]} |
94 version_plus_separator=${BASH_REMATCH[[11]]} |
95 version_plus_separator=${BASH_REMATCH[[13]]} |
95 VERSION_BUILD=${BASH_REMATCH[[12]]} |
96 VERSION_BUILD=${BASH_REMATCH[[14]]} |
96 VERSION_OPT_BASE=${BASH_REMATCH[[14]]} |
97 VERSION_OPT=${BASH_REMATCH[[16]]} |
97 VERSION_OPT_DEBUGLEVEL=${BASH_REMATCH[[16]]} |
98 # Unspecified numerical fields are interpreted as 0. |
98 # Unspecified numerical fields are interpreted as 0. |
99 if test "x$VERSION_MINOR" = x; then |
99 if test "x$VERSION_MINOR" = x; then |
100 VERSION_MINOR=0 |
100 VERSION_MINOR=0 |
101 fi |
101 fi |
102 if test "x$VERSION_SECURITY" = x; then |
102 if test "x$VERSION_SECURITY" = x; then |
103 VERSION_SECURITY=0 |
103 VERSION_SECURITY=0 |
104 fi |
104 fi |
105 if test "x$VERSION_PATCH" = x; then |
105 if test "x$VERSION_PATCH" = x; then |
106 VERSION_PATCH=0 |
106 VERSION_PATCH=0 |
107 fi |
107 fi |
108 if test "x$version_plus_separator" != x && test "x$VERSION_BUILD$VERSION_OPT" = x; then |
108 if test "x$version_plus_separator" != x \ |
|
109 && test "x$VERSION_BUILD$VERSION_OPT_BASE$VERSION_OPT_DEBUGLEVEL" = x; then |
109 AC_MSG_ERROR([Version string contains + but both 'BUILD' and 'OPT' are missing]) |
110 AC_MSG_ERROR([Version string contains + but both 'BUILD' and 'OPT' are missing]) |
110 fi |
111 fi |
111 # Stop the version part process from setting default values. |
112 # Stop the version part process from setting default values. |
112 # We still allow them to explicitely override though. |
113 # We still allow them to explicitely override though. |
113 NO_DEFAULT_VERSION_PARTS=true |
114 NO_DEFAULT_VERSION_PARTS=true |
114 else |
115 else |
115 AC_MSG_ERROR([--with-version-string fails to parse as a valid version string: $with_version_string]) |
116 AC_MSG_ERROR([--with-version-string fails to parse as a valid version string: $with_version_string]) |
116 fi |
117 fi |
117 fi |
118 fi |
118 |
119 |
119 AC_ARG_WITH(version-pre-base, [AS_HELP_STRING([--with-version-pre-base], |
120 AC_ARG_WITH(version-pre, [AS_HELP_STRING([--with-version-pre], |
120 [Set the base part of the version 'PRE' field (pre-release identifier) @<:@'internal'@:>@])], |
121 [Set the base part of the version 'PRE' field (pre-release identifier) @<:@'internal'@:>@])], |
121 [with_version_pre_base_present=true], [with_version_pre_base_present=false]) |
122 [with_version_pre_present=true], [with_version_pre_present=false]) |
122 |
123 |
123 if test "x$with_version_pre_base_present" = xtrue; then |
124 if test "x$with_version_pre_present" = xtrue; then |
124 if test "x$with_version_pre_base" = xyes; then |
125 if test "x$with_version_pre" = xyes; then |
125 AC_MSG_ERROR([--with-version-pre-base must have a value]) |
126 AC_MSG_ERROR([--with-version-pre must have a value]) |
126 elif test "x$with_version_pre_base" = xno; then |
127 elif test "x$with_version_pre" = xno; then |
127 # Interpret --without-* as empty string instead of the literal "no" |
128 # Interpret --without-* as empty string instead of the literal "no" |
128 VERSION_PRE_BASE= |
129 VERSION_PRE= |
129 else |
130 else |
130 # Only [a-zA-Z] is allowed in the VERSION_PRE. Outer [ ] to quote m4. |
131 # Only [a-zA-Z] is allowed in the VERSION_PRE. Outer [ ] to quote m4. |
131 [ VERSION_PRE_BASE=`$ECHO "$with_version_pre_base" | $TR -c -d '[a-z][A-Z]'` ] |
132 [ VERSION_PRE=`$ECHO "$with_version_pre" | $TR -c -d '[a-z][A-Z]'` ] |
132 if test "x$VERSION_PRE_BASE" != "x$with_version_pre_base"; then |
133 if test "x$VERSION_PRE" != "x$with_version_pre"; then |
133 AC_MSG_WARN([--with-version-pre-base value has been sanitized from '$with_version_pre_base' to '$VERSION_PRE_BASE']) |
134 AC_MSG_WARN([--with-version-pre value has been sanitized from '$with_version_pre' to '$VERSION_PRE']) |
134 fi |
135 fi |
135 fi |
136 fi |
136 else |
137 else |
137 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then |
138 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then |
138 # Default is to use "internal" as pre |
139 # Default is to use "internal" as pre |
139 VERSION_PRE_BASE="internal" |
140 VERSION_PRE="internal" |
140 fi |
141 fi |
141 fi |
142 fi |
142 |
143 |
143 AC_ARG_WITH(version-pre-debuglevel, [AS_HELP_STRING([--with-version-pre-debuglevel], |
144 AC_ARG_WITH(version-opt-base, [AS_HELP_STRING([--with-version-opt-base], |
144 [Set the debug level part of the version 'PRE' field (pre-release identifier) @<:@current debug level@:>@])], |
145 [Set version 'OPT' base field. Debug level will be appended. (build metadata) @<:@<timestamp>.<user>.<dirname>@:>@])], |
145 [with_version_pre_debuglevel_present=true], [with_version_pre_debuglevel_present=false]) |
146 [with_version_opt_base_present=true], [with_version_opt_base_present=false]) |
146 |
147 |
147 if test "x$with_version_pre_debuglevel_present" = xtrue; then |
148 if test "x$with_version_opt_base_present" = xtrue; then |
148 if test "x$with_version_pre_debuglevel" = xyes; then |
149 if test "x$with_version_opt_base" = xyes; then |
149 AC_MSG_ERROR([--with-version-pre-debuglevel must have a value]) |
150 AC_MSG_ERROR([--with-version-opt-base must have a value]) |
150 elif test "x$with_version_pre_debuglevel" = xno; then |
151 elif test "x$with_version_opt_base" = xno; then |
151 # Interpret --without-* as empty string instead of the literal "no" |
152 # Interpret --without-* as empty string instead of the literal "no" |
152 VERSION_PRE_DEBUGLEVEL= |
153 VERSION_OPT_BASE= |
153 else |
154 else |
154 # Only [a-zA-Z] is allowed in the VERSION_PRE. Outer [ ] to quote m4. |
155 # Only [-.a-zA-Z0-9] is allowed in the VERSION_OPT_BASE. Outer [ ] to quote m4. |
155 [ VERSION_PRE_DEBUGLEVEL=`$ECHO "$with_version_pre_debuglevel" | $TR -c -d '[a-z][A-Z]'` ] |
156 [ VERSION_OPT_BASE=`$ECHO "$with_version_opt_base" | $TR -c -d '[a-z][A-Z][0-9].-'` ] |
156 if test "x$VERSION_PRE_DEBUGLEVEL" != "x$with_version_pre_debuglevel"; then |
157 if test "x$VERSION_OPT_BASE" != "x$with_version_opt_base"; then |
157 AC_MSG_WARN([--with-version-pre-debuglevel value has been sanitized from '$with_version_pre_debuglevel' to '$VERSION_PRE_DEBUGLEVEL']) |
158 AC_MSG_WARN([--with-version-opt-base value has been sanitized from '$with_version_opt_base' to '$VERSION_OPT_BASE']) |
158 fi |
|
159 fi |
|
160 else |
|
161 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then |
|
162 # Default is to use the debug level name, except for release which is empty. |
|
163 if test "x$DEBUG_LEVEL" != "xrelease"; then |
|
164 VERSION_PRE_DEBUGLEVEL="$DEBUG_LEVEL" |
|
165 else |
|
166 VERSION_PRE_DEBUGLEVEL="" |
|
167 fi |
|
168 fi |
|
169 fi |
|
170 |
|
171 AC_ARG_WITH(version-opt, [AS_HELP_STRING([--with-version-opt], |
|
172 [Set version 'OPT' field (build metadata) @<:@<timestamp>.<user>.<dirname>@:>@])], |
|
173 [with_version_opt_present=true], [with_version_opt_present=false]) |
|
174 |
|
175 if test "x$with_version_opt_present" = xtrue; then |
|
176 if test "x$with_version_opt" = xyes; then |
|
177 AC_MSG_ERROR([--with-version-opt must have a value]) |
|
178 elif test "x$with_version_opt" = xno; then |
|
179 # Interpret --without-* as empty string instead of the literal "no" |
|
180 VERSION_OPT= |
|
181 else |
|
182 # Only [-.a-zA-Z0-9] is allowed in the VERSION_OPT. Outer [ ] to quote m4. |
|
183 [ VERSION_OPT=`$ECHO "$with_version_opt" | $TR -c -d '[a-z][A-Z][0-9].-'` ] |
|
184 if test "x$VERSION_OPT" != "x$with_version_opt"; then |
|
185 AC_MSG_WARN([--with-version-opt value has been sanitized from '$with_version_opt' to '$VERSION_OPT']) |
|
186 fi |
159 fi |
187 fi |
160 fi |
188 else |
161 else |
189 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then |
162 if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then |
190 # Default is to calculate a string like this <timestamp>.<username>.<base dir name> |
163 # Default is to calculate a string like this <timestamp>.<username>.<base dir name> |
191 timestamp=`$DATE '+%Y-%m-%d-%H%M%S'` |
164 timestamp=`$DATE '+%Y-%m-%d-%H%M%S'` |
192 # Outer [ ] to quote m4. |
165 # Outer [ ] to quote m4. |
193 [ username=`$ECHO "$USER" | $TR -d -c '[a-z][A-Z][0-9]'` ] |
166 [ username=`$ECHO "$USER" | $TR -d -c '[a-z][A-Z][0-9]'` ] |
194 [ basedirname=`$BASENAME "$TOPDIR" | $TR -d -c '[a-z][A-Z][0-9].-'` ] |
167 [ basedirname=`$BASENAME "$TOPDIR" | $TR -d -c '[a-z][A-Z][0-9].-'` ] |
195 VERSION_OPT="$timestamp.$username.$basedirname" |
168 VERSION_OPT_BASE="$timestamp.$username.$basedirname" |
196 fi |
169 fi |
197 fi |
170 fi |
198 |
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], |
199 AC_ARG_WITH(version-build, [AS_HELP_STRING([--with-version-build], |
200 [Set version 'BUILD' field (build number) @<:@not specified@:>@])], |
200 [Set version 'BUILD' field (build number) @<:@not specified@:>@])], |
201 [with_version_build_present=true], [with_version_build_present=false]) |
201 [with_version_build_present=true], [with_version_build_present=false]) |
202 |
202 |
203 if test "x$with_version_build_present" = xtrue; then |
203 if test "x$with_version_build_present" = xtrue; then |