Debian Codegraph @

src/scripts/generate-sndfile/generate-sndfile.pl

raw
1 # generate a single header/source pair from libsndfile distribution source
2 # used to create util_sndfile.h/c | author: Ari Lazier c. 2003
3
4 use Data::Dumper;
5 my %seen;
6 my @source;
7
8 my $output = $ARGV[0];
9
10 my @fileList = `ls *.c *.h`;
11 foreach $_ (@fileList)
12 {
13 chomp;
14 if( $_ =~ /$output/ || $_ =~ /test/ ) {}
15 elsif( $_ =~ /\.h/ ) { $seen{$_} = 0; }
16 elsif( $_ =~ /\.c/ ) { push @source, $_ }
17 }
18
19 close DOTH;
20 close DOTC;
21 open DOTH, ">" . $output . ".h" or die;
22 open DOTC, ">" . $output . ".c" or die;
23 my @list;
24 $seen{'config.h'} = 1;
25 push @list, "config.h";
26 $seen{'sndfile.h'} = 1;
27 push @list, "sndfile.h";
28 $seen{'common.h'} = 1;
29 push @list, "common.h";
30 $seen{'G72x.h'} = 1;
31 push @list, "G72x.h";
32
33 sub depend
34 {
35 my $file = shift;
36 my $handle;
37 open $handle, "<$file";
38 while(<$handle>)
39 {
40 if( my $include = /#include[ \t]*[<"]([\w\d]+\.h)[>"]/ )
41 {
42 if( defined( $seen{$include} && $seen{$include} == 0 ) )
43 {
44 depend( $include );
45 }
46 }
47 }
48 close $handle;
49 $seen{$file} = 1;
50 push @list, $file;
51 }
52
53 foreach my $key ( keys %seen )
54 {
55 if( $seen{$key} == 0 ) { depend($key); }
56 }
57
58 print DOTH '#include <stdio.h>' . "\n\n";
59 print DOTH '#include <stdlib.h>' . "\n\n";
60 foreach my $file (@list)
61 {
62 open F, "<$file";
63 while(<F>)
64 {
65 if( $_ !~ /#include[ \t]*[<"](\w+\.h)[>"]/ )
66 {
67 print DOTH $_;
68 }
69 }
70 close F;
71 }
72
73 close FILE;
74
75 print DOTC '#include ' . "\"$output.h\"\n";
76 print DOTC '#include <stdio.h>' . "\n\n";
77 print DOTC '#include <stdlib.h>' . "\n\n";
78 foreach my $file (@source)
79 {
80 open FILE, $file;
81 $file =~ s/\.[ch]//g;
82 while( my $line = <FILE> )
83 {
84 if( $line !~ /#include[ \t]*("[\w\d]+\.[ch]")|<CoreServices.h>/ )
85 {
86 $line =~ s/(f2d_array)/$file$1/g;
87 $line =~ s/(d2f_array)/$file$1/g;
88 $line =~ s/(_\w+tab)/$file$1/g;
89 $line =~ s/(STEP)/$file$1/g;
90 $line =~ s/(HAVE_[^D]\w+)/$file$1/g;
91 print DOTC $line;
92 }
93 }
94 close FILE;
95 }
96
97 close DOTH;
98 close DOTC;
99
100
101