Fix uninit var warning from _inline_create_error when $args is undef
[gitmo/Moose.git] / inc / MMHelper.pm
CommitLineData
004ac8d9 1package MMHelper;
2
3use strict;
4use warnings;
5
6use Config;
7use Cwd qw( abs_path );
8use File::Basename qw( dirname );
9
6ae2c8a1 10sub ccflags_dyn {
6bf5d14d 11 my $is_dev = shift;
004ac8d9 12
6ae2c8a1 13 my $ccflags = q<( $Config::Config{ccflags} || '' ) . ' -I.'>;
14 $ccflags .= q< . ' -Wall -Wdeclaration-after-statement'>
6bf5d14d 15 if $is_dev;
004ac8d9 16
6ae2c8a1 17 return $ccflags;
18}
19
20sub ccflags_static {
21 my $is_dev = shift;
004ac8d9 22
6ae2c8a1 23 return eval(ccflags_dyn($is_dev));
24}
25
26sub mm_args {
004ac8d9 27 my ( @object, %xs );
28
6bf5d14d 29 for my $xs ( glob "xs/*.xs" ) {
004ac8d9 30 ( my $c = $xs ) =~ s/\.xs$/.c/i;
31 ( my $o = $xs ) =~ s/\.xs$/\$(OBJ_EXT)/i;
32
33 $xs{$xs} = $c;
34 push @object, $o;
35 }
36
6bf5d14d 37 for my $c ( glob "*.c" ) {
004ac8d9 38 ( my $o = $c ) =~ s/\.c$/\$(OBJ_EXT)/i;
39 push @object, $o;
40 }
41
42 return (
004ac8d9 43 clean => { FILES => join( q{ }, @object ) },
44 OBJECT => join( q{ }, @object ),
45 XS => \%xs,
46 );
47}
48
49sub my_package_subs {
50 return <<'EOP';
6bf5d14d 51{
004ac8d9 52package MY;
53
54use Config;
55
56sub const_cccmd {
57 my $ret = shift->SUPER::const_cccmd(@_);
58 return q{} unless $ret;
59
60 if ($Config{cc} =~ /^cl\b/i) {
61 warn 'you are using MSVC... my condolences.';
62 $ret .= ' /Fo$@';
63 }
64 else {
65 $ret .= ' -o $@';
66 }
67
68 return $ret;
69}
70
71sub postamble {
72 return <<'EOF';
73$(OBJECT) : mop.h
74EOF
75}
227fbc0e 76}
004ac8d9 77EOP
78}
79
801;