[c82599]: Makefile.PL Maximize Restore History

Download this file

Makefile.PL    214 lines (182 with data), 5.9 kB

  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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# PDL interface to FFTW 2.x
use ExtUtils::MakeMaker;
use Config;
use PDL::Core::Dev;
require './fftw.conf';
$msg = "";
# Setup the FFTW library we will link to: (single/double precision)
# Default is double precision
$want_float = 0;
$want_double = 1;
if (defined $FFTW_CONFIG{FFTW_TYPE} && $FFTW_CONFIG{FFTW_TYPE} =~ /single/i ) {
$want_float = 1;
$want_double = 0;
}
$found_float = $found_double = 'none';
# Look for FFTW includes/libs
# default locations:
@FFTW_inc_locations = ('/usr/include', '/usr/local/include', $Config{usrinc});
@FFTW_lib_locations = ('/lib','/usr/lib','/usr/local/lib',split(/ /, $Config{libpth}));
# get locations from perldl.conf, if specified there:
@FFTW_inc_locations = @{$FFTW_CONFIG{FFTW_INC}} if( defined $FFTW_CONFIG{FFTW_INC} );
@FFTW_lib_locations = @{$FFTW_CONFIG{FFTW_LIBS}} if( defined $FFTW_CONFIG{FFTW_LIBS} );
foreach $i (@FFTW_inc_locations) {
if (-e "$i/dfftw.h") {
print "Found FFTW2 double version in $i/dfftw.h !\n";
$double_rinclude = 'drfftw.h';
$double_lib = '-ldfftw -ldrfftw';
# Inc found, now try to find libs:
if( findLibs($double_lib, @FFTW_lib_locations)){
print " FFTW Libs also found.\n";
$found_double = 'dfftw.h';
}
}
if (-e "$i/sfftw.h") {
print "Found FFTW2 single version $i/sfftw.h !\n";
$single_rinclude = 'srfftw.h';
$single_lib = '-lsfftw -lsrfftw';
# Inc found, now try to find libs:
if( findLibs($single_lib, @FFTW_lib_locations)){
print " FFTW Libs also found.\n";
$found_float = 'sfftw.h';
}
}
if (-e "$i/fftw.h") {
open F,"$i/fftw.h";
$is_float=0;
while (<F>) {
if (/define FFTW_ENABLE_FLOAT 1/) {$is_float=1;}
}
close F;
if ($is_float) {
print "Found FFTW2 single version in $i/fftw.h !\n";
$single_rinclude = 'rfftw.h';
$single_lib = '-lfftw -lrfftw';
# Inc found, now try to find libs:
if( findLibs($single_lib, @FFTW_lib_locations)){
print " FFTW Libs also found.\n";
$found_float = 'fftw.h';
}
}
else {
print "Found FFTW2 double version in $i/fftw.h !\n";
$double_rinclude = 'rfftw.h';
$double_lib = '-lfftw -lrfftw';
if( findLibs($double_lib, @FFTW_lib_locations)){
print " FFTW Libs also found.\n";
$found_double = 'fftw.h';
}
}
}
}
$donot = 1;
$wanted_not_found = 0;
# want float, found float
if ($found_float ne 'none' && $want_float ) {
$include = $found_float;
print "Building single version\n";
$pdltype = 'PDL_F';
$lib = $single_lib;
$rinclude = $single_rinclude;
$out = '$fftwtype=\'float\'';
$donot = 0;
}
# want double, found double
elsif ($found_double ne 'none' && $want_double ) {
$include = $found_double;
print "Building double version\n";
$pdltype = 'PDL_D';
$lib = $double_lib;
$rinclude = $double_rinclude;
$out = '$fftwtype=\'double\'';
$donot = 0;
}
if ( $donot ) {
$msg .= "\n Skipping build of PDL::FFTW.\n";
$elaborate = 0;
# maybe we found something, but it wasn't what was wanted...
if ( $found_double ne 'none' )
{ $msg .= "Found double version, wanted float!\n"; $elaborate++ }
if ( $found_float ne 'none' )
{ $msg .= "Found float version, wanted double!\n"; $elaborate++ }
unless ( $elaborate )
{ $msg .= " In the Makefile.PL try adding the location of the FFTW2 header and\n" .
" library to \@FFTW_inc_locations and \@FFTW_lib_locations (respectively).\n" }
}
if ($msg ne "") {
warn $msg . "\n";
$donot = 1;
} else {
print "\n Building PDL::FFTW. Turn off WITH_FFTW if there are any problems\n\n";
}
# Sub to find libs
sub findLibs {
my ($libstring, @libdirs) = @_;
# make a list of libs from the libstring
my @libs = split ' ',$double_lib;
grep s/\-l//g, @libs;
grep $_ = "lib$_.a", @libs;
my %libs;
my $lib;
foreach $libdir(@libdirs){
foreach $lib(@libs){
if( -e "$libdir/$lib"){
$libs{$lib} = 1;
}
}
}
if( scalar(keys %libs) == scalar(@libs) ){
return 1; # all libs in the list were found
}
print " Libs: '".join("', '",@libs)."' Not Found\n";
print " Looked in: '".join("', '",@libdirs)."'\n";
return 0; # all libs in the list not found
}
if ($donot) {
return if (caller); exit 0;
}
open F,'>typespec';
print F $out,";\n";
print F 'pp_addhdr(\'',"\n";
print F '#include "',$include,'"',"\n";
print F '#include "',$rinclude,'"',"\n";
print F '#define PDL_MYTYPE ',$pdltype,"\n";
print F '\');',"\n";
close F;
@pack = (["fftw.pd",FFTW,PDL::FFTW]);
%hash = pdlpp_stdargs(@::pack);
$hash{INC} .= " -I".join(' -I',@FFTW_inc_locations);
$hash{VERSION_FROM} = 'fftw.pd';
$hash{clean}->{FILES} .= ' typespec MANIFEST.bak';
push @{$hash{LIBS}},"-lm -L".join(" -L",@FFTW_lib_locations)." $lib";
$hash{PREREQ_PM} = { 'PDL' => 2.004, };
$hash{CONFIGURE_REQUIRES} = { 'PDL' => 2.004, };
$hash{META_MERGE} = {
'provides' => {
'PDL::FFTW' => {
'file' => 'fftw.pd',
'version' => '2.019',
},
},
'resources' => {
'homepage' => 'http://pdl.perl.org/',
'bugtracker' => {
'web' => 'http://sourceforge.net/p/pdl/bugs/',
},
'repository' => {
'url' => 'git://git.code.sf.net/p/pdl/pdl-fftw',
'web' => 'http://sourceforge.net/p/pdl/pdl-fftw/ci/master/tree/',
'type' => 'git',
},
},
};
WriteMakefile(%hash);
sub MY::postamble {
my $pdlpp_post = pdlpp_postamble(@::pack);
my $text = <<"FOO";
install ::
\t\@echo "Updating PDL documentation database...";
\t\@\$(PERL) -e "use PDL::Doc; eval { PDL::Doc::add_module(q{PDL::FFTW}); }; ";
FOO
return $pdlpp_post . $text;
} # Add genpp rule