-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile.PL
160 lines (141 loc) · 4.71 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
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
use 5.008000;
use strict;
use warnings;
use ExtUtils::MakeMaker;
our (%CONFIGURE_REQUIRES, %TEST_REQUIRES, %PREREQ_PM);
BEGIN {
%CONFIGURE_REQUIRES= (
'Devel::CheckLib' => '1.03',
'ExtUtils::Depends' => '0.405',
'ExtUtils::MakeMaker' => 0,
);
%TEST_REQUIRES= (
'Test::More' => 0,
);
%PREREQ_PM= (
'Try::Tiny' => 0,
'Carp' => 0,
'Scalar::Util' => 0,
'strict' => 0,
'warnings' => 0,
);
# If the prereqs for this script are missing,
# write out a Makefile that tells CPAN to install them
my $use_prereqs_code= join('', map { "use $_ '$CONFIGURE_REQUIRES{$_}'; " } keys %CONFIGURE_REQUIRES).'1;';
print $use_prereqs_code."\n";
unless (eval $use_prereqs_code) {
warn "$@\n";
WriteMakefile(
NAME => 'X11::Xlib',
PREREQ_FATAL => 1,
PREREQ_PM => \%CONFIGURE_REQUIRES,
);
exit 1; # not reached
}
}
my $dep= ExtUtils::Depends->new('X11::Xlib');
# TODO: follow the pattern of Glib perl module and detect which extensions are
# present, then use that to determine which headers to include and which XS
# files to merge together.
my @incpath;
my @libpath;
unless (check_lib( lib => 'X11' )) {
if ($^O eq 'darwin') {
unless (-e '/opt/X11/lib') {
warn "Could not find /opt/X11/lib\n";
warn "On MacOS, you will need to install XQuartz (http://www.xquartz.org).\n";
exit;
}
push @incpath, '/opt/X11/include';
push @libpath, '/opt/X11/lib';
}
elsif (-e '/usr/X11R6/lib') {
push @incpath, '/usr/X11R6/include';
push @libpath, '/usr/X11R6/lib';
}
}
check_lib_or_exit(
lib => 'X11',
header => [ 'X11/Xlib.h', 'X11/Xutil.h' ],
incpath => \@incpath,
libpath => \@libpath,
);
check_lib_or_exit(
lib => 'Xtst',
header => [ 'X11/extensions/XTest.h' ],
incpath => \@incpath,
libpath => \@libpath,
);
check_lib_or_exit(
lib => 'Xext',
incpath => \@incpath,
libpath => \@libpath,
);
my @libs= qw( X11 Xtst Xext );
my @have;
sub add_optional_lib {
my ($lib, $header)= @_;
warn "Checking for extension $lib\n";
if (check_lib(
lib => $lib,
header => (ref $header? $header : [ $header ]),
incpath => \@incpath,
libpath => \@libpath,
)) {
warn " found!\n";
push @libs, $lib;
push @have, uc($lib);
} else {
warn " not available.\n";
}
}
add_optional_lib( Xcomposite => 'X11/extensions/Xcomposite.h' );
add_optional_lib( Xfixes => 'X11/extensions/Xfixes.h' );
add_optional_lib( Xrender => 'X11/extensions/Xrender.h' );
$dep->set_libs(join(' ', (map { "-L$_" } @libpath), (map { "-l$_" } @libs)));
if (@incpath) {
$dep->set_inc(join(' ', map { "-I$_" } @incpath));
}
$dep->add_c('PerlXlib.c');
$dep->add_xs('Xlib.xs');
$dep->add_pm(map { my $n= $_; $n =~ s/^lib/\$(INST_LIB)/; $_ => $n } <lib/*/*.pm>, <lib/*/*/*.pm>);
$dep->add_typemaps('typemap');
$dep->install('PerlXlib.h');
mkdir 'build', 0777;
$dep->save_config('build/IFiles.pm');
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
my %WriteMakefileArgs = (
NAME => 'X11::Xlib',
VERSION_FROM => 'lib/X11/Xlib.pm', # finds $VERSION
LICENSE => 'perl_5',
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/X11/Xlib.pm', # retrieve abstract from module
AUTHOR => [
'Olivier Thauvin <[email protected]>',
'Michael Conrad <[email protected]>'
]) : ()),
# Split out or combine dependencies depending on version of MakeMaker
( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ? (
CONFIGURE_REQUIRES => \%CONFIGURE_REQUIRES,
TEST_REQUIRES => \%TEST_REQUIRES,
PREREQ_PM => \%PREREQ_PM,
) : eval { ExtUtils::MakeMaker->VERSION(6.52) } ? (
CONFIGURE_REQUIRES => \%CONFIGURE_REQUIRES,
PREREQ_PM => { %PREREQ_PM, %TEST_REQUIRES },
) : (
PREREQ_PM => { %PREREQ_PM, %TEST_REQUIRES, %CONFIGURE_REQUIRES },
)),
DEFINE => join(' ', (map { "-DHAVE_$_" } @have)),
META_MERGE => {
resources => {
bugtracker => 'https://github.com/nanardon/X11-Xlib/issues',
repository => 'https://github.com/nanardon/X11-Xlib.git',
}
},
# script to update all version numbers to match X11/Xlib.pm
# Runs during "make dist"
dist => { PREOP => 'perl util/update_versions.pl' },
$dep->get_makefile_vars,
);
WriteMakefile( %WriteMakefileArgs );