-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.PL
126 lines (115 loc) · 3.34 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
use strict;
use warnings;
use ExtUtils::MakeMaker;
use Config;
use Text::ParseWords qw(shellwords quotewords);
use PDL::Core::Dev;
my ($include_path, $lib_path, $linkname);
my $ppfile = "GD.pd";
my $package_name = "PDL::IO::GD";
my $lib_name = "GD";
my @find_libs = ( "libgd.$Config{dlext}", 'libgd.a', 'libgd.dll.a', 'bgd.dll' );
my @find_incs = ( 'gd.h' );
my @lib_locations = grep defined, (
$ENV{GD_LIBS},
find_macos_path('lib'),
'/usr/lib64',
'/usr/local/lib64',
'/lib64',
'/usr/lib',
'/usr/local/lib',
'/lib',
($^O eq 'MSWin32'
? (split($Config{path_sep}, $ENV{PATH}),
(map {s/^-L//;$_} grep /^-L/, map {s/"//g; $_} quotewords('\s+', 1, $Config{ldflags}))
)
: shellwords($Config{libpth})),
);
my @inc_locations = grep defined, (
$ENV{GD_INC},
find_macos_path('include'),
'/usr/include',
'/usr/local/include',
$Config{usrinc},
(map {s/^-I//;$_} grep /^-I/, $^O eq 'MSWin32'
? (map {s/"//g; $_} quotewords('\s+', 1, $Config{cppflags}))
: shellwords($Config{cppflags})),
);
sub find_macos_path {
return if $^O ne 'darwin';
my $pref = `brew --prefix gd`;
return if !$pref;
chomp $pref;
qq{$pref/$_[0]};
}
my $msg = "";
# Look for GD includes/libs
# Look for the libs:
foreach my $libdir ( @lib_locations ) {
my $found = 0;
foreach my $find_lib ( @find_libs ) {
if ( -e "$libdir/$find_lib" ) {
$lib_path = $libdir;
$found = 1;
# The lib name is different on windows, so we need to adjust the LIBS, below:
$linkname = ( $find_lib =~ /bgd.dll$/ ) ? 'bgd' : 'gd';
}
last if $found;
}
last if $found;
} # foreach $libdir...
unless( defined( $lib_path ) ) {
$msg .= "Cannot find $lib_name library, (@find_libs).\n"
. "Please add the correct library path to Makefile.PL or install $lib_name\n.";
}
# Look for the include files:
foreach my $incdir ( @inc_locations ) {
foreach my $find_inc ( @find_incs ) {
if ( -e "$incdir/$find_inc" ) {
$include_path = $incdir;
last;
}
}
}
unless( defined( $include_path ) ) {
$msg .= "Cannot find $lib_name header files, (@find_incs).\n"
. "Please add the correct library path to Makefile.PL or install $lib_name.\n";
}
die $msg if $msg;
my $package = [$ppfile, $lib_name, $package_name];
my %hash = pdlpp_stdargs($package);
$hash{VERSION_FROM} = $ppfile;
$hash{DEFINE} = $ENV{GD_DEFINE};
$hash{LIBS} = [qq{-L"$lib_path" -l$linkname}];
$hash{INC} = PDL_INCLUDE() . qq{ -I"$include_path"};
$hash{CONFIGURE_REQUIRES} = {
'ExtUtils::MakeMaker' => 0,
'PDL' => '2.094',
};
$hash{PREREQ_PM} = {
'PDL' => '2.094',
};
$hash{TEST_REQUIRES} = {
'Test::More' => '0.88',
};
$hash{AUTHOR} = 'PerlDL Developers <[email protected]>';
$hash{LICENSE} = "perl";
sub MY::postamble { pdlpp_postamble( $package ); }
(my $repo = $package_name) =~ s#::#-#g;
$repo = "PDLPorters/$repo";
WriteMakefile(
META_MERGE => {
"meta-spec" => { version => 2 },
resources => {
homepage => 'http://pdl.perl.org/',
bugtracker => {web=>"https://github.com/$repo/issues"},
repository => {
url => "git://github.com/$repo.git",
type => 'git',
web => "https://github.com/$repo",
},
x_IRC => 'irc://irc.perl.org/#pdl',
},
},
%hash,
);