From d952e6bb30f6bfb1f1100a6b8ec263fc08073d51 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 10 Nov 2019 13:41:00 +0000 Subject: [PATCH 1/1] GO BACK TO HIER --- build-aux/subdirmk-setup | 43 +++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/build-aux/subdirmk-setup b/build-aux/subdirmk-setup index 11d0f26..c1866f6 100644 --- a/build-aux/subdirmk-setup +++ b/build-aux/subdirmk-setup @@ -8,38 +8,41 @@ use strict; -our @allsubdirs = @ARGV; +our $root = [ '.', [ ] ]; +# each node is [ 'relative subdir name', \@children ] + +sub build_tree () { + foreach my $subdir (@ARGV) { + my @path = $subdir eq '.' ? () : split m{/+}, $subdir; + my $node = $root; + foreach my $d (@path) { + my ($c,) = grep { $_->[0] eq $d } @{ $node->[1] }; + if (!$c) { + $c = [ $d, [ ] ]; + push @{ $node->[1] }, $c; + } + $node = $c; + } + } +} + + sub write_makefile ($$) { - my ($subdir,$depth) + my ($subdir,$depth) = @_; start_output_file("Makefile"); my $cd = $depth ? join('/', ('..',) x $depth) : '.'; print O < list of descendant subdirs - my ($here) = (@_); - my $prefix = $here eq '.' ? qr{} : qr{$prefix/}; - my @children = grep { m{^$prefix[^/]+$} } @allsubdirs; - my @descendants; - foreach my $child (@children) { - push @descendants, require_subdir( - - $subdir, grep { $_ =~ m{^$subdir/} } - printf O "include $_/Subdir.mk" - - - sub process_subdir ($$) { my ($subdir) = @_; my $depth = $subdir eq '.' ? 0 : scalar split m{/+}, $subdir; write_makefile($subdir,$depth); - require_subdir($subdir); + filter_subdir_mk(); } -foreach (@allsubdirs) { process_subdir($_); } +build_tree(); -- 2.30.2