summaryrefslogtreecommitdiff
path: root/getoptflags
blob: 8031bf9d270419238f91dd0338e251846fb8779b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl -w

BEGIN {
  unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build');
}

use strict;

use Build;

my ($dist, $archs, $configdir, $debug);

while (@ARGV)  {
  if ($ARGV[0] eq '--dist') {
    shift @ARGV;
    $dist = shift @ARGV;
    next;
  }
  if ($ARGV[0] eq '--archpath') {
    shift @ARGV;
    $archs = shift @ARGV;
    next;
  }
  if ($ARGV[0] eq '--configdir') {
    shift @ARGV;
    $configdir = shift @ARGV;
    next;
  }
  if ($ARGV[0] eq '--debug') {
    shift @ARGV;
    $debug = 1;
    next;
  }
  last;
}

die("Usage: getoptflags --dist <dist> --archpath <archpath> [--configdir <configdir>]\n") if @ARGV;

my $cf = Build::read_config_dist($dist, $archs, $configdir);
exit 0 unless $cf->{'optflags'};
my $all = $cf->{'optflags'}->{'*'};
$all = defined($all) && $all ne '' ? " $all" : '';
$all .= " -g" if $debug;
for (sort keys %{$cf->{'optflags'}}) {
  next if $_ eq '*';
  print "optflags: $_ $cf->{'optflags'}->{$_}$all\n";
}