chiark / gitweb /
WIP PART OF SUBDIR
[subdirmk.git] / build-aux / subdirmk-setup
index c1866f6bcb29ae5f48858a6c3353e691972046dd..6822fe12aa27d8d285b1775dbbc7bbebcd242ad9 100644 (file)
@@ -8,35 +8,19 @@
 
 use strict;
 
-our $root = [ '.', [ ] ];
-# each node is [ 'relative subdir name', \@children ]
+our @allsubdirs = @ARGV;
 
-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) = @_;
+sub write_makefile () {
     start_output_file("Makefile");
-    my $cd = $depth ? join('/', ('..',) x $depth) : '.';
     print O <<END;
 %:
-       $(MAKE) -C $cd $subdir/$@
+       $(MAKE) -C @top $subdir/$@
 END
-}
+
+    my @thesedirs = $subdir, grep { $_ =~ m{^$subdir/} } @allsubdirs;
+    printf O "include $_/Subdir.mk"
+       
+
 
 sub process_subdir ($$) {
     my ($subdir) = @_;
@@ -45,4 +29,4 @@ sub process_subdir ($$) {
     filter_subdir_mk();
 }
 
-build_tree();
+foreach (@allsubdirs) { process_subdir($_); }