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