From: Jesse Luehrs Date: Mon, 3 Jan 2011 22:57:54 +0000 (-0600) Subject: generate CCFLAGS correctly X-Git-Tag: 1.9902~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6ae2c8a1ea8e51322d8a623a1b621fded29f254a;p=gitmo%2FMoose.git generate CCFLAGS correctly --- diff --git a/Makefile.PL b/Makefile.PL index 6eb0b0f..0a7006b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -28,5 +28,6 @@ eval MMHelper::my_package_subs(); WriteMakefile( NAME => 'Moose', test => { TESTS => 't/*.t t/*/*.t' }, - MMHelper::mm_args('dev'), + CCFLAGS => MMHelper::ccflags_static('dev'), + MMHelper::mm_args(), ); diff --git a/inc/MMHelper.pm b/inc/MMHelper.pm index a63cd59..02bf893 100644 --- a/inc/MMHelper.pm +++ b/inc/MMHelper.pm @@ -7,15 +7,23 @@ use Config; use Cwd qw( abs_path ); use File::Basename qw( dirname ); -sub mm_args { +sub ccflags_dyn { my $is_dev = shift; - my $ccflags = ( $Config::Config{ccflags} || '' ) . ' -I.'; - $ccflags .= ' -Wall -Wdeclaration-after-statement' + my $ccflags = q<( $Config::Config{ccflags} || '' ) . ' -I.'>; + $ccflags .= q< . ' -Wall -Wdeclaration-after-statement'> if $is_dev; - my %mm = ( CCFLAGS => $ccflags ); + return $ccflags; +} + +sub ccflags_static { + my $is_dev = shift; + return eval(ccflags_dyn($is_dev)); +} + +sub mm_args { my ( @object, %xs ); for my $xs ( glob "xs/*.xs" ) { @@ -32,7 +40,6 @@ sub mm_args { } return ( - CCFLAGS => $ccflags, clean => { FILES => join( q{ }, @object ) }, OBJECT => join( q{ }, @object ), XS => \%xs, diff --git a/inc/MakeMaker.pm b/inc/MakeMaker.pm index 4c5f55d..5263fd3 100644 --- a/inc/MakeMaker.pm +++ b/inc/MakeMaker.pm @@ -13,6 +13,9 @@ override _build_MakeFile_PL_template => sub { my $tmpl = super(); + my $ccflags = MMHelper::ccflags_dyn(); + $tmpl =~ s/^(WriteMakefile\()/\$WriteMakefileArgs{CCFLAGS} = $ccflags;\n\n$1/m; + return $tmpl . "\n\n" . MMHelper::my_package_subs(); };