version 1.34, 2011/03/14 08:43:59 |
version 1.35, 2011/03/18 14:55:32 |
|
|
my $version = 0.23; # pretend to be this version of pkgconfig |
my $version = 0.23; # pretend to be this version of pkgconfig |
|
|
my %configs = (); |
my %configs = (); |
|
setup_self(); |
|
|
my %mode = (); |
my %mode = (); |
my $variables = {}; |
my $variables = {}; |
my $D = 0; # debug flag |
my $D = 0; # debug flag |
|
|
{ |
$variables->{pc_top_builddir} = $ENV{PKG_CONFIG_TOP_BUILD_DIR} // |
my $d = $ENV{PKG_CONFIG_TOP_BUILD_DIR}; |
'$(top_builddir)'; |
if (defined $d) { |
|
$variables->{pc_top_builddir} = $d; |
|
} else { |
|
$variables->{pc_top_builddir} = '$(top_builddir)'; |
|
} |
|
|
|
my $s = $ENV{PKG_CONFIG_SYSROOT_DIR}; |
$variables->{pc_sysrootdir} //= $ENV{PKG_CONFIG_SYSROOT_DIR}; |
if (defined $s) { |
# The default '/' is implied. |
$variables->{pc_sysrootdir} = $s; |
|
} |
|
# The default '/' is implied. |
|
} |
|
|
|
$D = 1 if defined($ENV{PKG_CONFIG_DEBUG_SPEW}); |
$D = 1 if defined $ENV{PKG_CONFIG_DEBUG_SPEW}; |
|
|
if ($logfile) { |
if ($logfile) { |
open my $L, ">>" . $logfile; |
open my $L, ">>" , $logfile or die; |
print $L '[' . join('] [', $0, @ARGV) . "]\n"; |
print $L beautify_list($_, @ARGV), "\n"; |
close $L; |
close $L; |
} |
} |
|
|
|
|
} |
} |
} |
} |
|
|
print STDERR "\n[" . join('] [', $0, @ARGV) . "]\n" if $D; |
print STDERR "\n", beautify_list($0, @ARGV), "\n" if $D; |
|
|
my $rc = 0; |
my $rc = 0; |
|
|
|
|
{ |
{ |
my $p = join(' ', @ARGV); |
my $p = join(' ', @ARGV); |
$p =~ s/^\s+//; |
$p =~ s/^\s+//; |
@ARGV = split /\s+/, $p; |
@ARGV = split /\,?\s+/, $p; |
} |
} |
|
|
if ($mode{myminvers}) { |
if ($mode{myminvers}) { |
|
|
my $p = shift @ARGV; |
my $p = shift @ARGV; |
my $op = undef; |
my $op = undef; |
my $v = undef; |
my $v = undef; |
if (@ARGV >= 2 && $ARGV[0] =~ /[<=>]+/ && |
if (@ARGV >= 2 && $ARGV[0] =~ /^[<=>]+$/ && |
$ARGV[1] =~ /[0-9\.]+/) { |
$ARGV[1] =~ /^[\d\.]+$/) { |
$op = shift @ARGV; |
$op = shift @ARGV; |
$v = shift @ARGV; |
$v = shift @ARGV; |
} |
} |
$p =~ s/,//g; |
|
handle_config($p, $op, $v, $cfg_full_list); |
handle_config($p, $op, $v, $cfg_full_list); |
push(@$top_config, $p); |
push(@$top_config, $p); |
} |
} |
|
|
sub handle_config |
sub handle_config |
{ |
{ |
my ($p, $op, $v, $list) = @_; |
my ($p, $op, $v, $list) = @_; |
my $cfg; |
my $cfg = cache_find_config($p); |
|
|
# pkg-config won't install a pkg-config.pc file itself, but it may be |
unshift @$list, $p if defined $cfg; |
# listed as a dependency in other files. |
|
# If we encounter a dependency on pkg-config, check if our version |
|
# is sufficient and error out if not. |
|
if ($p eq "pkg-config"){ |
|
if ($v > $version) { |
|
print STDERR "pkg-config version $version too old, $v required.\n" if $D; |
|
$rc = 1; |
|
return undef; |
|
} |
|
} else { |
|
$cfg = cache_find_config($p); |
|
|
|
unshift @$list, $p if defined $cfg; |
if (!defined $cfg) { |
|
$rc = 1; |
|
return undef; |
|
} |
|
|
if (!defined $cfg) { |
if (defined $op) { |
|
if (!versionmatch($cfg, $op, $v)) { |
|
mismatch($p, $cfg, $op, $v) if $mode{printerr}; |
$rc = 1; |
$rc = 1; |
return undef; |
return undef; |
} |
} |
|
} |
|
|
if (defined $op) { |
my $deps = $cfg->get_property('Requires', $variables); |
if (!versionmatch($cfg, $op, $v)) { |
if (defined $deps) { |
mismatch($p, $cfg, $op, $v) if $mode{printerr}; |
for my $dep (@$deps) { |
$rc = 1; |
if ($dep =~ m/^(.*?)\s*([<=>]+)\s*([\d\.]+)$/) { |
return undef; |
handle_config($1, $2, $3, $list); |
|
} else { |
|
handle_config($dep, undef, undef, $list); |
} |
} |
} |
} |
|
print STDERR "package $p requires ", |
|
join(',', @$deps), "\n" if $D; |
|
} |
|
|
my $deps = $cfg->get_property('Requires', $variables); |
$deps = $cfg->get_property('Requires.private', $variables); |
if (defined $deps) { |
if (defined $deps) { |
for my $dep (@$deps) { |
for my $dep (@$deps) { |
if ($dep =~ m/^(.*?)\s*([<=>]+)\s*([\d\.]+)$/) { |
if ($dep =~ m/^(.*?)\s*([<=>]+)\s*([\d\.]+)$/) { |
handle_config($1, $2, $3, $list); |
handle_config($1, $2, $3, $list); |
} else { |
} else { |
handle_config($dep, undef, undef, $list); |
handle_config($dep, undef, undef, $list); |
} |
|
} |
} |
print STDERR "package $p requires ", |
|
join(',', @$deps), "\n" if $D; |
|
} |
} |
|
print STDERR "package $p requires (private)", |
$deps = $cfg->get_property('Requires.private', $variables); |
join(',', @$deps), "\n" if $D; |
if (defined $deps) { |
|
for my $dep (@$deps) { |
|
if ($dep =~ m/^(.*?)\s*([<=>]+)\s*([\d\.]+)$/) { |
|
handle_config($1, $2, $3, $list); |
|
} else { |
|
handle_config($dep, undef, undef, $list); |
|
} |
|
} |
|
print STDERR "package $p requires (private)", |
|
join(',', @$deps), "\n" if $D; |
|
} |
|
} |
} |
} |
} |
|
|
|
|
} |
} |
} |
} |
|
|
|
# pkg-config won't install a pkg-config.pc file itself, but it may be |
|
|
|
# listed as a dependency in other files. |
|
# so, prime the cache with self |
|
sub setup_self |
|
{ |
|
my $pkg_pc = OpenBSD::PkgConfig->new; |
|
$pkg_pc->add_property('Version', $version); |
|
$configs{'pkg-config'} = $pkg_pc; |
|
} |
|
|
sub find_config |
sub find_config |
{ |
{ |
my ($p) = @_; |
my ($p) = @_; |
|
|
} |
} |
|
|
$rc = 1; |
$rc = 1; |
|
} |
|
|
|
sub beautify_list |
|
{ |
|
return join(' ', map {"[$_]"} @_); |
} |
} |