-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.args
90 lines (74 loc) · 1.77 KB
/
Makefile.args
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
%WriteMakefileArgs = (
%WriteMakefileArgs,
OBJECT => ['$(BASEEXT)$(OBJ_EXT)'],
"test" => { "TESTS" => "t/*.t" },
depend => {
'Direct.c' => 'Direct.xs xs/*.xs xs/*.c',
},
);
my $addl_search = $ENV{ADDL_SEARCH} // '';
my $addl_L = '';
if ( !$addl_search && -e 'webgpu/webgpu.h' )
{
$addl_search = 'webgpu';
}
if ( $addl_search && -e "$addl_search/webgpu/webgpu.h" )
{
$addl_search = "$addl_search/webgpu/";
}
if ($addl_search)
{
$addl_L = "-L$addl_search";
}
my ($EXTRALIBS) = do
{
local $SIG{__WARN__} = sub { };
ExtUtils::Liblist->ext("-l_lib_test_$$");
};
sub is_lib
{
my $lib = shift;
my ($extra) = ExtUtils::Liblist->ext("$addl_L -l$lib");
$extra =~ s/\Q$EXTRALIBS//;
return !!$extra;
}
my $wgpu;
my @tests = qw/wgpu_native dawn_native/;
for my $wgpu_test (@tests)
{
if ( is_lib($wgpu_test) )
{
$wgpu = $wgpu_test;
last;
}
}
if ( !$wgpu )
{
die "Unable to locate WebGPU library (tried @tests)\n";
}
my @libs;
my @defines;
if ( is_lib('X11') )
{
push @libs, '-lX11';
push @defines, '-DHAS_X11';
}
if ( is_lib('wayland-client') && qx/pkg-config --version 2>&1/ )
{
my $scanner = qx/pkg-config --variable=wayland_scanner wayland-scanner/;
my $proto_dir = qx/pkg-config wayland-protocols --variable=pkgdatadir/;
chomp $proto_dir;
my $xml = "$proto_dir/stable/xdg-shell/xdg-shell.xml";
if ( $scanner && -e $xml )
{
qx{wayland-scanner client-header $xml xdg-shell.h};
qx{wayland-scanner private-code $xml xdg-shell.c};
push @libs, '-lwayland-client';
push @defines, '-DHAS_WAYLAND';
push $WriteMakefileArgs{OBJECT}->@*, 'xdg-shell.o';
}
}
$WriteMakefileArgs{LIBS} = "$addl_L -l$wgpu @libs";
$WriteMakefileArgs{DEFINE} = "@defines";
$WriteMakefileArgs{INC} = "-I$addl_search/.."
if $addl_search;