]> git.donarmstrong.com Git - lilypond.git/blob - bin/wild-perl
release: 0.1.52
[lilypond.git] / bin / wild-perl
1 # -*- perl -*-
2 ##! @PERL@
3
4 use Getopt::Long;
5 GetOptions("top-srcdir:s");
6
7 $my_topdir = $opt_top_srcdir ? $opt_top_srcdir : "\$(top_srcdir)";
8
9 @ignorestuff = ();
10
11 sub ignore_query
12 {
13     my ($testfile) = @_;
14     return !grep(/$testfile/, @ignorestuff);
15 }
16
17 print "# Generated automatically by wild-perl 0.1\n";
18
19
20 while (<>) {
21         $line = $_;
22         if ($line =~ /^ *nowildcard: *(.*)$/) {
23             $ignore = $1;
24             @ignorelist = split (/ +/, $ignore);
25             foreach $i (@ignorelist) {
26                 print "# ignoring wildcards for \`$i\'\n";
27                 push @ignorestuff, $i; # concat ? uh?
28             }
29
30             
31         } elsif ($line =~ /(.*)\$\(wildcard(.*)\)(.*)/) {
32             $wild = $2;
33             
34             @expanded = glob ($wild);
35
36             @expanded = grep {ignore_query($_);}  @expanded;
37             
38             print $1 . join (' ', @expanded) . $3 . "\n";
39         } else {
40             print $line;
41         }
42 }
43
44
45 print "\$(srcdir)/Makefile.am: \$(srcdir)/Makefile.am.wild\n" .
46     "\t\$(PERL) $my_topdir/bin/wild-perl --top-srcdir=\"\$(real_topdir)\" < \$< > \$@";
47