1# This Makefile.PL for Math-Int64 was generated by
2# inc::MyMakeMaker <self>
3# and Dist::Zilla::Plugin::MakeMaker::Awesome 0.33.
4# Don't edit it but the dist.ini and plugins used to construct it.
5
6use strict;
7use warnings;
8
9use 5.006;
10use ExtUtils::MakeMaker;
11
12my %WriteMakefileArgs = (
13  "ABSTRACT" => "Manipulate 64 bits integers in Perl",
14  "AUTHOR" => "Salvador Fandino <sfandino\@yahoo.com>, Dave Rolsky <autarch\@urth.org>",
15  "CONFIGURE_REQUIRES" => {
16    "ExtUtils::MakeMaker" => 0
17  },
18  "DISTNAME" => "Math-Int64",
19  "EXE_FILES" => [],
20  "LICENSE" => "perl",
21  "MIN_PERL_VERSION" => "5.006",
22  "NAME" => "Math::Int64",
23  "PREREQ_PM" => {
24    "Exporter" => 0,
25    "XSLoader" => 0,
26    "constant" => 0,
27    "overload" => 0,
28    "strict" => 0,
29    "warnings" => 0,
30    "warnings::register" => 0
31  },
32  "TEST_REQUIRES" => {
33    "ExtUtils::MakeMaker" => 0,
34    "File::Spec" => 0,
35    "IO::Handle" => 0,
36    "IPC::Open3" => 0,
37    "Storable" => 0,
38    "Test::More" => "0.96",
39    "blib" => "1.01"
40  },
41  "VERSION_FROM" => "lib/Math/Int64.pm",
42  "test" => {
43    "TESTS" => "t/*.t"
44  }
45);
46$WriteMakefileArgs{DEFINE} = join ' ',
47                               grep defined, _backend_define(),
48                                             _int64_define(),
49                                             _has_stdint_h_define();
50
51my %FallbackPrereqs = (
52  "Exporter" => 0,
53  "ExtUtils::MakeMaker" => 0,
54  "File::Spec" => 0,
55  "IO::Handle" => 0,
56  "IPC::Open3" => 0,
57  "Storable" => 0,
58  "Test::More" => "0.96",
59  "XSLoader" => 0,
60  "blib" => "1.01",
61  "constant" => 0,
62  "overload" => 0,
63  "strict" => 0,
64  "warnings" => 0,
65  "warnings::register" => 0
66);
67
68unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
69  delete $WriteMakefileArgs{TEST_REQUIRES};
70  delete $WriteMakefileArgs{BUILD_REQUIRES};
71  $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
72}
73
74delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
75  unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
76
77_check_for_capi_maker();
78
79WriteMakefile(%WriteMakefileArgs);
80
81use lib 'inc';
82use Config::AutoConf;
83
84sub _check_for_capi_maker {
85    return unless -d '.git';
86
87    unless ( eval { require Module::CAPIMaker; 1; } ) {
88        warn <<'EOF';
89
90  It looks like you're trying to build Math::Int64 from the git repo. You'll
91  need to install Module::CAPIMaker from CPAN in order to do this.
92
93EOF
94
95        exit 1;
96    }
97}
98
99my $autoconf;
100sub autoconf {
101    unless (defined $autoconf) {
102        $autoconf = Config::AutoConf->new;
103        unless ($autoconf->check_default_headers()) {
104            warn 'Config::AutoConf check for default headers failed!';
105            exit 1;
106        }
107    }
108    $autoconf;
109}
110
111sub _int64_define {
112    return '-DUSE_INT64_T' if autoconf->check_type('int64_t');
113    return '-DUSE___INT64' if autoconf->check_type('__int64');
114    return '-DUSE_INT64_DI'
115        if autoconf->check_type('int __attribute__ ((__mode__ (DI)))');
116
117    warn <<'EOF';
118
119  It looks like your compiler doesn't support a 64-bit integer type (one of
120  "int64_t" or "__int64"). One of these types is necessary to compile the
121  Math::Int64 module.
122
123EOF
124
125    exit 1;
126}
127
128sub _has_stdint_h_define {
129    return '-DHAS_STDINT_H' if autoconf->check_header('stdint.h');
130    undef
131}
132
133sub _backend_define {
134    my $backend
135        = defined $ENV{MATH_INT64_BACKEND} ? $ENV{MATH_INT64_BACKEND}
136        : $Config::Config{ivsize} >= 8     ? 'IV'
137        : $Config::Config{doublesize} >= 8 ? 'NV'
138        :                                    die <<'EOF';
139Unable to find a suitable representation for int64 on your system.
140Your Perl must have ivsize >= 8 or doublesize >= 8.
141EOF
142
143    print "Using $backend backend\n";
144
145    return '-DINT64_BACKEND_' . $backend;
146}
147
148package MY;
149
150sub postamble {
151    my $self = shift;
152
153    my $author = $self->{AUTHOR};
154    $author = join( ', ', @$author ) if ref $author;
155
156    if ($^O =~ /MSWin/) {
157        $author = qq{"$author"};
158    }
159    else {
160        $author =~ s/'/'\''/g;
161        $author = qq{'$author'};
162    }
163
164    return <<"MAKE_FRAG";
165c_api.h: c_api.decl
166	perl -MModule::CAPIMaker -emake_c_api module_name=\$(NAME) module_version=\$(VERSION) author=$author
167MAKE_FRAG
168}
169
170sub init_dirscan {
171    my $self = shift;
172    $self->SUPER::init_dirscan(@_);
173    push @{ $self->{H} }, 'c_api.h'
174        unless grep { $_ eq 'c_api.h' } @{ $self->{H} };
175    return;
176}
177