Alt-Acme-Math-XS-CPP

 view release on metacpan or  search on metacpan

inc/ExtUtils/CppGuess.pm  view on Meta::CPAN

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
 
use strict;
 
=head1 NAME
 
ExtUtils::CppGuess - guess C++ compiler and flags
 
=head1 SYNOPSIS
 
With L<Extutils::MakeMaker>:
 
    use ExtUtils::CppGuess;
     
    my $guess = ExtUtils::CppGuess->new;
     
    WriteMakefile
      ( # MakeMaker args,
        $guess->makemaker_options,
        );
 
With L<Module::Build>:
 
    my $guess = ExtUtils::CppGuess->new;
     
    my $build = Module::Build->new
      ( # Module::Build arguments
        $guess->module_build_options,
        );
    $build->create_build_script;
 
=head1 DESCRIPTION
 
C<ExtUtils::CppGuess> attempts to guess the system's C++ compiler
that is compatible with the C compiler that your perl was built with.
 
It can generate the necessary options to the L<Module::Build>
constructor or to L<ExtUtils::MakeMaker>'s C<WriteMakefile>
function.
 
=head1 METHODS
 
=head2 new

inc/ExtUtils/CppGuess.pm  view on Meta::CPAN

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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
sub new {
    my( $class, %args ) = @_;
    my $self = bless {
      cc => $Config::Config{cc},
      %args
    }, $class;
 
    return $self;
}
 
sub guess_compiler {
    my( $self ) = @_;
    return $self->{guess} if $self->{guess};
 
    if( $^O =~ /^mswin/i ) {
        $self->_guess_win32() or return();
    } else {
        $self->_guess_unix() or return();
    }
 
    return $self->{guess};
}
 
sub _get_cflags {
    my( $self ) = @_;
    $self->guess_compiler || die;
    my $cflags = $self->{guess}{extra_cflags};
    $cflags .= ' ' . $self->{extra_compiler_flags}
      if defined $self->{extra_compiler_flags};
    return $cflags;
}
 
sub _get_lflags {
    my( $self ) = @_;
    $self->guess_compiler || die;
    my $lflags = $self->{guess}{extra_lflags};
    $lflags .= ' ' . $self->{extra_linker_flags}
      if defined $self->{extra_linker_flags};
    return $lflags;
}
 
sub makemaker_options {
    my( $self ) = @_;
 
    my $lflags = $self->_get_lflags;
    my $cflags = $self->_get_cflags;

inc/ExtUtils/CppGuess.pm  view on Meta::CPAN

169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
    my( $self ) = @_;
 
    my $lflags = $self->_get_lflags;
    my $cflags = $self->_get_cflags;
 
    return ( extra_compiler_flags => $cflags,
             extra_linker_flags   => $lflags,
             );
}
 
sub _guess_win32 {
    my( $self ) = @_;
    my $c_compiler = $self->{cc};
    $c_compiler = $Config::Config{cc} if not defined $c_compiler;
 
    if( $self->_cc_is_gcc( $c_compiler ) ) {
        $self->{guess} = { extra_cflags => ' -xc++ ',
                           extra_lflags => ' -lstdc++ ',
                           };
    } elsif( $self->_cc_is_msvc( $c_compiler ) ) {
        $self->{guess} = { extra_cflags => ' -TP -EHsc ',
                           extra_lflags => ' msvcprt.lib ',
                           };
    } else {
        die "Unable to determine a C++ compiler for '$c_compiler'";
    }
 
    return 1;
}
 
sub _guess_unix {
    my( $self ) = @_;
    my $c_compiler = $self->{cc};
    $c_compiler = $Config::Config{cc} if not defined $c_compiler;
 
    if( !$self->_cc_is_gcc( $c_compiler ) ) {
        die "Unable to determine a C++ compiler for '$c_compiler'";
    }
 
    $self->{guess} = { extra_cflags => ' -xc++ ',
                       extra_lflags => ' -lstdc++ ',
                       };
    $self->{guess}{extra_cflags} .= ' -D_FILE_OFFSET_BITS=64' if $Config::Config{ccflags} =~ /-D_FILE_OFFSET_BITS=64/;
    $self->{guess}{extra_lflags} .= ' -lgcc_s' if $^O eq 'netbsd' && $self->{guess}{extra_lflags} !~ /-lgcc_s/;
    return 1;
}
 
# originally from Alien::wxWidgets::Utility
 
my $quotes = $^O =~ /MSWin32/ ? '"' : "'";
 
sub _capture {
    my @cmd = @_;
    my $out = capture_merged {

inc/ExtUtils/CppGuess.pm  view on Meta::CPAN

259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
       )
    {
        $self->{is_gcc} = 1;
    }
 
    return $self->{is_gcc};
}
 
sub is_gcc {
    my( $self ) = @_;
    $self->guess_compiler || die;
    return $self->{is_gcc};
}
 
sub is_msvc {
    my( $self ) = @_;
    $self->guess_compiler || die;
    return $self->{is_msvc};
}
 
sub add_extra_compiler_flags {
    my( $self, $string ) = @_;
    $self->{extra_compiler_flags}
      = defined($self->{extra_compiler_flags})
        ? $self->{extra_compiler_flags} . ' ' . $string
        : $string;
}

inc/Inline/CPP/Config.pm  view on Meta::CPAN

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
# This module comes from Inline::Module share file: 'CPPConfig.pm'
 
use strict; use warnings;
 
use Config;
 
our ($compiler, $libs, $iostream_fn, $cpp_flavor_defs) = guess();
 
sub guess {
    my ($compiler, $libs, $iostream_fn, $cpp_flavor_defs);
    $iostream_fn = 'iostream';
    $cpp_flavor_defs = <<'.';
#define __INLINE_CPP_STANDARD_HEADERS 1
#define __INLINE_CPP_NAMESPACE_STD 1
.
 
    if ($Config::Config{osname} eq 'freebsd'
        && $Config::Config{osvers} =~ /^(\d+)/
        && $1 >= 10
    ) {
        $compiler = 'clang++';
        $libs = '-lc++';
    }
    else {
        my $guesser = ExtUtils::CppGuess->new;
        my %configuration = $guesser->module_build_options;
        if( $guesser->is_gcc ) {
            $compiler = 'g++';
        }
        elsif ( $guesser->is_msvc ) {
            $compiler = 'cl';
        }
 
        $compiler .= $configuration{extra_compiler_flags};
        $libs = $configuration{extra_linker_flags};
 
        ($compiler, $libs) = map {
            _trim_whitespace($_)
        } ($compiler, $libs);
    }



( run in 0.436 second using v1.01-cache-2.11-cpan-95122f20152 )