text
stringlengths
0
834k
use File::Basename qw( dirname );
use Text::ParseWords qw( shellwords );
our $UseDebugging;
################################################################################
### Check for Log::Fu ###
################################################################################
BEGIN {
my $ret = eval q{
use Log::Fu 0.25 { level => ""warn"" };
1;
};
if(!$ret) {
my $log_base = sub {
my (@args) = @_;
print STDERR ""[DEBUG] "", join(' ', @args);
print STDERR ""\n"";
};
*log_debug = *log_debugf = sub { return unless $UseDebugging; goto &$log_base };
*log_err = *log_errf = *log_warn = *log_warnf = *log_info = *log_infof =
$log_base;
}
}
our $VarClassSerial = 0;
################################################################################
### Sane Defaults ###
################################################################################
our @DEFAULT_SEARCH_PATH = qw(
/usr/local/lib/pkgconfig /usr/local/share/pkgconfig
/usr/lib/pkgconfig /usr/share/pkgconfig
);
our @DEFAULT_EXCLUDE_CFLAGS = qw(-I/usr/include -I/usr/local/include);
# don't include default link/search paths!
our @DEFAULT_EXCLUDE_LFLAGS = map { ( ""-L$_"", ""-R$_"" ) } qw( /lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib/64 /usr/local/lib /usr/local/lib32 /usr/local/lib64 );
if($ENV{PKG_CONFIG_NO_OS_CUSTOMIZATION}) {
# use the defaults regardless of detected platform
} elsif($ENV{PKG_CONFIG_LIBDIR}) {
@DEFAULT_SEARCH_PATH = split $Config{path_sep}, $ENV{PKG_CONFIG_LIBDIR};
} elsif($^O eq 'msys') {
# MSYS2 seems to actually set PKG_CONFIG_PATH in its /etc/profile
# god bless it. But. The defaults if you unset the environment
# variable are different
@DEFAULT_SEARCH_PATH = qw(
/usr/lib/pkgconfig
/usr/share/pkgconfig
);
} elsif($^O eq 'solaris' && $Config{ptrsize} == 8) {
@DEFAULT_SEARCH_PATH = qw(
/usr/local/lib/64/pkgconfig /usr/local/share/pkgconfig
/usr/lib/64/pkgconfig /usr/share/pkgconfig
);
} elsif($^O eq 'linux' and -f '/etc/gentoo-release') {
# OK, we're running on Gentoo
# Fetch ptrsize value
my $ptrsize = $Config{ptrsize};
# Are we running on 64 bit system?
if ($ptrsize eq 8) {
# We do
@DEFAULT_SEARCH_PATH = qw!
/usr/lib64/pkgconfig/ /usr/share/pkgconfig/
!;
} else {
# We're running on a 32 bit system (hopefully)
@DEFAULT_SEARCH_PATH = qw!
/usr/lib/pkgconfig/ /usr/share/pkgconfig/
!;
}
} elsif($^O =~ /^(gnukfreebsd|linux)$/ && -r ""/etc/debian_version"") {
my $arch;
if(-x ""/usr/bin/dpkg-architecture"") {
# works if dpkg-dev is installed
# rt96694
($arch) = map { chomp; (split /=/)[1] }
grep /^DEB_HOST_MULTIARCH=/,
`/usr/bin/dpkg-architecture`;
} elsif(-x ""/usr/bin/gcc"") {
# works if gcc is installed
$arch = `/usr/bin/gcc -dumpmachine`;
chomp $arch;
} else {