Automagically expand includes in Makefile.in during configure time
[ira/wip.git] / source3 / script / expand-includes.pl
1 #!/usr/bin/perl
2 # Expand the include lines in a Makefile
3 # Copyright (C) 2009 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPLv3 or later
5
6 sub process($)
7 {
8         my ($f) = @_;
9         open(IN, $f) or die("Unable to open $f: $!");
10         foreach (<IN>) {
11                 my $l = $_;
12                 if ($l =~ /^include (.*)$/) {
13                         process($1);
14                 } else {
15                         print $l;
16                 }
17         }
18 }
19
20 my $path = shift;
21 unless ($path) {
22         print STDERR "Usage: $0 Makefile.in > Makefile-noincludes.in\n";
23         exit(1);
24 }
25 process($path);