X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=examples%2Fdepmod.pl;h=809dc08b39e85de8b384ccaeddc237262162ac27;hb=778794d1dd99f29d099eb80ae2750381bc5e0059;hp=6b47bad094c7665649c516e842c0b312cf4ce6df;hpb=2b6497ba84a3c612738a5939c142e33480e8e0f6;p=oweals%2Fbusybox.git diff --git a/examples/depmod.pl b/examples/depmod.pl index 6b47bad09..809dc08b3 100755 --- a/examples/depmod.pl +++ b/examples/depmod.pl @@ -167,25 +167,39 @@ sub maybe_unshift } unshift (@{$array}, $ele); } +sub add_mod_deps +{ + my ($depth, $mod, $mod2, $module, $this_module) = @_; + + $depth .= " "; + warn "${depth}loading deps of module: $this_module\n" if $verbose; + if (length($depth) > 50) { + die "too much recursion (circular dependencies in modules?)"; + } + + foreach my $md (keys %{$mod->{$this_module}}) { + add_mod_deps ($depth, $mod, $mod2, $module, $md); + warn "${depth} outputting $md\n" if $verbose; + maybe_unshift (\@{$$mod2->{$module}}, $md); + } + + if (!%{$mod->{$this_module}}) { + warn "${depth} no deps\n" if $verbose; + } +} foreach my $module (keys %$mod) { - warn "filling out module: $module\n" if $verbose; - @{$mod2->{$module}} = (); - foreach my $md (keys %{$mod->{$module}}) { - foreach my $md2 (keys %{$mod->{$md}}) { - warn "outputting $md2\n" if $verbose; - maybe_unshift (\@{$mod2->{$module}}, $md2); - } - warn "outputting $md\n" if $verbose; - maybe_unshift (\@{$mod2->{$module}}, $md); - } + warn "filling out module: $module\n" if $verbose; + @{$mod2->{$module}} = (); + add_mod_deps ("", $mod, \$mod2, $module, $module); } # figure out where the output should go if ($stdout == 0) { + warn "writing $basedir/modules.dep\n" if $verbose; open(STDOUT, ">$basedir/modules.dep") or die "cannot open $basedir/modules.dep: $!"; } -my $kseries = $basedir =~ m,/2\.6\.[^/]*, ? '2.6' : '2.4'; +my $kseries = $basedir =~ m,/2\.4\.[^/]*, ? '2.4' : 'others'; foreach my $module ( keys %$mod ) { if($kseries eq '2.4') {