File Coverage

inc/ILCPPConfig/OldCompilerGuess.pm
Criterion Covered Total %
statement 15 43 34.8
branch 5 22 22.7
condition 3 27 11.1
subroutine 4 4 100.0
pod 0 1 0.0
total 27 97 27.8


line stmt bran cond sub pod time code
1             package ILCPPConfig::OldCompilerGuess;
2              
3 1     1   104358 use strict;
  1         12  
  1         31  
4 1     1   5 use warnings;
  1         2  
  1         29  
5 1     1   5 use Config;
  1         3  
  1         546  
6              
7             our $VERSION = '0.01';
8              
9             # This is the logic we used to keep in Makefile.PL that was used to make an
10             # educated guess as to what compiler, compiler flags, standard libraries, and
11             # linker flags to configure into Inline::CPP.
12              
13             # Inline::CPP shifted to using ExtUtils::CppGuess instead, but retains this
14             # logic for testing purposes, as well as for working toward improving
15             # ExtUtils::CppGuess.
16              
17             # my( $cc_guess, $libs_guess ) = guess_compiler();
18              
19              
20             #============================================================================
21             # Make an intelligent guess about what compiler to use
22             #============================================================================
23              
24             sub guess_compiler {
25              
26 1     1 0 86 my( $cc_guess, $libs_guess );
27            
28 1 50 33     124 if ( $Config{osname} eq 'darwin' ) {
    50 33        
    50 0        
    50 0        
    0 0        
    0 0        
    0          
    0          
    0          
29 0         0 my $stdlib_query
30             = 'find /usr/lib/gcc -name "libstdc++*" | grep $( uname -p )';
31 0         0 my $stdcpp = `$stdlib_query`;
32 0         0 +$stdcpp =~ s/^(.*)\/[^\/]+$/$1/;
33 0         0 $cc_guess = 'g++';
34 0         0 $libs_guess = "-L$stdcpp -lstdc++";
35             }
36             elsif ( $Config{osname} ne 'darwin'
37             and $Config{gccversion}
38             and $Config{cc} =~ m#\bgcc\b[^/]*$#
39             ) {
40 0         0 ( $cc_guess = $Config{cc} ) =~ s[\bgcc\b([^/]*)$(?:)][g\+\+$1];
41 0         0 $libs_guess = '-lstdc++';
42             }
43             elsif ( $Config{osname} =~ m/^MSWin/ ) {
44 0         0 $cc_guess = 'cl -TP -EHsc';
45 0         0 $libs_guess = 'MSVCIRT.LIB';
46             }
47             elsif ( $Config{osname} eq 'linux' ) {
48 1         5 $cc_guess = 'g++';
49 1         3 $libs_guess = '-lstdc++';
50             }
51             # Dragonfly patch is just a hunch... (still doesn't work)
52             elsif ( $Config{osname} eq 'netbsd' || $Config{osname} eq 'dragonfly' ) {
53 0         0 $cc_guess = 'g++';
54 0         0 $libs_guess = '-lstdc++ -lgcc_s';
55             }
56             elsif ( $Config{osname} eq 'cygwin' ) {
57 0         0 $cc_guess = 'g++';
58 0         0 $libs_guess = '-lstdc++';
59             }
60             elsif ( $Config{osname} eq 'solaris' or $Config{osname} eq 'SunOS' ) {
61 0 0 0     0 if ( $Config{cc} eq 'gcc'
      0        
62             || ( exists( $Config{gccversion} ) && $Config{gccversion} > 0 ) )
63             {
64 0         0 $cc_guess = 'g++';
65 0         0 $libs_guess = '-lstdc++';
66             }
67             else {
68 0         0 $cc_guess = 'CC';
69 0         0 $libs_guess = '-lCrun';
70             }
71             }
72              
73             # MirBSD: Still problematic.
74             elsif ( $Config{osname} eq 'mirbsd' ) {
75 0         0 my $stdlib_query
76             = 'find /usr/lib/gcc -name "libstdc++*" | grep $( uname -p ) | head -1';
77 0         0 my $stdcpp = `$stdlib_query`;
78 0         0 +$stdcpp =~ s/^(.*)\/[^\/]+$/$1/;
79 0         0 $cc_guess = 'g++';
80 0         0 $libs_guess = "-L$stdcpp -lstdc++ -lc -lgcc_s";
81             }
82             elsif( $Config{osname} eq 'freebsd'
83             and $Config{osvers} =~ /^(\d+)/
84             and $1 >= 10
85             ){
86 0         0 $cc_guess = 'clang++';
87 0         0 $libs_guess = '-lc++';
88             }
89             # Sane defaults for other (probably unix-like) operating systems
90             else {
91 0         0 $cc_guess = 'g++';
92 0         0 $libs_guess = '-lstdc++';
93             }
94            
95 1 50 33     12 if( $cc_guess eq 'g++' && $Config{cc} eq 'clang') {
96 0         0 $cc_guess = 'clang++';
97             }
98              
99 1         17 return( $cc_guess, $libs_guess );
100             }
101              
102             1;