chiark
/
gitweb
/
~ian
/
subdirmk.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8a218c9
)
GO BACK TO HIER
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 10 Nov 2019 13:41:00 +0000
(13:41 +0000)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 10 Nov 2019 13:41:29 +0000
(13:41 +0000)
build-aux/subdirmk-setup
patch
|
blob
|
history
diff --git
a/build-aux/subdirmk-setup
b/build-aux/subdirmk-setup
index 11d0f26c8b131d459951ec3a393accf47ae7b7d3..c1866f6bcb29ae5f48858a6c3353e691972046dd 100644
(file)
--- a/
build-aux/subdirmk-setup
+++ b/
build-aux/subdirmk-setup
@@
-8,38
+8,41
@@
use strict;
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 ($$) {
sub write_makefile ($$) {
- my ($subdir,$depth)
+ my ($subdir,$depth)
= @_;
start_output_file("Makefile");
my $cd = $depth ? join('/', ('..',) x $depth) : '.';
print O <<END;
start_output_file("Makefile");
my $cd = $depth ? join('/', ('..',) x $depth) : '.';
print O <<END;
-# autogenerated - do not edit
%:
%:
-
\$(MAKE) -C $cd $subdir/\
$@
+
$(MAKE) -C $cd $subdir/
$@
END
}
END
}
-sub require_subdir ($) {
- # => 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);
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();