#!/usr/bin/perl -w # # $(srcdir)/build-aux/subdirmk-setup SUBDIR... # # generates # Subdir.mk.tmp # Makefile.tmp use strict; our @allsubdirs = @ARGV; sub write_makefile ($$) { 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); } foreach (@allsubdirs) { process_subdir($_); }