Move MakeMaker customizations to a module in inc that can be used for dzil and the...
[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
10sub mm_args {
11 my $root = shift;
12
13 my $ccflags = ( $Config::Config{ccflags} || '' ) . ' -I.';
14 $ccflags .= ' -Wall -Wdeclaration-after-statement';
15
16 my %mm = ( CCFLAGS => $ccflags );
17
18 my ( @object, %xs );
19
20 for my $xs ( glob "$root/xs/*.xs" ) {
21 ( my $c = $xs ) =~ s/\.xs$/.c/i;
22 ( my $o = $xs ) =~ s/\.xs$/\$(OBJ_EXT)/i;
23
24 $xs{$xs} = $c;
25 push @object, $o;
26 }
27
28 for my $c ( glob "$root/*.c" ) {
29 ( my $o = $c ) =~ s/\.c$/\$(OBJ_EXT)/i;
30 push @object, $o;
31 }
32
33 return (
34 CCFLAGS => $ccflags,
35 clean => { FILES => join( q{ }, @object ) },
36 OBJECT => join( q{ }, @object ),
37 XS => \%xs,
38 );
39}
40
41sub my_package_subs {
42 return <<'EOP';
43package MY;
44
45use Config;
46
47sub const_cccmd {
48 my $ret = shift->SUPER::const_cccmd(@_);
49 return q{} unless $ret;
50
51 if ($Config{cc} =~ /^cl\b/i) {
52 warn 'you are using MSVC... my condolences.';
53 $ret .= ' /Fo$@';
54 }
55 else {
56 $ret .= ' -o $@';
57 }
58
59 return $ret;
60}
61
62sub postamble {
63 return <<'EOF';
64$(OBJECT) : mop.h
65EOF
66}
67EOP
68}
69
701;