-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathcheck_compiler.pm
More file actions
143 lines (125 loc) · 3.95 KB
/
check_compiler.pm
File metadata and controls
143 lines (125 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#
package check_compiler;
use strict;
use warnings;
use Cwd;
use common::utility;
###############################################################################
# Constructor
sub new
{
my $proto = shift;
my $class = ref ($proto) || $proto;
my $self = {
'required_by_default' => 1,
};
bless ($self, $class);
return $self;
}
##############################################################################
sub CheckRequirements ()
{
my $self = shift;
return 1;
}
##############################################################################
sub Run ($)
{
my $self = shift;
my $compiler = shift;
if (!defined $compiler || $compiler eq "") {
$compiler = main::GetVariable ('the_compiler');
}
main::PrintStatus ('Config', "check compiler $compiler" );
print "================ Compiler version ================\n";
if ($compiler =~ m/^(\w*-)*(gcc|g\+\+|clang|ccsimpc|(cc|c\+\+)(pentium|ppc))/) {
if (!utility::run_command ("$compiler -v 2>&1")) {
return 0;
}
if ($compiler =~ /^(\w*-)*(gcc|g\+\+|clang)/) {
my $linker = `$compiler -print-prog-name=ld`;
chomp $linker;
if ($linker =~ m/ld$/) {
return utility::run_command ($linker." -v 2>&1");
}
elsif ($linker =~ m/ccs/) {
return utility::run_command ($linker." -V 2>&1");
}
else {
print STDERR __FILE__, ": ERROR: Unexpected Linker: $linker\n";
}
}
}
elsif (lc $compiler =~ m/^(sun_cc|studio|suncc)/) {
return utility::run_command ("CC -V");
}
elsif (lc $compiler eq "mingwcygwin") {
return utility::run_command ("g++ -v -mno-cygwin");
}
elsif (lc $compiler =~ m/^(bcc(.*))$/) {
return utility::run_command ("$1 --version");
}
elsif (lc $compiler eq "kylix") {
return utility::run_command ("bc++ -V");
}
elsif ($compiler =~ m/^(dcc|dplus)/) {
return utility::run_command ($compiler . " -V");
}
elsif (lc $compiler eq "dm") {
return utility::run_command ("scppn");
}
elsif (lc $compiler =~ m/^(msvc|vc|cl)/) {
return utility::run_command ("cl");
}
elsif (lc $compiler eq "deccxx") {
return utility::run_command ("cxx/VERSION");
}
elsif (lc $compiler eq "cxx") {
return utility::run_command ("cxx -V");
}
elsif (lc $compiler eq "acc") {
return utility::run_command ("aCC -V");
}
elsif (lc $compiler eq "pgcc") {
return utility::run_command ("pgCC -V");
}
elsif (lc $compiler eq "mipspro") {
return utility::run_command ("CC -version");
}
elsif (lc $compiler eq "doxygen") {
return utility::run_command ("doxygen --version");
}
elsif ($compiler =~ m/^(ecc|icc|icpc)/) {
return utility::run_command ("$compiler -V 2>&1");
}
elsif (lc $compiler eq "icl") {
return utility::run_command ("icl");
}
elsif ($compiler =~ m/^(ibmcxx)/i) {
if (-x "/usr/bin/lslpp") {
return utility::run_command ("/usr/bin/lslpp -l ibmcxx.cmp | grep ibmcxx.cmp");
}
else {
print STDERR __FILE__, ": " .
"ERROR: Could not find /usr/bin/lslpp!!\n";
}
}
elsif ($compiler =~ m/^(vacpp)/i) {
if (-x "/usr/bin/lslpp") {
return utility::run_command ("/usr/bin/lslpp -l | grep -i \'C++ Compiler\'");
}
else {
print STDERR __FILE__, ": " .
"ERROR: Could not find /usr/bin/lslpp!!\n";
}
}
elsif (lc $compiler eq "c89") {
return utility::run_command ("c89 -Whelp 2>&1 | tail -2");
}
else {
print STDERR __FILE__, ": " . "Invalid Compiler Option: $compiler\n";
}
return 0;
}
##############################################################################
main::RegisterCommand ("check_compiler", new check_compiler());