s/Build/Makefile/
[gitmo/Moose.git] / Makefile.PL
1 use strict;
2 use warnings;
3
4 use Config;
5 use ExtUtils::MakeMaker;
6
7 warn <<'EOF';
8
9   ********************************* WARNING **********************************
10
11   This module uses Dist::Zilla for development. This Makefile.PL will let you
12   run the tests, but you are encouraged to install Dist::Zilla and the needed
13   plugins if you intend on doing any serious hacking.
14
15   ****************************************************************************
16
17 EOF
18
19 my $ccflags = ( $Config::Config{ccflags} || '' ) . ' -I.';
20 $ccflags .= ' -Wall -Wdeclaration-after-statement';
21
22 my %mm = ( CCFLAGS => $ccflags );
23
24 {
25     my (@OBJECT, %XS);
26
27     for my $xs (<xs/*.xs>) {
28         (my $c = $xs) =~ s/\.xs$/.c/i;
29         (my $o = $xs) =~ s/\.xs$/\$(OBJ_EXT)/i;
30
31         $XS{$xs} = $c;
32         push @OBJECT, $o;
33     }
34
35     for my $c (<*.c>) {
36         (my $o = $c) =~ s/\.c$/\$(OBJ_EXT)/i;
37         push @OBJECT, $o;
38     }
39
40     %mm = (
41         %mm,
42         clean => { FILES => join( q{ }, @OBJECT ) },
43         OBJECT => join( q{ }, @OBJECT ),
44         XS     => \%XS,
45     );
46 }
47
48 WriteMakefile(
49     NAME => 'Moose',
50     %mm,
51 );
52
53 package MY;
54
55 use Config;
56
57 sub const_cccmd {
58     my $ret = shift->SUPER::const_cccmd(@_);
59     return q{} unless $ret;
60
61     if ($Config{cc} =~ /^cl\b/i) {
62         warn 'you are using MSVC... my condolences.';
63         $ret .= ' /Fo$@';
64     }
65     else {
66         $ret .= ' -o $@';
67     }
68
69     return $ret;
70 }
71
72 sub postamble {
73     return <<'EOF';
74 $(OBJECT) : mop.h
75 EOF
76 }