]> git.donarmstrong.com Git - lilypond.git/blob - bin/wild-perl
release: 0.1.54
[lilypond.git] / bin / wild-perl
1 # -*- perl -*-
2 ##! @PERL@
3
4 use Getopt::Long;
5 GetOptions("top-srcdir:s");
6
7 $my_topsrcdir = $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                 print "IGNORE_WILDCARDS=$ignore";
29             }
30
31             
32         } elsif ($line =~ /(.*)\$\(wildcard(.*)\)(.*)/) {
33             $wild = $2;
34             
35             @expanded = glob ($wild);
36
37             @expanded = grep {ignore_query($_);}  @expanded;
38             
39             print $1 . join (' ', @expanded) . $3 . "\n";
40         } else {
41             print $line;
42         }
43 }
44
45
46 print "\$(srcdir)/Makefile.am: \$(srcdir)/Makefile.am.wild\n" .
47 #    "\t\$(PERL) $my_topsrcdir/bin/wild-perl --top-srcdir=\"\$(real_topsrcdir)\" < \$< > \$@";
48     "\t\$(PERL) $my_topsrcdir/bin/wild-perl < \$< > \$@\n";
49