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 | ||
56 | sub 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 | ||
71 | sub postamble { | |
72 | return <<'EOF'; | |
73 | $(OBJECT) : mop.h | |
74 | EOF | |
75 | } | |
227fbc0e | 76 | } |
004ac8d9 | 77 | EOP |
78 | } | |
79 | ||
80 | 1; |