-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.PL
132 lines (106 loc) · 3.61 KB
/
Makefile.PL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
use 5.006002;
use strict;
use warnings;
$^O eq 'darwin'
or die "OS unsupported\n";
use lib qw{ inc };
use Config;
use ExtUtils::MakeMaker;
use Getopt::Std;
use My::Module::Meta;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
my %opt;
getopts ('nptuy', \%opt) or die <<'EOD';
The only legal options are
-n = answer all questions 'no';
-p = use pbl back end (old implementation);
-t = use traditional Mac default text flavor;
-u = use UTF-8 as default text flavor;
-y = answer all questions 'yes'.
You may not assert both -n and -y, nor both -t and -u.
The default text flavor is UTF-8 for macOS 10.14 Mojave and later, and
traditional for 10.13 High Sierra and earlier.
EOD
my $meta = My::Module::Meta->new();
my @exe_files;
my @clean_files;
$meta->want_pbtool( \%opt )
and push @exe_files, 'script/pbtool';
(my $mmv = ExtUtils::MakeMaker->VERSION) =~ s/_//g;
my @ccflags = $meta->ccflags( \%opt );
my %args = (
ABSTRACT => $meta->abstract(),
AUTHOR => $meta->author(),
C => $opt{p} ?
[ qw{ Pasteboard.c pbl.c } ] :
[ qw{ Pasteboard.c } ],
(@ccflags ? (CCFLAGS => join ' ', @ccflags, $Config{ccflags}) : ()),
DISTNAME => $meta->dist_name(),
EXE_FILES => \@exe_files,
INC => '-I.', # e.g., '-I. -I/usr/include/other'
LDDLFLAGS => $Config{lddlflags} . ' -framework ApplicationServices',
LIBS => [''], # e.g., '-lm'
NAME => $meta->module_name(),
OBJECT => '$(O_FILES)', # link all the C files too
PREREQ_PM => $meta->requires(),
PL_FILES => {}, # Prevent old MakeMaker from running Build.PL
realclean => {
FILES => join( ' ', @{ $meta->add_to_cleanup() }, @clean_files ),
},
VERSION_FROM => $meta->version_from(),
);
$mmv >= 6.31
and $args{LICENSE} = $meta->license();
if ( $mmv >= 6.4501 ) {
$args{META_ADD} = {
no_index => $meta->no_index(),
$meta->provides(),
};
$args{META_MERGE} = $meta->meta_merge();
}
$mmv >= 6.4701
and $args{MIN_PERL_VERSION} = $meta->requires_perl();
if ( $mmv >= 6.52 ) {
$args{BUILD_REQUIRES} = $meta->build_requires();
$args{CONFIGURE_REQUIRES} = $meta->configure_requires();
} elsif ( $mmv >= 6.5501 ) {
$args{BUILD_REQUIRES} = $meta->build_requires();
$args{META_MERGE}{configure_requires} = $meta->configure_requires();
} elsif ( $mmv >= 6.4501 ) {
$args{META_MERGE}{build_requires} = $meta->build_requires();
$args{META_MERGE}{configure_requires} = $meta->configure_requires();
} else {
foreach my $method ( qw{ configure_requires build_requires } ) {
my $req = $meta->$method();
foreach my $key ( keys %{ $req } ) {
exists $args{PREREQ_PM}{$key}
or $args{PREREQ_PM}{$key} = $req->{$key};
}
}
}
WriteMakefile( %args );
sub MY::postamble {
my ( $self, @args ) = @_;
my $authortest = $self->test_via_harness(
'$(FULLPERLRUN)', '$(AUTHORTEST_FILES)' );
$authortest =~ s/ \s+ \z //smx;
$authortest =~ s/ \A \s+ //smx;
chomp $authortest;
return <<"EOD";
AUTHORTEST_FILES = t/*.t xt/author/*.t
authortest :: pure_all
AUTHOR_TESTING=1 $authortest
testcover :: pure_all
cover -test -ignore_re=inc/ -ignore_re=/System
pbl : pbl.c pbl.h constant-c.inc constant-h.inc
\$(CC) -o pbl -DTEST -DDEBUG_PBL \$(CCFLAGS) \$(CCCDLFLAGS) pbl.c -framework ApplicationServices
Pasteboard.c : Pasteboard.xs constant-xs.inc @{[ $opt{p} ? 'pbl.h constant-h.inc' : '' ]}
\$(XSUBPPRUN) \$(XSPROTOARG) \$(XSUBPPARGS) \$(XSUBPP_EXTRA_ARGS) \$*.xs > \$*.xsc
\$(MV) \$*.xsc \$*.c
#
#constant-c.inc constant-h.inc constant-xs.inc : tools/Constant.PL
# \$(PERLRUN) tools/Constant.PL
EOD
}
# ex: set textwidth=72 :