ExtUtils-CppGuess-0.23/0000755000175000017500000000000014055257035014702 5ustar osboxesosboxesExtUtils-CppGuess-0.23/META.json0000644000175000017500000000326314055257035016327 0ustar osboxesosboxes{ "abstract" : "unknown", "author" : [ "unknown" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "ExtUtils-CppGuess", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Capture::Tiny" : "0", "ExtUtils::ParseXS" : "3.35", "File::Basename" : "0", "File::Spec" : "0", "File::Temp" : "0" } }, "test" : { "requires" : { "Capture::Tiny" : "0", "Cwd" : "0", "Data::Dumper" : "0", "ExtUtils::CBuilder" : "0.280231", "ExtUtils::MakeMaker" : "0", "ExtUtils::Manifest" : "0", "Fatal" : "0", "Module::Build" : "0", "Test::More" : "0.88" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/tsee/extutils-cppguess/issues" }, "repository" : { "type" : "git", "url" : "git://github.com/tsee/extutils-cppguess", "web" : "https://github.com/tsee/extutils-cppguess" } }, "version" : "0.23", "x_serialization_backend" : "JSON::PP version 4.04" } ExtUtils-CppGuess-0.23/MANIFEST.SKIP0000644000175000017500000000256114055256640016605 0ustar osboxesosboxes\.travis\.yml #!start included /opt/perl/modules/lib/perl5/ExtUtils/MANIFEST.SKIP # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \B\.gitignore\b \b_darcs\b \B\.cvsignore$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid MYMETA files ^MYMETA\. #!end included /opt/perl/modules/lib/perl5/ExtUtils/MANIFEST.SKIP # Avoid configuration metadata file ^MYMETA\. # Avoid Module::Build generated and utility files. \bBuild$ \bBuild.bat$ \b_build \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid archives of this distribution \bExtUtils-CppGuess-[\d\.\_]+ # Ignore test byproducts CppGuessTest\.bs CppGuessTest\.c CppGuessTest\.o CppGuessTest\.obj ^t/module/lib/CppGuessTest.xs$ ^t/module/MYMETA\. ^t/module_build/ ^t/makemaker/ \.swp$ ExtUtils-CppGuess-0.23/t/0000755000175000017500000000000014055257035015145 5ustar osboxesosboxesExtUtils-CppGuess-0.23/t/011_makemaker.t0000644000175000017500000000100514055256640017645 0ustar osboxesosboxesuse strict; use Test::More; use lib 't/lib'; use TestUtils; my $separator = ( '=' x 40 . "\n" ); prepare_test( 't/module', 't/makemaker' ); my( $ok, $configure, $build, $test ) = build_makemaker( 't/makemaker' ); ok( $ok, 'build with ExtUtils::MakeMaker' ); if( !$ok ) { diag( "Makefile.PL output\n", $separator, $configure, $separator ); diag( "make output\n", $separator, $build, $separator ) if $build; diag( "make test output\n", $separator, $test, $separator ) if $test; } done_testing; ExtUtils-CppGuess-0.23/t/002_icpp.t0000644000175000017500000000545014055256640016653 0ustar osboxesosboxesuse strict; use warnings; use Data::Dumper; use Test::More; use ExtUtils::CppGuess; my @DATA = ( [ { os => 'MSWin32', cc => 'cl', config => {ccflags => ''} }, { is_sunstudio => 0, is_msvc => 1, is_gcc => 0, is_clang => 0, compiler_command => 'cl -TP -EHsc', linker_flags => 'msvcprt.lib', }, ], [ { os => 'MSWin32', cc => 'gcc', config => {ccflags => '', ldflags => ''} }, { is_sunstudio => 0, is_msvc => undef, is_gcc => 1, is_clang => 0, compiler_command => 'g++ -xc++', linker_flags => '-lstdc++', }, ], [ { os => 'MSWin32', cc => 'gcc', config => {ccflags => '', ldflags => 'static-libstdc++'} }, { is_sunstudio => 0, is_msvc => undef, is_gcc => 1, is_clang => 0, compiler_command => 'g++ -xc++', linker_flags => '', }, ], [ { os => 'freebsd', cc => 'gcc', config => {ccflags => ''}, osvers => 9 }, { is_sunstudio => 0, is_msvc => undef, is_gcc => 1, is_clang => 0, compiler_command => 'g++ -xc++', linker_flags => '-lstdc++', }, ], [ { os => 'freebsd', cc => 'gcc', config => {gccversion => 'Clang', ccflags => ''}, osvers => 10 }, { is_sunstudio => undef, is_msvc => undef, is_gcc => undef, is_clang => 1, compiler_command => 'clang++ -Wno-reserved-user-defined-literal', linker_flags => '-lc++', }, ], [ { os => 'netbsd', cc => 'gcc', config => {ccflags => ''} }, { is_sunstudio => 0, is_msvc => undef, is_gcc => 1, is_clang => 0, compiler_command => 'g++ -xc++', linker_flags => '-lstdc++ -lgcc_s', }, ], [ { os => 'linux', cc => 'clang', config => {gccversion => 'Clang', ccflags => ''} }, { is_sunstudio => 0, is_msvc => undef, is_gcc => undef, is_clang => 1, compiler_command => 'clang++ -xc++ -Wno-reserved-user-defined-literal', linker_flags => '-lstdc++', }, ], [ { os => 'linux', cc => 'gcc', config => {ccflags => ''} }, { is_sunstudio => 0, is_msvc => undef, is_gcc => 1, is_clang => 0, compiler_command => 'g++ -xc++', linker_flags => '-lstdc++', }, ], [ { os => 'linux', cc => '/opt/SUNWspro/bin/cc', config => {ccflags => ''} }, { is_sunstudio => 1, is_msvc => undef, is_gcc => undef, is_clang => undef, compiler_command => 'CC', linker_flags => '', }, ], ); my @METHODS = qw( is_msvc is_gcc is_clang is_sunstudio compiler_command linker_flags ); $Data::Dumper::Indent = $Data::Dumper::Sortkeys = $Data::Dumper::Terse = 1; run_test(@$_) for @DATA; done_testing; sub run_test { my ($args, $expect) = @_; my $guess = ExtUtils::CppGuess->new(%$args); my %got = map {$_ => $guess->$_} @METHODS; is_deeply \%got, $expect or diag Dumper [ $args, \%got, $expect ]; } ExtUtils-CppGuess-0.23/t/module/0000755000175000017500000000000014055257035016432 5ustar osboxesosboxesExtUtils-CppGuess-0.23/t/module/typemap0000644000175000017500000000026513445742660020044 0ustar osboxesosboxesstd::string T_STD_STRING INPUT T_STD_STRING $var = std::string( SvPV_nolen( $arg ), SvCUR( $arg ) ); OUTPUT T_STD_STRING $arg = newSVpvn( $var.c_str(), $var.length() ); ExtUtils-CppGuess-0.23/t/module/t/0000755000175000017500000000000014055257035016675 5ustar osboxesosboxesExtUtils-CppGuess-0.23/t/module/t/001_load.t0000644000175000017500000000010214055256640020353 0ustar osboxesosboxesuse strict; use Test::More tests => 1; use_ok( 'CppGuessTest' ); ExtUtils-CppGuess-0.23/t/module/t/002_base.t0000644000175000017500000000023714055256640020360 0ustar osboxesosboxesuse strict; use Test::More tests => 2; use CppGuessTest; is( CppGuessTest::silly_test( 4 ), 9 ); is( CppGuessTest::useless_test( "foo", "bar" ), "foobar" ); ExtUtils-CppGuess-0.23/t/module/lib/0000755000175000017500000000000014055257035017200 5ustar osboxesosboxesExtUtils-CppGuess-0.23/t/module/lib/CppGuessTest.pm0000644000175000017500000000015313445742660022133 0ustar osboxesosboxespackage CppGuessTest; our $VERSION = '0.01'; use XSLoader; XSLoader::load 'CppGuessTest', $VERSION; 1; ExtUtils-CppGuess-0.23/t/module/CppGuessTest.xs0000644000175000017500000000317414055256640021405 0ustar osboxesosboxes#ifdef _WIN32 #include #endif #if defined (__SVR4) && defined (__sun) #include #endif #if INCLUDE_DOT #include #else #include #endif typedef std::string std__string; extern "C" { #include #ifdef __clang__ # ifdef CLANG_WORKAROUND_514 /* perl.h before 5.18 or so blow up on clang with dVAR on EU::PXS >= 3.04_01 - this works around */ # undef HASATTRIBUTE_UNUSED # endif #endif #include #include #ifdef __clang__ # ifdef CLANG_WORKAROUND_516 /* perl.h before 5.18 or so blow up on clang with dVAR on EU::PXS >= 3.04_01 - this works around */ # undef dNOOP # define dNOOP /*EMPTY*/(void)0 # endif #endif #include } // Perl likes to pollute your namespace #undef bool #if defined( PERL_IMPLICIT_CONTEXT ) #undef abort #undef clearerr #undef close #undef eof #undef exit #undef fclose #undef feof #undef ferror #undef fflush #undef fgetpos #undef fopen #undef form #undef fputc #undef fputs #undef fread #undef free #undef freopen #undef fseek #undef fsetpos #undef ftell #undef fwrite #undef getc #undef getenv #undef malloc #undef open #undef read #undef realloc #undef rename #undef seekdir #undef setbuf #undef setvbuf #undef tmpfile #undef tmpnam #undef ungetc #undef vform #undef vfprintf #undef write #endif // defined( PERL_IMPLICIT_SYS ) int silly_test( int value ) { return 2 * value + 1; } std::string useless_test( const std::string& a, const std::string& b ) { return a + b; } MODULE=CppGuessTest PACKAGE=CppGuessTest PROTOTYPES: DISABLE int silly_test( int value ) std::string useless_test( std::string a, std::string b ) ExtUtils-CppGuess-0.23/t/module/Build.PL0000644000175000017500000000145714055256640017736 0ustar osboxesosboxes#!/usr/bin/perl -w use strict; use blib '../..'; use Module::Build; use ExtUtils::CppGuess; use ExtUtils::ParseXS; my $guess = ExtUtils::CppGuess->new; $guess->add_extra_compiler_flags( '-DINCLUDE_DOT=' . ($guess->iostream_fname =~ /\./ ? 1 : 0) ); # broken on 5.14, on EUPXS 3.04_01 to 3.35 if ($ExtUtils::ParseXS::VERSION > 3.04) { if ($] lt '5.016000') { $guess->add_extra_compiler_flags('-DCLANG_WORKAROUND_514'); } elsif ($] lt '5.018000') { $guess->add_extra_compiler_flags('-DCLANG_WORKAROUND_516'); } } my $build = Module::Build->new ( module_name => 'CppGuessTest', dist_abstract => 'a test module', license => 'perl', xs_files => { 'CppGuessTest.xs' => 'lib/CppGuessTest.xs' }, $guess->module_build_options, ); $build->create_build_script; ExtUtils-CppGuess-0.23/t/module/MANIFEST0000644000175000017500000000014413445742660017567 0ustar osboxesosboxesBuild.PL CppGuessTest.xs MANIFEST Makefile.PL lib/CppGuessTest.pm t/001_load.t t/002_base.t typemap ExtUtils-CppGuess-0.23/t/module/Makefile.PL0000644000175000017500000000130014055256640020377 0ustar osboxesosboxes#!/usr/bin/perl -w use strict; use blib '../..'; use ExtUtils::MakeMaker; use ExtUtils::CppGuess; use ExtUtils::ParseXS; my $guess = ExtUtils::CppGuess->new; # broken on 5.14, on EUPXS 3.04_01 to 3.35 if ($ExtUtils::ParseXS::VERSION > 3.04) { if ($] lt '5.016000') { $guess->add_extra_compiler_flags('-DCLANG_WORKAROUND_514'); } elsif ($] lt '5.018000') { $guess->add_extra_compiler_flags('-DCLANG_WORKAROUND_516'); } } $guess->add_extra_compiler_flags( '-DINCLUDE_DOT=' . ($guess->iostream_fname =~ /\./ ? 1 : 0) ); WriteMakefile ( NAME => 'CppGuessTest', VERSION_FROM => 'lib/CppGuessTest.pm', PL_FILES => {}, $guess->makemaker_options, ); ExtUtils-CppGuess-0.23/t/001_load.t0000644000175000017500000000123114055256640016627 0ustar osboxesosboxesuse strict; use warnings; use Data::Dumper; use Test::More; my $MODULE = 'ExtUtils::CppGuess'; use_ok($MODULE); my $guess = $MODULE->new; isa_ok $guess, $MODULE; $Data::Dumper::Indent = $Data::Dumper::Sortkeys = $Data::Dumper::Terse = 1; diag 'EUMM:', Dumper { $guess->makemaker_options }; diag '---'; diag 'MB:', Dumper { $guess->module_build_options }; diag '---'; my $config = $guess->_config; diag 'Config:', Dumper { map { $_=>$config->{$_} } grep /cc|ld/, keys %$config }; for (qw( is_sunstudio is_msvc is_gcc is_clang compiler_command linker_flags iostream_fname cpp_flavor_defs )) { diag "Method: $_ = ", Dumper $guess->$_; } done_testing; ExtUtils-CppGuess-0.23/t/010_module_build.t0000644000175000017500000000165714055256640020370 0ustar osboxesosboxesuse strict; use Test::More; BEGIN { plan skip_all => 'no Module::Build' if !eval { require Module::Build; 1 }; plan skip_all => 'no ExtUtils::CBuilder' if !eval { require ExtUtils::CBuilder; 1 }; plan skip_all => 'perl 5.8.8 and EU::CBuilder bug if CC has "++"' if $ExtUtils::CBuilder::VERSION <= 0.280230 and $] lt '5.010'; } use lib 't/lib'; use TestUtils; diag "Module::Build version: $Module::Build::VERSION"; diag "ExtUtils::CBuilder version: $ExtUtils::CBuilder::VERSION"; my $separator = ( '=' x 40 . "\n" ); prepare_test( 't/module', 't/module_build' ); my( $ok, $configure, $build, $test ) = build_module_build( 't/module_build' ); ok( $ok, 'build with Module::Build' ); if( !$ok ) { diag( "Build.PL output\n", $separator, $configure, $separator ); diag( "Build output\n", $separator, $build, $separator ) if $build; diag( "Build test output\n", $separator, $test, $separator ) if $test; } done_testing; ExtUtils-CppGuess-0.23/t/lib/0000755000175000017500000000000014055257035015713 5ustar osboxesosboxesExtUtils-CppGuess-0.23/t/lib/TestUtils.pm0000644000175000017500000000423314055256640020214 0ustar osboxesosboxespackage # hide TestUtils; use strict; use ExtUtils::Manifest qw(manicopy maniread); use File::Path qw(rmtree); use File::Spec::Functions qw(rel2abs); use Cwd qw(cwd); use Fatal qw(chdir); use Config qw(); use Capture::Tiny 'capture_merged'; require Exporter; *import = \&Exporter::import; our @EXPORT = qw(prepare_test build_makemaker build_module_build); sub _run_capture { my @cmd = @_; my $captured = capture_merged { system(@cmd); }; my $status = $?; return($captured, $status); } sub prepare_test { my( $source, $destination ) = @_; my $cwd = cwd(); $destination = rel2abs( $destination ); rmtree( $destination ); chdir( $source ); manicopy( maniread(), $destination ); chdir( $cwd ); } sub build_module_build { my( $path ) = @_; my $cwd = cwd(); chdir $path; my ($build_pl, $build_pl_ok) = _run_capture($^X, "Build.PL"); if( $build_pl_ok != 0 ) { chdir( $cwd ); return ( 0, $build_pl, undef, undef ); } my ($build, $build_ok) = _run_capture($^X, "Build"); if( $build_ok != 0 ) { chdir( $cwd ); return ( 0, $build_pl, $build, undef ); } my ($build_test, $build_test_ok) = _run_capture($^X, "Build", "test"); if( $build_test_ok != 0 ) { chdir( $cwd ); return ( 0, $build_pl, $build, $build_test ); } else { chdir( $cwd ); return ( 1, $build_pl, $build, $build_test ); } } sub build_makemaker { my( $path ) = @_; my $cwd = cwd(); chdir $path; my ($makefile_pl, $makefile_pl_ok) = _run_capture($^X, "Makefile.PL"); if( $makefile_pl_ok != 0 ) { chdir( $cwd ); return ( 0, $makefile_pl, undef, undef ); } my ($make, $make_ok) = _run_capture($Config::Config{make}); if( $make_ok != 0 ) { chdir( $cwd ); return ( 0, $makefile_pl, $make, undef ); } my ($make_test, $make_test_ok) = _run_capture($Config::Config{make}, "test"); if( $make_test_ok != 0 ) { chdir( $cwd ); return ( 0, $makefile_pl, $make, $make_test ); } else { chdir( $cwd ); return ( 1, $makefile_pl, $make, $make_test ); } } 1; ExtUtils-CppGuess-0.23/t/lib/TestGuess.pm0000644000175000017500000000566113445742660020214 0ustar osboxesosboxespackage TestGuess; use strict; use warnings; # This is the logic we used to keep in Makefile.PL that was used to make an # educated guess as to what compiler, compiler flags, standard libraries, and # linker flags to configure into Inline::CPP. # Inline::CPP shifted to using ExtUtils::CppGuess instead, but retains this # logic for testing purposes, as well as for working toward improving # ExtUtils::CppGuess. # my( $cc_guess, $libs_guess ) = guess_compiler(); #============================================================================ # Make an intelligent guess about what compiler to use #============================================================================ sub new { my( $class, $config ) = @_; return bless { config => $config }, $class; } sub guess_compiler { my $self = shift; my( $cc_guess, $libs_guess ); if ( $self->{config}{osname} eq 'darwin' ) { my $stdlib_query = 'find /usr/lib/gcc -name "libstdc++*" | grep $( uname -p )'; my $stdcpp = `$stdlib_query`; +$stdcpp =~ s/^(.*)\/[^\/]+$/$1/; $cc_guess = 'g++'; $libs_guess = "-L$stdcpp -lstdc++"; } elsif ( $self->{config}{osname} ne 'darwin' and $self->{config}{gccversion} and $self->{config}{cc} =~ m#\bgcc\b[^/]*$# ) { ( $cc_guess = $self->{config}{cc} ) =~ s[\bgcc\b([^/]*)$(?:)][g\+\+$1]; $libs_guess = '-lstdc++'; } elsif ( $self->{config}{osname} =~ m/^MSWin/ ) { $cc_guess = 'cl -TP -EHsc'; $libs_guess = 'MSVCIRT.LIB'; } elsif ( $self->{config}{osname} eq 'linux' ) { $cc_guess = 'g++'; $libs_guess = '-lstdc++'; } # Dragonfly patch is just a hunch... (still doesn't work) elsif ( $self->{config}{osname} eq 'netbsd' || $self->{config}{osname} eq 'dragonfly' ) { $cc_guess = 'g++'; $libs_guess = '-lstdc++ -lgcc_s'; } elsif ( $self->{config}{osname} eq 'cygwin' ) { $cc_guess = 'g++'; $libs_guess = '-lstdc++'; } elsif ( $self->{config}{osname} eq 'solaris' || $self->{config}{osname} eq 'SunOS' ) { if ( $self->{config}{cc} eq 'gcc' || ( exists( $self->{config}{gccversion} ) && $self->{config}{gccversion} > 0 ) ) { $cc_guess = 'g++'; $libs_guess = '-lstdc++'; } else { $cc_guess = 'CC'; $libs_guess = '-lCrun'; } } # MirBSD: Still problematic. elsif ( $self->{config}{osname} eq 'mirbsd' ) { my $stdlib_query = 'find /usr/lib/gcc -name "libstdc++*" | grep $( uname -p ) | head -1'; my $stdcpp = `$stdlib_query`; +$stdcpp =~ s/^(.*)\/[^\/]+$/$1/; $cc_guess = 'g++'; $libs_guess = "-L$stdcpp -lstdc++ -lc -lgcc_s"; } elsif( $self->{config}{osname} eq 'freebsd' and $self->{config}{osvers} =~ /^(\d+)/ and $1 >= 10 ){ $cc_guess = 'clang++'; $libs_guess = '-lc++'; } # Sane defaults for other (probably unix-like) operating systems else { $cc_guess = 'g++'; $libs_guess = '-lstdc++'; } return( $cc_guess, $libs_guess ); } 1; ExtUtils-CppGuess-0.23/t/lib/Guess.pm0000644000175000017500000000175413445742660017353 0ustar osboxesosboxespackage Guess; use strict; use warnings; BEGIN{ use Config; } use ExtUtils::CppGuess; # Repackage results from ExtUtils::CppGuess into a form that is most useful # to Inline::CPP's Makefile.PL. sub new { my( $class, $config ) = @_; return bless { config => $config }, $class; } sub guess_compiler { my $self = shift; local %Config::Config = %{$self->{config}}; # Use our own configuration. my( $cc_guess, $libs_guess, $guesser, %configuration ); $guesser = ExtUtils::CppGuess->new; %configuration = $guesser->module_build_options; if( $guesser->is_gcc ) { $cc_guess = 'g++'; } elsif ( $guesser->is_msvc ) { $cc_guess = 'cl'; } $cc_guess .= $configuration{extra_compiler_flags}; $libs_guess = $configuration{extra_linker_flags}; ( $cc_guess, $libs_guess ) = map { _trim_whitespace($_) } ( $cc_guess, $libs_guess ); return ( $cc_guess, $libs_guess ); } sub _trim_whitespace { my $string = shift; $string =~ s/^\s+|\s+$//g; return $string; } 1; ExtUtils-CppGuess-0.23/t/003_standard_flag.t0000644000175000017500000000227314055256640020512 0ustar osboxesosboxesuse strict; use warnings; use Test::More; use ExtUtils::CppGuess; my $guess = ExtUtils::CppGuess->new; plan skip_all => "Test currently only supports GCC and Clang" unless $guess->is_gcc || $guess->is_clang; subtest "Test argument C++11" => sub { my $flag = eval { $guess->cpp_standard_flag('C++11'); }; if( $@ =~ /does not support any flags for standard/ ) { plan skip_all => "Skipping: $@"; } like $flag, qr/\Q-std=c++\E(11|0x)/, 'correct flag'; }; subtest "Test non-C++ standard" => sub { my $flag = eval { # The flag `-std=c11` is a valid compiler flag, # but not for C++. $guess->cpp_standard_flag('C11'); }; ok $@ =~ /Unknown standard/, 'C11 is not a C++ standard'; }; subtest "Test compiler failure to support known version" => sub { # NOTE Monkey-patching data here. local $ExtUtils::CppGuess::CPP_STANDARD_FLAGS; for my $compiler ( qw(is_gcc is_clang) ) { $ExtUtils::CppGuess::CPP_STANDARD_FLAGS ->{$compiler}{'C++unreal'} = [ '-std=c++unreal' ]; } my $flag = eval { # This will try to use the fake C++unreal flag, but fail. $guess->cpp_standard_flag('C++unreal'); }; ok $@ =~ /does not support/, 'Fake version is not supported by compiler'; }; done_testing; ExtUtils-CppGuess-0.23/t/00-report-prereqs.t0000644000175000017500000001350614055256640020547 0ustar osboxesosboxes#!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.020 # THEN modified with more info by Ed J for PDL project use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec; # from $version::LAX my $lax_version_re = qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | (?:\.[0-9]+) (?:_[0-9]+)? ) | (?: v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? ) )/x; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _max { my $max = shift; $max = ( $_ > $max ) ? $_ : $max for @_; return $max; } sub _merge_prereqs { my ($collector, $prereqs) = @_; # CPAN::Meta::Prereqs object if (ref $collector eq $cpan_meta_pre) { return $collector->with_merged_prereqs( CPAN::Meta::Prereqs->new( $prereqs ) ); } # Raw hashrefs for my $phase ( keys %$prereqs ) { for my $type ( keys %{ $prereqs->{$phase} } ) { for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; } } } return $collector; } my @include = qw( ); my @exclude = qw( ); # Add static prereqs to the included modules list my $static_prereqs = do 't/00-report-prereqs.dd'; # Merge all prereqs (either with ::Prereqs or a hashref) my $full_prereqs = _merge_prereqs( ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), $static_prereqs ); # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; if ( $source && $HAS_CPAN_META ) { if ( my $meta = eval { CPAN::Meta->load_file($source) } ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } } else { $source = 'static metadata'; } my @full_reports; my @dep_errors; my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; # Add static includes into a fake section for my $mod (@include) { $req_hash->{other}{modules}{$mod} = 0; } for my $phase ( qw(configure build test runtime develop other) ) { next unless $req_hash->{$phase}; next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); for my $type ( qw(requires recommends suggests conflicts modules) ) { next unless $req_hash->{$phase}{$type}; my $title = ucfirst($phase).' '.ucfirst($type); my @reports = [qw/Module Want Have Where Howbig/]; for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { next if $mod eq 'perl'; next if grep { $_ eq $mod } @exclude; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; if ($prefix) { my $filename = File::Spec->catfile($prefix, $file); my $have = MM->parse_version( $filename ); $have = "undef" unless defined $have; push @reports, [$mod, $want, $have, $prefix, (-s $filename)]; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { if ( $have !~ /\A$lax_version_re\z/ ) { push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; } elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { push @dep_errors, "$mod version '$have' is not in required range '$want'"; } } } else { push @reports, [$mod, $want, "missing", '', 0]; if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { push @dep_errors, "$mod is not installed ($req_string)"; } } } if ( @reports ) { push @full_reports, "=== $title ===\n\n"; my $ml = _max( map { length $_->[0] } @reports ); my $wl = _max( map { length $_->[1] } @reports ); my $hl = _max( map { length $_->[2] } @reports ); my $ll = _max( map { length $_->[3] } @reports ); # location my $sl = _max( map { length $_->[4] } @reports ); # size if ($type eq 'modules') { splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl, "-" x $ll, "-" x $sl]; push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; } else { splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl, "-" x $ll, "-" x $sl]; push @full_reports, map { sprintf(" %*s %*s %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2], -$ll, $_->[3], $sl, $_->[4]) } @reports; } push @full_reports, "\n"; } } } if ( @full_reports ) { diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( @dep_errors ) { diag join("\n", "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n", "The following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass; # vim: ts=4 sts=4 sw=4 et: ExtUtils-CppGuess-0.23/META.yml0000644000175000017500000000157614055257035016164 0ustar osboxesosboxes--- abstract: unknown author: - unknown build_requires: Capture::Tiny: '0' Cwd: '0' Data::Dumper: '0' ExtUtils::CBuilder: '0.280231' ExtUtils::MakeMaker: '0' ExtUtils::Manifest: '0' Fatal: '0' Module::Build: '0' Test::More: '0.88' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: ExtUtils-CppGuess no_index: directory: - t - inc requires: Capture::Tiny: '0' ExtUtils::ParseXS: '3.35' File::Basename: '0' File::Spec: '0' File::Temp: '0' resources: bugtracker: https://github.com/tsee/extutils-cppguess/issues repository: git://github.com/tsee/extutils-cppguess version: '0.23' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' ExtUtils-CppGuess-0.23/Changes0000644000175000017500000000513314055256770016204 0ustar osboxesosboxes0.23 2021-05-31 - added CI - thanks @zmughal - now recognises MacOS clang - thanks @xenu 0.22 2021-05-29 - Add C++ standard support flag detection - thanks @zmughal! See . 0.21 2020-01-23 - no give $Config{ccflags} in Module::Build as add not replace - thanks @xenu 0.20 Sat 31 Aug 22:20:32 BST 2019 - no link -lstdc++ if -static-libstdc++ - thanks @andygrundman 0.19 Mon 1 Apr 07:08:46 BST 2019 - support clang on Perl 5.14-16 with ExtUtils::ParseXS >= 3.04_01 (yes, really) 0.18 Sun 31 Mar 17:49:21 BST 2019 - improve clang detection 0.17 Sat 30 Mar 16:03:52 GMT 2019 - support Sun Studio compiler family 0.16 Sat 30 Mar 00:09:42 GMT 2019 - test output more if no clue about compiler 0.15 Fri 29 Mar 22:42:00 GMT 2019 - iostream_fname, cpp_flavor_defs methods - add which actual compiler to use to generated MB and EUMM flags - make the test sensitive to whether to #include with a ".h" 0.14 Mon 25 Mar 21:13:36 GMT 2019 - add is_clang, unify OS-based detection 0.13 Mon Mar 25 02:57:02 2019 +0000 - repo tidied slightly - use Travis - add compiler_command, linker_flags - test all known configurations - inhale knowledge from Inline::CPP 0.12 Sat Oct 21 18:12:51 BST 2017 - Fix tests on 5.26 without '.' in @INC (kentfredric) 0.11 Thu Sep 10 13:12:17 MDT 2015 - Add leading whitespace to $cflags in _get_cflags (bulk88) 0.10 Tue Sep 08 21:15:30 MDT 2015 - Config's ccflags must always be used. (bulk88) 0.09 Sat Apr 11 16:05:50 BST 2015 - Convert to EUMM - Make tests divulge guessed options for better debugging 0.08 Thu Jan 15 03:07:38 GMT 2015 - Update metadata 0.07 Thu Jul 7 17:00:00 CEST 2011 - Fix for unknown enum `vtype' on solaris 2.11 (Tobias Leich) See http://www.cpantesters.org/cpan/report/a0cca9ee-39e3-11e0-83a5-34754e7aadc9 - NetBSD fix for: Undefined PLT symbol _Unwind_Resume (Tobias Leich) 0.06 Sun Jun 5 21:00:00 CEST 2011 - Fix for -D_FILE_OFFSET_BITS (Tobias Leich) See http://www.cpantesters.org/cpan/report/b6e29992-894c-11e0-b6b1-f9d75287cfae 0.05 Tue Feb 15 23:00:00 CEST 2010 - Fix test failures on win32 (Shmuel Fomberg) 0.04 Mon Jul 12 18:00:00 CEST 2010 - Fix problem with duplicate extra-linker/compiler options 0.03 Thu Jul 1 18:00:00 CEST 2010 - Fix tests to use the current perl - Make tests use Capture::Tiny - Very explicit dependencies in Build.PL 0.02 Mon Jun 28 20:00:00 CEST 2010 - Just removed debugging code. 0.01 Mon Jun 28 20:00:00 CEST 2010 - First release. ExtUtils-CppGuess-0.23/lib/0000755000175000017500000000000014055257035015450 5ustar osboxesosboxesExtUtils-CppGuess-0.23/lib/ExtUtils/0000755000175000017500000000000014055257035017231 5ustar osboxesosboxesExtUtils-CppGuess-0.23/lib/ExtUtils/CppGuess.pm0000644000175000017500000003707114055256665021340 0ustar osboxesosboxespackage ExtUtils::CppGuess; use strict; use warnings; =head1 NAME ExtUtils::CppGuess - guess C++ compiler and flags =head1 SYNOPSIS With L: use ExtUtils::CppGuess; my $guess = ExtUtils::CppGuess->new; WriteMakefile ( # MakeMaker args, $guess->makemaker_options, ); With L: my $guess = ExtUtils::CppGuess->new; my $build = Module::Build->new ( # Module::Build arguments $guess->module_build_options, ); $build->create_build_script; =head1 DESCRIPTION C 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 constructor or to L's C function. =head1 METHODS =head2 new Creates a new C object. Takes the path to the C compiler as the C argument, but falls back to the value of C<$Config{cc}>, which should be what you want anyway. You can specify C and C (as strings) which will be merged in with the auto-detected ones. =head2 module_build_options Returns the correct options to the constructor of C. 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 L <= 0.280230 due to a Perl RE issue. =head2 makemaker_options Returns the correct options to the C function of C. 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 C or C respectively. =head2 is_gcc Returns true if the detected compiler is in the gcc family. =head2 is_msvc Returns true if the detected compiler is in the MS VC family. =head2 is_clang Returns true if the detected compiler is in the Clang family. =head2 is_sunstudio Returns true if the detected compiler is in the Sun Studio family. =head2 add_extra_compiler_flags Takes a string as argument that is added to the string of extra compiler flags. =head2 add_extra_linker_flags Takes a string as argument that is added to the string of extra linker flags. =head2 compiler_command Returns the string that can be passed to C to execute the compiler. Will include the flags returned as the Module::Build C. Added in 0.13. =head2 linker_flags The same as returned as the Module::Build C. Added in 0.13. =head2 iostream_fname Returns the filename to C<#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 #else #include #endif Added in 0.15. =head2 cpp_flavor_defs Returns the text for a header that C<#define>s C<__INLINE_CPP_STANDARD_HEADERS> and C<__INLINE_CPP_NAMESPACE_STD> if the standard headers and namespace are available. This is determined by trying to compile C++ with C<< #define >> - if it succeeds, the symbols will be defined, else commented. Added in 0.15. =head2 cpp_standard_flag $guess->cpp_standard_flag( $standard_name ) Given a string C<$standard_name> that is currently one of =over =item * C<< C++98 >> =item * C<< C++11 >> =item * C<< C++14 >> =item * C<< C++17 >> =back returns a string with a flag that can be used to tell the compiler to support that version of the C++ standard or dies if version is not supported. Added in version v0.22. =head1 AUTHOR Mattia Barbon Steffen Mueller Tobias Leich =head1 COPYRIGHT AND LICENSE 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. =cut use Config (); use File::Basename qw(); use Capture::Tiny 'capture_merged'; use File::Spec::Functions qw(catfile); use File::Temp qw(tempdir); our $VERSION = '0.23'; sub new { my( $class, %args ) = @_; my $self = bless { %args }, $class; # Allow override of default %Config::Config; useful in testing. if( ! exists $self->{config} || ! defined $self->{config} ) { if ($ExtUtils::MakeMaker::Config::VERSION) { # tricksy hobbitses are overriding Config, go with it $self->{config} = \%ExtUtils::MakeMaker::Config::Config; } else { $self->{config} = \%Config::Config; } } # Allow a 'cc' %args. If not supplied, pull from {config}, or $Config{cc}. if( ! exists $self->{cc} || ! defined $self->{cc} ) { $self->{cc} = exists $self->{config}{cc} && defined $self->{config}{cc} ? $self->{config}{cc} : $Config::Config{cc}; } # Set up osname. if( ! exists $self->{os} || ! defined $self->{os} ) { $self->{os} = exists $self->{config}{osname} && defined $self->{config}{osname} ? $self->{config}{osname} : $^O; } # Set up osvers. if( ! exists $self->{osvers} || ! defined $self->{osvers} ) { $self->{osvers} = exists $self->{config}{osvers} && defined $self->{config}{osvers} ? $self->{config}{osvers} : ''; } return $self; } # Thus saith the law: All references to %Config::Config shall come through # $self->_config. Accessors shall provide access to key components thereof. # Testing shall thus grow stronger, verifying performance for platforms diverse # to which access we have not. sub _config { shift->{config} } sub _cc { shift->{cc} } sub _os { shift->{os} } sub _osvers { shift->{osvers} } # This is IBM's "how to compile on" list with lots of compilers: # https://www.ibm.com/support/knowledgecenter/en/SS4PJT_5.2.0/com.ibm.help.cd52.unix.doc/com.ibm.help.cdunix_user.doc/CDU_Compiling_Custom_Programs.html sub guess_compiler { my $self = shift; return $self->{guess} if $self->{guess}; my $c_compiler = $self->_cc; # $c_compiler = $Config::Config{cc} if not defined $c_compiler; my %guess; if ($self->{os} eq 'freebsd' && $self->{osvers} =~ /^(\d+)/ && $1 >= 10) { $self->{is_clang} = 1; # special-case override %guess = ( compiler_command => 'clang++', extra_lflags => '-lc++', ); } elsif( $self->_cc_is_sunstudio( $c_compiler ) ) { %guess = ( compiler_command => 'CC', extra_cflags => '', extra_lflags => '', ); } elsif( $self->_cc_is_clang( $c_compiler ) ) { %guess = ( compiler_command => 'clang++', extra_cflags => '-xc++', extra_lflags => '-lstdc++', ); } elsif( $self->_cc_is_gcc( $c_compiler ) ) { %guess = ( compiler_command => 'g++', extra_cflags => '-xc++', ); # Don't use -lstdc++ if Perl was linked with -static-libstdc++ (ActivePerl 5.18+ on Windows) $guess{extra_lflags} = '-lstdc++' unless ($self->_config->{ldflags} || '') =~ /static-libstdc\+\+/; } elsif ( $self->_cc_is_msvc( $c_compiler ) ) { %guess = ( compiler_command => 'cl', extra_cflags => '-TP -EHsc', extra_lflags => 'msvcprt.lib', ); } else { my $v1 = `$c_compiler -v`; my $v2 = `$c_compiler -V`; my $v3 = `$c_compiler --version`; my $os = $self->_os; die <_os eq 'netbsd' and $guess{compiler_command} =~ /g\+\+/i and $guess{extra_lflags} !~ /-lgcc_s/; $self->{guess} = \%guess; } sub _get_cflags { my ($self, $omit_ccflags) = @_; $self->guess_compiler or die; join ' ', '', map _trim_whitespace($_), grep defined && length, ($omit_ccflags ? '' : $self->_config->{ccflags}), $self->{guess}{extra_cflags}, $self->{extra_compiler_flags}, ($self->is_clang ? '-Wno-reserved-user-defined-literal' : ()), ; } sub _get_lflags { my $self = shift; $self->guess_compiler || die; join ' ', '', map _trim_whitespace($_), grep defined && length, $self->{guess}{extra_lflags}, $self->{extra_linker_flags}, ; } sub makemaker_options { my $self = shift; my $lflags = $self->_get_lflags; my $cflags = $self->_get_cflags; return ( CCFLAGS => $cflags, dynamic_lib => { OTHERLDFLAGS => $lflags }, CC => $self->{guess}{compiler_command}, ); } sub module_build_options { my $self = shift; my $lflags = $self->_get_lflags; # We're omitting ccflags to avoid duplication of flags, because unlike # makemaker, we're appending to the compiler flags, not overriding # them. They already contain $Config{ccflags}. my $cflags = $self->_get_cflags(1); return ( extra_compiler_flags => $cflags, extra_linker_flags => $lflags, config => { cc => $self->{guess}{compiler_command} }, ); } # originally from Alien::wxWidgets::Utility # Why was this hanging around outside of all functions, and without any other # use of $quotes? # my $quotes = $self->_os =~ /MSWin32/ ? '"' : "'"; sub _capture { my @cmd = @_; my $out = capture_merged { system(@cmd) }; $out = '' if not defined $out; return $out; } # capture the output of a command that is run with piping # to stdin of the command. We immediately close the pipe. sub _capture_empty_stdin { my $cmd = shift; my $out = capture_merged { if ( open my $fh, '|-', $cmd ) { close $fh; } }; $out = '' if not defined $out; return $out; } sub _cc_is_msvc { my( $self, $cc ) = @_; $self->{is_msvc} = ($self->_os =~ /MSWin32/ and File::Basename::basename($cc) =~ /^cl/i); return $self->{is_msvc}; } sub _cc_is_gcc { my( $self, $cc ) = @_; $self->{is_gcc} = 0; my $cc_version = _capture( "$cc --version" ); if ( $cc_version =~ m/\bg(?:cc|\+\+)/i # 3.x, some 4.x || scalar( _capture( "$cc" ) =~ m/\bgcc\b/i ) # 2.95 || scalar(_capture_empty_stdin("$cc -dM -E -") =~ /__GNUC__/) # more or less universal? || scalar($cc_version =~ m/\bcc\b.*Free Software Foundation/si) # some 4.x? || $cc eq 'gcc' # because why would they lie? ) { $self->{is_gcc} = 1; } return $self->{is_gcc}; } sub _cc_is_clang { my( $self, $cc ) = @_; $self->{is_clang} = 0; my $cc_version = _capture( "$cc --version" ); if ( $cc_version =~ m/\A(?:clang|apple llvm)/i || $cc eq 'clang' # because why would they lie? || (($self->_config->{gccversion} || '') =~ /Clang|Apple LLVM/), ) { $self->{is_clang} = 1; } return $self->{is_clang}; } sub _cc_is_sunstudio { my( $self, $cc ) = @_; $self->{is_sunstudio} = 0; my $cc_version = _capture( "$cc -V" ); if ( $cc_version =~ m/Sun C/i || $cc =~ /SUNWspro/ # because why would they lie? ) { $self->{is_sunstudio} = 1; } return $self->{is_sunstudio}; } sub is_gcc { my $self = shift; $self->guess_compiler || die; return $self->{is_gcc}; } sub is_msvc { my $self = shift; $self->guess_compiler || die; return $self->{is_msvc}; } sub is_clang { my $self = shift; $self->guess_compiler || die; return $self->{is_clang}; } sub is_sunstudio { my $self = shift; $self->guess_compiler || die; return $self->{is_sunstudio}; } sub add_extra_compiler_flags { my( $self, $string ) = @_; $self->{extra_compiler_flags} = join ' ', map _trim_whitespace($_), grep defined && length, $self->{extra_compiler_flags}, $string; } sub add_extra_linker_flags { my( $self, $string ) = @_; $self->{extra_linker_flags} = join ' ', map _trim_whitespace($_), grep defined && length, $self->{extra_linker_flags}, $string; } sub compiler_command { my( $self ) = @_; $self->guess_compiler || die; my $cc = $self->{guess}{compiler_command}; my $cflags = $self->_get_cflags; join ' ', map _trim_whitespace($_), grep defined && length, $cc, $cflags; } sub _trim_whitespace { my $string = shift; $string =~ s/^\s+|\s+$//g; return $string; } sub linker_flags { my( $self ) = @_; _trim_whitespace($self->_get_lflags); } sub _to_file { my ($file, @data) = @_; open my $fh, '>', $file or die "open $file: $!\n"; print $fh @data or die "write $file: $!\n"; close $fh or die "close $file: $!\n"; } my $test_cpp_filename = 'ilcpptest'; # '.cpp' appended via open. my $test_cpp = <<'END_TEST_CPP'; #include int main(){ return 0; } END_TEST_CPP # Compile the given code and returns true on success. # # Can optionally be given compiler flags. sub _can_compile_code { my( $self, $cpp_code, $compiler_flags ) = @_; my $dir = tempdir( CLEANUP => 1 ); my $file = catfile( $dir, qq{$test_cpp_filename.cpp} ); my $exe = catfile( $dir, qq{$test_cpp_filename.exe} ); _to_file $file, $cpp_code; my $command = join ' ', $self->compiler_command, @{ defined $compiler_flags ? $compiler_flags : [] }, ($self->is_msvc ? qq{-Fe:} : qq{-o }) . $exe, $file, ; return 0 == system $command; } # returns true if compile succeeded, false if failed sub _compile_no_h { my( $self ) = @_; return $self->{no_h_status} if defined $self->{no_h_status}; $self->guess_compiler || die; $self->{no_h_status} = $self->_can_compile_code( $test_cpp ); } sub iostream_fname { my( $self ) = @_; 'iostream' . ($self->_compile_no_h ? '' : '.h'); } sub cpp_flavor_defs { my( $self ) = @_; my $comment = ($self->_compile_no_h ? '' : '//'); sprintf <<'END_FLAVOR_DEFINITIONS', $comment, $comment; %s#define __INLINE_CPP_STANDARD_HEADERS 1 %s#define __INLINE_CPP_NAMESPACE_STD 1 END_FLAVOR_DEFINITIONS } # Listed in order by year. our @CPP_STANDARDS = ( 'C++98', 'C++11', 'C++14', 'C++17', ); # Hash of flags for each compiler: # # Structure # Hash: # - key: # - value: # Hash: # - key: # - value: # ArrayRef[Str] # our $CPP_STANDARD_FLAGS = { is_gcc => { 'C++98' => [ "-std=c++98" ], 'C++11' => [ "-std=c++11", "-std=c++0x" ], 'C++14' => [ "-std=c++14", "-std=c++1y" ], 'C++17' => [ "-std=c++17", "-std=c++1z" ], }, is_clang => { 'C++98' => [ "-std=c++98", ], 'C++11' => [ "-std=c++11", ], 'C++14' => [ "-std=c++14", "-std=c++1y" ], 'C++17' => [ "-std=c++17", "-std=c++1z" ], }, is_msvc => { # Newer MSVC set C++14 as minimum version. 'C++98' => [ "" ], 'C++11' => [ "" ], 'C++14' => [ "-std:c++14" ], 'C++17' => [ "-std:c++17" ], }, is_sunstudio => { 'C++98' => [ "" ], 'C++11' => [ "-std=c++11", "-std=c++0x" ], 'C++14' => [ "-std=c++14" ], # No mention of C++17 for Oracle Developer Studio 12.6. }, }; sub cpp_standard_flag { my ($self, $standard_name) = @_; $self->guess_compiler || die; my ($detected_compiler) = grep { $self->{$_} } keys %$CPP_STANDARD_FLAGS; die "Unknown standard '$standard_name' for compiler '$detected_compiler'" unless exists $CPP_STANDARD_FLAGS->{$detected_compiler}{$standard_name}; my $test_flags = $CPP_STANDARD_FLAGS->{$detected_compiler}{$standard_name}; for my $flag (@$test_flags) { return $flag if $self->_can_compile_code( <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; DESCRIPTION "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. METHODS 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 makemaker_options Returns the correct options to the "WriteMakefile" function of "ExtUtils::MakeMaker". These are: CCFLAGS dynamic_lib => { OTHERLDFLAGS => ... } 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. 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. AUTHOR Mattia Barbon Steffen Mueller Tobias Leich COPYRIGHT AND LICENSE 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. ExtUtils-CppGuess-0.23/MANIFEST0000644000175000017500000000112614055257035016033 0ustar osboxesosboxesChanges lib/ExtUtils/CppGuess.pm Makefile.PL MANIFEST This list of files MANIFEST.SKIP README t/00-report-prereqs.t t/001_load.t t/002_icpp.t t/003_standard_flag.t t/010_module_build.t t/011_makemaker.t t/lib/Guess.pm t/lib/TestGuess.pm t/lib/TestUtils.pm t/module/Build.PL t/module/CppGuessTest.xs t/module/lib/CppGuessTest.pm t/module/Makefile.PL t/module/MANIFEST t/module/t/001_load.t t/module/t/002_base.t t/module/typemap META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) ExtUtils-CppGuess-0.23/Makefile.PL0000644000175000017500000000214314055256640016655 0ustar osboxesosboxes#!/usr/bin/perl -w use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'ExtUtils::CppGuess', VERSION_FROM => 'lib/ExtUtils/CppGuess.pm', LICENSE => 'perl', PREREQ_PM => { 'Capture::Tiny' => '0', 'File::Basename' => '0', 'File::Spec' => '0', 'File::Temp' => '0', 'ExtUtils::ParseXS' => '3.35', }, TEST_REQUIRES => { 'Capture::Tiny' => '0', 'Module::Build' => '0', 'ExtUtils::CBuilder' => '0.280231', 'ExtUtils::MakeMaker' => '0', 'Test::More' => '0.88', 'ExtUtils::Manifest' => '0', 'Fatal' => '0', 'Cwd' => '0', 'Data::Dumper' => 0, }, clean => { FILES => 't/module_build t/makemaker' }, META_MERGE => { "meta-spec" => { version => 2 }, resources => { bugtracker => { web => 'https://github.com/tsee/extutils-cppguess/issues' }, repository => { type => 'git', url => 'git://github.com/tsee/extutils-cppguess', web => 'https://github.com/tsee/extutils-cppguess', }, }, }, );