redirect 'make dist' and 'make install' to dzil
[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
093f4bba 56my $message;
57BEGIN {
58$message = <<'MESSAGE';
59
60 ********************************* ERROR ************************************
61
62 This module uses Dist::Zilla for development. This Makefile.PL will let you
63 run the tests, but should not be used for installation or building dists.
64 Building a dist should be done with 'dzil build', installation should be
65 done with 'dzil install', and releasing should be done with 'dzil release'.
66
67 ****************************************************************************
68
69MESSAGE
70$message =~ s/^(.*)$/\t\$(NOECHO) echo "$1";/mg;
71}
72
004ac8d9 73sub const_cccmd {
74 my $ret = shift->SUPER::const_cccmd(@_);
75 return q{} unless $ret;
76
77 if ($Config{cc} =~ /^cl\b/i) {
78 warn 'you are using MSVC... my condolences.';
79 $ret .= ' /Fo$@';
80 }
81 else {
82 $ret .= ' -o $@';
83 }
84
85 return $ret;
86}
87
88sub postamble {
89 return <<'EOF';
90$(OBJECT) : mop.h
91EOF
92}
093f4bba 93
94sub install {
95 return <<EOF;
96install:
97$message
98 \$(NOECHO) echo "Running dzil install for you...";
99 \$(NOECHO) dzil install
100EOF
101}
102
103sub dist_core {
104 return <<EOF;
105dist:
106$message
107 \$(NOECHO) echo "Running dzil build for you...";
108 \$(NOECHO) dzil build
109EOF
6bf5d14d 110}
004ac8d9 111EOP
112}
113
1141;