3 ################################################################
5 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 2 or 3 as
9 # published by the Free Software Foundation.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program (see the file COPYING); if not, write to the
18 # Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 ################################################################
24 unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build');
31 my ($dist, $archs, $configdir, $type, $argument);
33 $configdir = ($::ENV{'BUILD_DIR'} || '/usr/lib/build') . '/configs';
36 if ($ARGV[0] eq '--dist') {
40 } elsif ($ARGV[0] eq '--archpath') {
44 } elsif ($ARGV[0] eq '--configdir') {
46 $configdir = shift @ARGV;
48 } elsif (defined($type)) {
49 $argument = shift @ARGV;
55 die("Please specify what to query\n") unless defined $type;
57 my $cf = Build::read_config_dist($dist, $archs, $configdir);
58 die("Unable to read config\n") unless $cf;
60 if ($type eq 'buildflags') {
61 die("Specify which buildflag to query\n") unless $argument;
62 my $result = $cf->{"buildflags:$argument"};
63 print "$result\n" if defined $result;
64 } elsif ($type eq 'target' || $type eq 'type' || $type eq 'binarytype' || $type eq 'buildengine' || $type eq 'rawmacros') {
65 print "$cf->{$type}\n" if $cf->{$type};
66 } elsif ($type eq 'optflags') {
67 exit(0) unless $cf->{'optflags'};
68 my $all = $cf->{'optflags'}->{'*'};
69 $all = defined($all) && $all ne '' ? " $all" : '';
70 $all .= " -g" if $argument && $argument eq 'debug';
71 for (sort keys %{$cf->{'optflags'}}) {
73 print "optflags: $_ $cf->{'optflags'}->{$_}$all\n";
75 } elsif ($type eq 'substitute') {
76 die("Specify which substitute to query\n") unless $argument;
77 my @res = @{$cf->{'substitute'}->{$argument} || []};
78 print join(' ', @res)."\n" if @res;
80 die("unsupported query type: $type\n");