version 1.60, 2011/06/12 17:11:01 |
version 1.61, 2011/06/12 17:13:17 |
|
|
$variables->{pc_sysrootdir} //= $ENV{PKG_CONFIG_SYSROOT_DIR}; |
$variables->{pc_sysrootdir} //= $ENV{PKG_CONFIG_SYSROOT_DIR}; |
# The default '/' is implied. |
# The default '/' is implied. |
|
|
my $D; |
defined $ENV{PKG_CONFIG_DEBUG_SPEW} ? $mode{debug} = 1 : $mode{debug} = 0; |
defined $ENV{PKG_CONFIG_DEBUG_SPEW} ? $D = 1 : $D = 0; |
|
|
|
if ($logfile) { |
if ($logfile) { |
open my $L, ">>" , $logfile or die; |
open my $L, ">>" , $logfile or die; |
|
|
# without having to go back and reload the files from disk. |
# without having to go back and reload the files from disk. |
|
|
Getopt::Long::Configure('no_ignore_case'); |
Getopt::Long::Configure('no_ignore_case'); |
GetOptions( 'debug' => \$D, |
GetOptions( 'debug' => \$mode{debug}, |
'help' => \&help, #does not return |
'help' => \&help, #does not return |
'usage' => \&help, #does not return |
'usage' => \&help, #does not return |
'list-all' => \$mode{list}, |
'list-all' => \$mode{list}, |
|
|
|
|
# Initial value of printerr depends on the options... |
# Initial value of printerr depends on the options... |
if (!defined $mode{printerr}) { |
if (!defined $mode{printerr}) { |
if (defined $mode{libs} || defined $mode{cflags} |
if (defined $mode{libs} |
|| defined $mode{version} || defined $mode{list}) { |
or defined $mode{cflags} |
|
or defined $mode{version} |
|
or defined $mode{list}) { |
$mode{printerr} = 1; |
$mode{printerr} = 1; |
} else { |
} else { |
$mode{printerr} = 0; |
$mode{printerr} = 0; |
} |
} |
} |
} |
|
|
print STDERR "\n", beautify_list($0, @ARGV), "\n" if $D; |
pr_debug("\n" . beautify_list($0, @ARGV)); |
|
|
my $rc = 0; |
my $rc = 0; |
|
|
|
|
handle_config($dep, undef, undef, $list); |
handle_config($dep, undef, undef, $list); |
} |
} |
} |
} |
print STDERR "package $p ", lc($property), " ", |
pr_debug("package $p " . lc($property) . " " . join(',', @$deps)); |
join(',', @$deps), "\n" if $D; |
|
} |
} |
}; |
}; |
|
|
|
|
if ($allow_uninstalled && $p !~ m/\-uninstalled$/) { |
if ($allow_uninstalled && $p !~ m/\-uninstalled$/) { |
foreach my $d (@PKGPATH) { |
foreach my $d (@PKGPATH) { |
my $f = "$d/$p-uninstalled.pc"; |
my $f = "$d/$p-uninstalled.pc"; |
print STDERR "pathresolve($p) looking in $f\n" if $D; |
pr_debug("pathresolve($p) looking in $f"); |
if (-f $f) { |
if (-f $f) { |
$found_uninstalled = 1; |
$found_uninstalled = 1; |
return $f; |
return $f; |
|
|
|
|
foreach my $d (@PKGPATH) { |
foreach my $d (@PKGPATH) { |
my $f = "$d/$p.pc"; |
my $f = "$d/$p.pc"; |
print STDERR "pathresolve($p) looking in $f\n" if $D; |
pr_debug("pathresolve($p) looking in $f"); |
return $f if -f $f; |
return $f if -f $f; |
} |
} |
return undef; |
return undef; |
|
|
if (!$@) { |
if (!$@) { |
return validate_config($f, $cfg); |
return validate_config($f, $cfg); |
} else { |
} else { |
print STDERR $@, "\n" if $D; |
pr_debug($@); |
} |
} |
return undef; |
return undef; |
} |
} |
|
|
{ |
{ |
my $name = shift; |
my $name = shift; |
|
|
print STDERR "processing $name\n" if $D; |
pr_debug("processing $name"); |
|
|
if (exists $configs{$name}) { |
if (exists $configs{$name}) { |
return $configs{$name}; |
return $configs{$name}; |
|
|
|
|
# Check if we're dealing with an empty file, but don't error out just |
# Check if we're dealing with an empty file, but don't error out just |
# yet, we'll do that when we realize there's no Name field. |
# yet, we'll do that when we realize there's no Name field. |
if ((stat($f)->size == 0) && $mode{printerr}) { |
if (stat($f)->size == 0) { |
my $p = $f; |
my $p = $f; |
$p =~ s/(^.*\/)(.*?)$/$2/g; |
$p =~ s/(^.*\/)(.*?)$/$2/g; |
print STDERR "Package file '$p' appears to be empty\n"; |
pr_error("Package file '$p' appears to be empty"); |
} |
} |
|
|
foreach (@required_elems) { |
foreach (@required_elems) { |
my $e = $cfg->get_property($_, $variables); |
my $e = $cfg->get_property($_, $variables); |
if (!defined $e) { |
if (!defined $e) { |
$f =~ s/(^.*\/)(.*?)\.pc$/$2/g; |
$f =~ s/(^.*\/)(.*?)\.pc$/$2/g; |
if ($mode{printerr}) { |
pr_error("Package '$f' has no $_: field"); |
print STDERR "Package '$f' has no $_: field\n"; |
|
} |
|
return undef; |
return undef; |
} |
} |
} |
} |
|
|
if (defined $f) { |
if (defined $f) { |
return get_config($f); |
return get_config($f); |
} |
} |
if ($mode{printerr}) { |
pr_error("Package $p was not found in the pkg-config search path"); |
print STDERR |
|
"Package $p was not found in the pkg-config search path\n"; |
|
} |
|
return undef; |
return undef; |
} |
} |
|
|
|
|
# accepted are (in order): a(lpha) < b(eta) < rc < ' '. |
# accepted are (in order): a(lpha) < b(eta) < rc < ' '. |
# suffix[0] is the 'alpha' part, suffix[1] is the '1' part in 'alpha1'. |
# suffix[0] is the 'alpha' part, suffix[1] is the '1' part in 'alpha1'. |
if ($a =~ s/(rc|beta|b|alpha|a)(\d+)$//) { |
if ($a =~ s/(rc|beta|b|alpha|a)(\d+)$//) { |
print STDERR "valid suffix $1$2 found in $a$1$2.\n" if $D; |
pr_debug("valid suffix $1$2 found in $a$1$2."); |
$suffix_a[0] = $1; |
$suffix_a[0] = $1; |
$suffix_a[1] = $2; |
$suffix_a[1] = $2; |
} |
} |
|
|
if ($b =~ s/(rc|beta|b|alpha|a)(\d+)$//) { |
if ($b =~ s/(rc|beta|b|alpha|a)(\d+)$//) { |
print STDERR "valid suffix $1$2 found in $b$1$2.\n" if $D; |
pr_debug("valid suffix $1$2 found in $b$1$2."); |
$suffix_b[0] = $1; |
$suffix_b[0] = $1; |
$suffix_b[1] = $2; |
$suffix_b[1] = $2; |
} |
} |
|
|
|
|
# rc beats beta beats alpha |
# rc beats beta beats alpha |
if (&$first_char($suffix_a[0]) lt &$first_char($suffix_b[0])) { |
if (&$first_char($suffix_a[0]) lt &$first_char($suffix_b[0])) { |
print STDERR "$full_a (installed) < $full_b (wanted)\n" if $D; |
pr_debug("$full_a (installed) < $full_b (wanted)"); |
return -1; |
return -1; |
} else { |
} else { |
print STDERR "$full_a (installed) > $full_b (wanted)\n" if $D; |
pr_debug("$full_a (installed) > $full_b (wanted)"); |
return 1; |
return 1; |
} |
} |
|
|
|
|
# thereby beating the other. |
# thereby beating the other. |
# e.g.: 1.02 > 1.02b1 |
# e.g.: 1.02 > 1.02b1 |
if (@suffix_a) { # a is older |
if (@suffix_a) { # a is older |
print STDERR "$full_a (installed) < $full_b (wanted)\n" if $D; |
pr_debug("$full_a (installed) < $full_b (wanted)"); |
return 1; |
return 1; |
} |
} |
|
|
if (@suffix_b) { # b is older |
if (@suffix_b) { # b is older |
print STDERR "$full_a (installed) > $full_b (wanted)\n" if $D; |
pr_debug("$full_a (installed) > $full_b (wanted)"); |
return -1; |
return -1; |
} |
} |
} |
} |
|
|
# can't possibly match if we can't find the version string |
# can't possibly match if we can't find the version string |
return 0 if $inst eq ''; |
return 0 if $inst eq ''; |
|
|
print "comparing $want (wanted) to $inst (installed)\n" if $D; |
pr_debug("comparing $want (wanted) to $inst (installed)"); |
my $value = compare($inst, $want); |
my $value = compare($inst, $want); |
if ($op eq '>=') { return $value >= 0; } |
if ($op eq '>=') { return $value >= 0; } |
elsif ($op eq '=') { return $value == 0; } |
elsif ($op eq '=') { return $value == 0; } |
|
|
} elsif (defined($mode{printrequiresprivate})) { |
} elsif (defined($mode{printrequiresprivate})) { |
$value = $cfg->get_property('Requires.private', $variables); |
$value = $cfg->get_property('Requires.private', $variables); |
} else { |
} else { |
print STDERR "Unknown mode for print_requires.\n" if $D; |
pr_debug("Unknown mode for print_requires."); |
return 1; |
return 1; |
} |
} |
|
|
|
|
sub beautify_list |
sub beautify_list |
{ |
{ |
return join(' ', map {"[$_]"} @_); |
return join(' ', map {"[$_]"} @_); |
|
} |
|
|
|
sub pr_debug |
|
{ |
|
my $str = shift; |
|
print STDERR $str . "\n" if $mode{debug}; |
|
} |
|
|
|
sub pr_error |
|
{ |
|
my $str = shift; |
|
print STDERR $str . "\n" if $mode{printerr}; |
} |
} |