blob: c99c69d28cd924bc7f573e82dc595bf341a31ac7 [file] [log] [blame]
Patrick Williamsf04f1ce2015-03-01 03:50:18 -06001#!/usr/bin/env perl
2
3use strict;
4my %seen = ();
5
6# Generate dependency list for all 'priority' targets. These are targets a
7# user is likely to build.
8my @priority_targets = ( "openpower-pnor" );
9foreach my $target (@priority_targets)
10{
11 next if $seen{$target};
12
13 print "$target\n";
14 $seen{$target} = 1;
15 package_deps($target, 0);
16}
17
18# Generate dependency list for all other targets.
19packages();
20
21# @sub packages
22# @brief Determine all the packages that can be built.
23#
24# Skip host-* (uninteresting) and target-* (buildroot special) packages.
25sub packages
26{
27 open TARGETS, "make --directory=`pwd`/buildroot O=`pwd`/output ".
28 "show-targets | sed 's/^make:.*//' |";
29
30 while (my $line = <TARGETS>)
31 {
32 chomp $line;
33 next if ($line eq "");
34
35 my @targets = split / /,$line;
36 foreach (@targets)
37 {
38 next if ($seen{$_});
39 next if ($_ =~ m/^host-/);
40 next if ($_ =~ m/^target-/);
41
42 print $_."\n";
43 $seen{$_} = 1;
44 package_deps($_, 0);
45 }
46 }
47
48 close TARGETS
49
50}
51
52# @sub package_deps
53# @brief Collect children dependencies for a package.
54sub package_deps
55{
56 my $package = shift;
57 my $level = shift;
58
Patrick Williamsf04f1ce2015-03-01 03:50:18 -060059 $package =~ s/-rebuild.*//; # Strip off -rebuild* subpass.
60 $package =~ s/linux[0-9]*/linux/; # Strip off linux version.
61
62 open DEPENDS, "make --directory=`pwd`/buildroot O=`pwd`/output ".
63 "$package-show-depends | sed 's/^make:.*//' |";
64
65 while (my $line = <DEPENDS>)
66 {
67 chomp $line;
68 next if ($line eq "");
69
70 my @depends = split / /,$line;
71 foreach my $depend (@depends)
72 {
73 foreach (0..$level)
74 {
75 print " ";
76 }
77 print $depend."\n";
78
79 next if ($seen{$depend});
80 $seen{$depend} = 1;
81 package_deps($depend, $level+1);
82 }
83 }
84
85 close DEPENDS;
86}