-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.PL
90 lines (81 loc) · 3.03 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
#
# Copyright (C) 2006-2011 Tom Zoerner.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a copy of the GPL refer to <http://www.gnu.org/licenses/>
#
# $Id: Makefile.PL,v 1.6 2011/01/02 16:42:18 tom Exp tom $
#
# oldest supported perl version
use 5.007_001; # note: keep in sync with ZVBI.pm and META.yml
use ExtUtils::MakeMaker;
use ExtUtils::Liblist;
#
# Since MakeMaker considers missing libraries "probably harmless"
# we perform a search for libzvbi beforehand and abort if it's missing.
#
my $libs = '-lzvbi';
if ($^O =~ /bsd$/i) {
$libs .= ' -lpthread -lpng -lz';
}
my $inc = '';
if (($#ARGV >= 0) && ($ARGV[0] =~ /^LIBPATH=(.*)/)) {
my $libpath = $1;
shift @ARGV;
$libs = "-L$libpath $libs";
$libpath =~ m#^(/.*)/lib$# and $inc = "$1/include";
die "Cannot access $libpath: $!\n" unless -d $libpath;
print STDERR "Probing for prerequisite libzvbi in $libpath...\n";
} else {
print STDERR "Probing for prerequisite libzvbi at standard paths...\n";
}
my $ll = ExtUtils::Liblist->ext($libs, 1, 1); # verbose, return names
if ($#$ll < 0) {
print STDERR "\nFATAL: Prerequisite zvbi library not found on your system.\n".
"If it's located at a non-standard path, run Makefile.PL\n".
"with 'LIBPATH=/your/path' on the command line (and replace\n".
"'/your/path' with the directory which holds libzvbi.so)\n";
exit 0; # don't die to avoid FAIL reports from CPAN testers
}
#
# Compile path and base name of the library (sans minor version) into the
# module for dynamic loading
#
my $def = "";
my $lso_path;
foreach (@$ll) {
if (m#(^|/)(libzvbi\.so($|[^a-zA-Z].*))#) {
$lso_path = $_;
if (($lso_path =~ /(.*libzvbi\.so.\d+)/) && (-r $1)) {
$lso_path = $1;
}
print STDERR "Library path for dlopen(): $lso_path\n";
last;
}
}
# load optional symbols dynamically from shared library
# this requires to pass the library path and file name to dlopen()
die "\nFATAL: libzvbi.so not found in:\n".join(",",@$ll)."\n" unless defined $lso_path;
$def .= " -DUSE_DL_SYM -DLIBZVBI_PATH=\\\"$lso_path\\\"";
# use packaged header file instead of the one that may or may not be installed
# should only be enabled together with USE_DL_SYM
$def .= " -DUSE_LIBZVBI_INT";
#
# Generate the Makefile
#
WriteMakefile(
'NAME' => 'Video::ZVBI',
'VERSION_FROM' => 'ZVBI.pm',
'LIBS' => [ $libs ],
'DEFINE' => $def,
'INC' => $inc,
);