diff options
author | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2011-03-10 19:13:15 +0000 |
---|---|---|
committer | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2011-03-10 19:13:15 +0000 |
commit | 732c603fe121b02b406a65654d9f80dcc4d490ed (patch) | |
tree | 352841c679bb4a6b39bce79c03efde7de6f6add3 /usr.bin/pkg-config | |
parent | cc26bbdf73f736ee57658b579b077c1ea9e861c2 (diff) |
- implement several more options that will be needed to bump to 0.24
(--print-provides, --print-requires and --print-requires-private)
ok ckuethe@
Diffstat (limited to 'usr.bin/pkg-config')
-rw-r--r-- | usr.bin/pkg-config/pkg-config | 53 | ||||
-rw-r--r-- | usr.bin/pkg-config/pkg-config.1 | 8 |
2 files changed, 55 insertions, 6 deletions
diff --git a/usr.bin/pkg-config/pkg-config b/usr.bin/pkg-config/pkg-config index 5de3db6e65b..0089d120f2f 100644 --- a/usr.bin/pkg-config/pkg-config +++ b/usr.bin/pkg-config/pkg-config @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: pkg-config,v 1.29 2011/03/10 19:06:30 jasper Exp $ +# $OpenBSD: pkg-config,v 1.30 2011/03/10 19:13:14 jasper Exp $ #$CSK: pkgconfig.pl,v 1.39 2006/11/27 16:26:20 ckuethe Exp $ # Copyright (c) 2006 Chris Kuethe <ckuethe@openbsd.org> @@ -82,6 +82,9 @@ GetOptions( 'debug' => \$D, 'silence-errors' => sub { $mode{printerr} = 0}, 'short-errors' => sub { $mode{printerr} = 0}, 'atleast-pkgconfig-version=s' => \$mode{myminvers}, + 'print-provides' => \$mode{printprovides}, + 'print-requires' => \$mode{printrequires}, + 'print-requires-private' => \$mode{printrequiresprivate}, 'cflags' => sub { $mode{cflags} = 3}, 'cflags-only-I' => sub { $mode{cflags} |= 1}, @@ -156,12 +159,18 @@ if ($mode{uninstalled}) { exit $rc; } -if ($mode{modversion}) { +if ($mode{modversion} || $mode{printprovides}) { for my $pkg (@$top_config) { do_modversion($pkg); } } +if ($mode{printrequires} || $mode{printrequiresprivate}) { + for my $pkg (@$top_config) { + print_requires($pkg); + } +} + if ($mode{minversion}) { my $v = $mode{minversion}; for my $pkg (@$top_config) { @@ -364,7 +373,8 @@ sub do_variable $rc = 1; } -#if the modversion option is set, pull out the compiler flags +#if the modversion or print-provides options are set, +#pull out the compiler flags sub do_modversion { my ($p) = @_; @@ -374,8 +384,13 @@ sub do_modversion if (defined $cfg) { my $value = $cfg->get_property('Version', $variables); if (defined $value) { - print stringize($value), "\n"; - return undef; + if (!defined($mode{printprovides})){ + print stringize($value), "\n"; + return undef; + } else { + print "$p = " . stringize($value) . "\n"; + return undef; + } } } $rc = 1; @@ -590,3 +605,31 @@ sub simplify_and_reverse } return $result; } + +# retrieve and print Requires(.private) +sub print_requires +{ + my ($p) = @_; + + my $cfg = cache_find_config($p); + + if (defined($cfg)) { + my $value; + + if (defined($mode{printrequires})) { + $value = $cfg->get_property('Requires', $variables); + } elsif (defined($mode{printrequiresprivate})) { + $value = $cfg->get_property('Requires.private', $variables); + } else { + print STDERR "Unknown mode for print_requires.\n" if $D; + return 1; + } + + if (defined($value)) { + print "$_\n" foreach (@$value); + return undef; + } + } + + $rc = 1; +} diff --git a/usr.bin/pkg-config/pkg-config.1 b/usr.bin/pkg-config/pkg-config.1 index b7b2740a84e..5c0cf4ab32f 100644 --- a/usr.bin/pkg-config/pkg-config.1 +++ b/usr.bin/pkg-config/pkg-config.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pkg-config.1,v 1.16 2011/03/10 19:07:45 jasper Exp $ +.\" $OpenBSD: pkg-config.1,v 1.17 2011/03/10 19:13:14 jasper Exp $ .\" .\" Copyright (c) 2006 Chris Kuethe <ckuethe@openbsd.org> .\" @@ -106,6 +106,12 @@ returns its own version. .It Cm --print-errors Print error messages and exit with an error when errors occur. This is the default operation. +.It Cm --print-provides +Print all the modules the given package provides. +.It Cm --print-requires +Print all the modules the given package requires. +.It Cm --print-requires-private +Print all the modules the given package requires for static linking. .It Cm --silence-errors Do not print error messages, just exit with an error. .It Cm --static |