3
# Licensed to the Apache Software Foundation (ASF) under one or more
4
# contributor license agreements. See the NOTICE file distributed with
5
# this work for additional information regarding copyright ownership.
6
# The ASF licenses this file to You under the Apache License, Version 2.0
7
# (the "License"); you may not use this file except in compliance with
8
# the License. You may obtain a copy of the License at
10
# http://www.apache.org/licenses/LICENSE-2.0
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS,
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
# See the License for the specific language governing permissions and
16
# limitations under the License.
19
# extract version numbers from a header file
21
# USAGE: get-version.sh CMD VERSION_HEADER PREFIX
22
# where CMD is one of: all, major, libtool
23
# where PREFIX is the prefix to {MAJOR|MINOR|PATCH}_VERSION defines
25
# get-version.sh all returns a dotted version number
26
# get-version.sh major returns just the major version number
27
# get-version.sh libtool returns a version "libtool -version-info" format
31
echo "USAGE: $0 CMD INCLUDEDIR PREFIX"
32
echo " where CMD is one of: all, major"
36
major_sed="/#define.*$3_MAJORVERSION/s/^.*\([0-9][0-9]*\).*$/\1/p"
37
minor_sed="/#define.*$3_MINORVERSION/s/^.*\([0-9][0-9]*\).*$/\1/p"
38
patch_sed="/#define.*$3_PATCHLEVEL/s/^[^0-9]*\([0-9][0-9a-z-]*\).*$/\1/p"
39
mmn_sed="/#define.*$3_MAJOR/s/^[^0-9]*\([0-9][0-9]*\).*$/\1/p"
40
major="`sed -n $major_sed $2`"
41
minor="`sed -n $minor_sed $2`"
42
patch="`sed -n $patch_sed $2`"
43
mmn="`sed -n $mmn_sed $2`"
45
if test "$1" = "all"; then
46
echo ${major}.${minor}.${patch}
47
elif test "$1" = "major"; then
49
elif test "$1" = "mmn"; then
51
elif test "$1" = "libtool"; then
52
# Yes, ${minor}:${patch}:${minor} is correct due to libtool idiocy.
53
echo ${minor}:${patch}:${minor}
55
echo "ERROR: unknown version CMD ($1)"