xref: /aoo4110/main/solenv/bin/getcompver.awk (revision b1cdbd2c)
1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21BEGIN {
22    CCversion = 0
23    compiler_matched = 0
24}
25# Sun c++ compiler
26/Sun WorkShop/ || /Forte Developer/ || /Sun/{
27    compiler_matched = 1
28    # version number right after "C++"
29    x = match( $0, /C\+\+ .*/ )
30    btwn = substr( $0, RSTART, RLENGTH)
31    # extract version, whitespaces get striped later
32    x = match( btwn, / .*\..*[ $\t]/)
33    CCversion = substr( btwn, RSTART, RLENGTH)
34}
35# Microsoft c++ compiler
36/Microsoft/ && /..\...\...../ {
37    compiler_matched = 1
38    # match on the format of the ms versions ( dd.dd.dddd )
39    x = match( $0, /..\...\...../ )
40    CCversion = substr( $0, RSTART, RLENGTH)
41}
42# Java
43/java version/ || /openjdk version/ {
44    compiler_matched = 1
45    # match on the format of the java versions ( d[d].d[d].d[d] )
46    x = match( $0, /[0-9]*\.[0-9]*\.[0-9]*/ )
47    CCversion = substr( $0, RSTART, RLENGTH)
48}
49/^[0-9]*[.][0-9]*\x0d*$/ {
50    if ( compiler_matched == 0 ) {
51# need to blow to x.xx.xx for comparing
52    	CCversion = $0 ".0"
53    }
54}
55/^[0-9]*[.][0-9]*[.][0-9]*\x0d*$/ {
56    if ( compiler_matched == 0 ) {
57        CCversion = $0
58    }
59}
60/^[0-9]*[.][0-9]*[.][0-9]*-[0-9a-z]*$/ {
61    if ( compiler_matched == 0 ) {
62        CCversion = substr($0, 0, index($0, "-") - 1)
63    }
64}
65END {
66    if ( num == "true" ) {
67        tokencount = split (CCversion,vertoken,".")
68        for ( i = 1 ; i <= tokencount ; i++ ) {
69            printf ("%04d",vertoken[i] )
70        }
71    } else
72        print CCversion
73}
74