1use strict;
2use warnings;
3use Config;
4use ExtUtils::MakeMaker;
5
6require 5.008008;
7
8my $do_complex_h = 0; # Let the Makefile.PL decide whether to support the double _Complex and
9                   # long double _Complex data types.
10#$do_complex_h = 1; # Force inclusion of the double _Complex, long double _Complex and __float128 _Complex data types
11#$do_complex_h = -1;# Force exclusion of the double _Complex, long double _Complex and __float128 _Complex data types
12
13unless ($do_complex_h) {
14  eval {require Math::Complex_C;};
15  $do_complex_h = $@ ? -1 : 1;
16}
17
18unless ($do_complex_h) {
19  eval {require Math::Complex_C::L;};
20  $do_complex_h = $@ ? -1 : 1;
21}
22
23unless ($do_complex_h) {
24  eval {require Math::Complex_C::Q;};
25  $do_complex_h = $@ ? -1 : 1;
26}
27
28my $use_64_bit_int = 0; # Let perl decide whether to include 64-bit 'long long' support
29my $use_long_double = 0;# Let perl decide whether to include 'long double' support
30
31#$use_64_bit_int = -1; # Force exclusion of 64-bit 'long long' support
32#$use_long_double = -1;# Force exclusion of 'long double' support
33
34#$use_64_bit_int = 1; # Force inclusion of 64-bit 'long long' support
35#$use_long_double = 1;# Force inclusion of 'long double' support
36
37print "\nThis module requires the following C libraries:\n";
38print " gmp-4.3.2 (or later)\n mpfr-2.4.2 (or later)\n mpc-0.8 (or later)\n\n";
39
40my $defines = $] < 5.008 ? "-DOLDPERL" : "-DNEWPERL";
41
42if($use_64_bit_int == -1) {}
43elsif($use_64_bit_int == 1) {$defines .= " -DMATH_MPC_NEED_LONG_LONG_INT"}
44else {
45  unless($Config{ivsize} < 8 || $Config{ivtype} eq 'long') {
46    $defines .= " -DMATH_MPC_NEED_LONG_LONG_INT";
47  }
48}
49
50if($use_long_double == -1) {}
51elsif($use_long_double == 1) {
52  $defines .= " -DNV_IS_FLOAT128" if $Config{nvtype} eq '__float128';
53  $defines .= " -DNV_IS_LONG_DOUBLE" if $Config{nvtype} eq 'long double';
54}
55else {
56  if($Config::Config{nvsize} > 8 ) {
57    $defines .= " -DNV_IS_FLOAT128" if $Config{nvtype} eq '__float128';
58    $defines .= " -DNV_IS_LONG_DOUBLE" if $Config{nvtype} eq 'long double';
59  }
60}
61
62my $have_float128 = 0;
63for(@ARGV) {
64  $have_float128 = 1 if $_ eq 'F128=1';
65}
66
67$defines .= " -DMPFR_WANT_FLOAT128" if $have_float128;
68
69if($do_complex_h == 1) { $defines .= " -D_DO_COMPLEX_H"}
70
71$defines =~ /\-DMATH_MPC_NEED_LONG_LONG_INT/ ? print "Building with 64-bit'long long' support\n" :
72                                 print "Building without 64-bit 'long long' support\n";
73
74print "If this is wrong, see the \"64-bit support\" section in the README\n\n";
75
76($defines =~ /\-DNV_IS_LONG_DOUBLE/ || $defines =~ /\-DNV_IS_FLOAT128/)
77                                 ? print "Building with 'long double' support\n"
78                                 :print "Building without 'long double' support\n";
79
80print "If this is wrong, see the \"64-bit support\" section in the README\n\n";
81
82($defines =~ /\-DNV_IS_FLOAT128/) ? print "Building with '__float128' support (because nvtype is __float128)\n\n"
83                                 : print "Building without '__float128' support (because nvtype is not __float128)\n\n";
84
85($defines =~ /\-D_DO_COMPLEX_H/) ? print "Trying to build with 'double _Complex' & 'long double _Complex' support\n" :
86                                 print "Building without 'double _Complex' & 'long double _Complex' support\n";
87
88print "If this is wrong, see the \"_Complex C types support\" section in the README\n\n";
89
90$defines .= " -DNV_IS_DOUBLE" if $Config{nvtype} eq 'double';
91
92if($^O =~ /MSWin32/i && $] < 5.022) {
93  $defines .= " -D_WIN32_BIZARRE_INFNAN";
94}
95
96my %options = (
97  NAME => 'Math::MPC',
98  AUTHOR => 'Sisyphus (sisyphus at (@) cpan dot (.) org)',
99  ABSTRACT => 'Perl interface to the MPC (multi precision complex) library',
100  PREREQ_PM => {
101                'Math::MPFR'          => '4.14',
102                'ExtUtils::MakeMaker' => '6.58',
103                'Test::More'          => '0.88',
104               },
105  DEFINE   => $defines,
106  LIBS => [
107    '-lmpc -lmpfr -lgmp'
108  ],
109  LICENSE  => 'perl',
110  VERSION_FROM => 'MPC.pm',
111  clean   => { FILES => 'out1.txt out2.txt out3.txt out4.txt out5.txt out6.txt out7.txt out8.txt save_child_setting.txt' },
112  META_MERGE => {
113   'meta-spec' => { version => 2 },
114    resources => {
115      repository => {
116        type => 'git',
117        url => 'https://github.com/sisyphus/math-mpc.git',
118        web => 'https://github.com/sisyphus/math-mpc',
119      },
120    },
121  },
122);
123
124WriteMakefile(%options);
125
126# Remove the Makefile dependency. Causes problems on a few systems.
127sub MY::makefile { '' }
128
129