2 ###############################################################################
3 # Copyright (c) 2000-2014 Ericsson Telecom AB
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Eclipse Public License v1.0
6 # which accompanies this distribution, and is available at
7 # http://www.eclipse.org/legal/epl-v10.html
8 ###############################################################################
9 # Find Perl in the path
10 # Can't use `perl -e 'print $^X'` because that may print just "perl"
11 perlexe
=`which perl 2>/dev/null | sed -n 's/[^\/]*\(\/.*perl\)/\1/p'`
12 # Do it the hard way if not found
13 if [ -z "${perlexe}" ] ; then
15 GCCVER
=`strings -a -10 ${1+"$@"} | sed -n '
16 s/.*TITAN: [0-9][0-9]* PLATFORM: [A-Z0-9][A-Z0-9]* //
21 s/.*\(Sun C++ *[0-9]\.[0-9]\).*/\1/g
26 if [ `echo "${GCCVER}" | wc -l` != 1 ]; then
27 echo -e "Error! Object files compiled with different compilers were detected:
29 Please clean and rebuild your project.";
32 : ; # no news is good news
35 exit 0; # avoid flowing into Perl
38 #! Here begins the real -*- perl -*- -ws
40 # The above directive should be adjusted to the line number of ** this ** line
41 eval 'exec ${perlexe} -x $0 ${1+"$@"} ;'
50 my
$objdump = `/bin/sh -c "which objdump" 2>/dev/null`;
52 exit 0 if ($objdump !~ m
!^
/! or
!@ARGV
); # go quiet if no objdump or @ARGV is empty
56 my @sections
= qw
( .titan .comment
);
61 open
(PIPE
, $cmdline = "$objdump -s -j " .
join(' -j ', @sections
) .
" @ARGV |") or die
"open failed: $!";
69 if (/^
([^
:]+):\s
+file format
/) {
70 if (length
($comment)) {
71 ($found_ver) = $comment =~
/GCC
: \
([^
)]*\
) (\d\.\d
+(?
:\.\d
+)?
)/;
72 $found_ver ||
= 'unknown!';
74 print
"$compiler version was $found_ver for $obj\n" if $v;
76 push @
{$versions{$found_ver}}, $obj;
78 if (defined
$r and
$r ne
$found_ver)
80 if (!$v) { # found version was not written, do it now
81 warn
"$compiler was $found_ver for $obj\n";
84 die
" $r was expected\n";
94 [0-9a-fA-F ]{8} # first group of hex digits
96 [0-9a-fA-F ]{8} # these should be [[:xdigit:] ] but rhea's perl is ancient :(
102 (.
+) # up to 16 characters of "plain" text
109 close
(PIPE
) or die
"close failed: $!";
111 if ( scalar keys
%versions
> 1 ) {
112 while ( my
($ver, $ref) = each
%versions
) {
113 warn
"Compiled with $compiler $ver: ", join(', ', @
$ref), "\n";
115 die
"Error! All object files should be compiled with the same compiler version.\n"
116 .
"The following $compiler versions were detected: ", join(', ', keys
%versions
);
122 Parse the output of objdump
, which looks like this
:
124 core
/XmlReader.o
: file format elf64-x86-64
126 Contents of section .comment
:
127 0000 00474343 3a202847
4e552920
342e342e .GCC
: (GNU
) 4.4.
128 0010 30203230 30393032 31332028 65787065 0 20090213 (expe
129 0020 72696d65
6e74616c
2900 rimental
).
132 -r=x.x.x expected GCC version
137 ** -r=XXX supplied and one of the objects fail to match
138 ** more than one GCC version detected