upload http
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / build / get-version.sh
1 #!/bin/sh
2 #
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
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
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.
17 #
18 #
19 # extract version numbers from a header file
20 #
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
24 #
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
28 #
29
30 if test $# != 3; then
31   echo "USAGE: $0 CMD INCLUDEDIR PREFIX"
32   echo "  where CMD is one of: all, major"
33   exit 1
34 fi
35
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`"
44
45 if test "$1" = "all"; then
46   echo ${major}.${minor}.${patch}
47 elif test "$1" = "major"; then
48   echo ${major}
49 elif test "$1" = "mmn"; then
50   echo ${mmn}
51 elif test "$1" = "libtool"; then
52   # Yes, ${minor}:${patch}:${minor} is correct due to libtool idiocy.
53   echo ${minor}:${patch}:${minor}
54 else
55   echo "ERROR: unknown version CMD ($1)"
56   exit 1
57 fi