Commit | Line | Data |
004ac8d9 |
1 | package MMHelper; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Config; |
7 | use Cwd qw( abs_path ); |
8 | use File::Basename qw( dirname ); |
9 | |
6ae2c8a1 |
10 | sub 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 | |
20 | sub ccflags_static { |
21 | my $is_dev = shift; |
004ac8d9 |
22 | |
6ae2c8a1 |
23 | return eval(ccflags_dyn($is_dev)); |
24 | } |
25 | |
26 | sub 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 | |
49 | sub my_package_subs { |
50 | return <<'EOP'; |
6bf5d14d |
51 | { |
004ac8d9 |
52 | package MY; |
53 | |
54 | use Config; |
55 | |
093f4bba |
56 | my $message; |
57 | BEGIN { |
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 | |
69 | MESSAGE |
70 | $message =~ s/^(.*)$/\t\$(NOECHO) echo "$1";/mg; |
71 | } |
72 | |
004ac8d9 |
73 | sub 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 | |
88 | sub postamble { |
89 | return <<'EOF'; |
90 | $(OBJECT) : mop.h |
91 | EOF |
92 | } |
093f4bba |
93 | |
94 | sub install { |
95 | return <<EOF; |
96 | install: |
97 | $message |
98 | \$(NOECHO) echo "Running dzil install for you..."; |
99 | \$(NOECHO) dzil install |
100 | EOF |
101 | } |
102 | |
103 | sub dist_core { |
104 | return <<EOF; |
105 | dist: |
106 | $message |
107 | \$(NOECHO) echo "Running dzil build for you..."; |
108 | \$(NOECHO) dzil build |
109 | EOF |
6bf5d14d |
110 | } |
227fbc0e |
111 | } |
004ac8d9 |
112 | EOP |
113 | } |
114 | |
115 | 1; |