ExtUtils::CppGuess − guess C++ compiler and flags
With Extutils::MakeMaker:
use
ExtUtils::CppGuess;
my $guess = ExtUtils::CppGuess−>new;
WriteMakefile
( # MakeMaker args,
$guess−>makemaker_options,
);
With Module::Build:
my $guess =
ExtUtils::CppGuess−>new;
my $build = Module::Build−>new
( # Module::Build arguments
$guess−>module_build_options,
);
$build−>create_build_script;
"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 Module::Build constructor or to ExtUtils::MakeMaker’s "WriteMakefile" function.
new
Creates a new "ExtUtils::CppGuess" object. Takes
the path to the C compiler as the "cc" argument,
but falls back to the value of $Config{cc}, which should be
what you want anyway.
You can specify "extra_compiler_flags" and "extra_linker_flags" (as strings) which will be merged in with the auto-detected ones.
module_build_options
Returns the correct options to the constructor of
"Module::Build". These are:
extra_compiler_flags
extra_linker_flags
config => { cc => ... }, # as of 0.15
Please note the above may have problems on Perl <= 5.8 with ExtUtils::CBuilder <= 0.280230 due to a Perl RE issue.
makemaker_options
Returns the correct options to the "WriteMakefile"
function of "ExtUtils::MakeMaker". These are:
CCFLAGS
dynamic_lib => { OTHERLDFLAGS => ... }
CC # as of 0.15
If you specify the extra compiler or linker flags in the constructor, they’ll be merged into "CCFLAGS" or "OTHERLDFLAGS" respectively.
is_gcc
Returns true if the detected compiler is in the gcc
family.
is_msvc
Returns true if the detected compiler is in the MS
VC family.
is_clang
Returns true if the detected compiler is in the Clang
family.
is_sunstudio
Returns true if the detected compiler is in the Sun Studio
family.
add_extra_compiler_flags
Takes a string as argument that is added to the string of
extra compiler flags.
add_extra_linker_flags
Takes a string as argument that is added to the string of
extra linker flags.
compiler_command
Returns the string that can be passed to "system"
to execute the compiler. Will include the flags returned as
the Module::Build "extra_compiler_flags".
Added in 0.13.
linker_flags
The same as returned as the Module::Build
"extra_linker_flags".
Added in 0.13.
iostream_fname
Returns the filename to "#include" to get iostream
capability.
This can be used a bit creatively to be portable in one’s XS files, as the tests for this module need to be:
# in
Makefile.PL:
$guess−>add_extra_compiler_flags(
'−DINCLUDE_DOT=' .
($guess−>iostream_fname =~ /\./ ? 1 : 0)
);
// in your .xs file:
#if INCLUDE_DOT
#include <string.h>
#else
#include <string>
#endif
Added in 0.15.
cpp_flavor_defs
Returns the text for a header that "#define"s
"__INLINE_CPP_STANDARD_HEADERS" and
"__INLINE_CPP_NAMESPACE_STD" if the standard
headers and namespace are available. This is determined by
trying to compile C ++ with "#define
<iostream>" − if it succeeds, the symbols
will be defined, else commented.
Added in 0.15.
Mattia Barbon <mbarbon@cpan.org>
Steffen Mueller <smueller@cpan.org>
Tobias Leich <froggs@cpan.org>
Copyright 2010, 2011 by Mattia Barbon.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.