r12750: Clean up more asn1 generated files (pointed out by <HotaruT>).
[jelmer/samba4-debian.git] / source / heimdal_build / asn1_deps.pl
1 #!/usr/bin/perl
2 # Generate make dependency rules for asn1 files
3 # Jelmer Vernooij <jelmer@samba.org> 2005
4 # GPL
5
6 use File::Basename;
7
8 my $file = shift;
9 my $prefix = shift;
10 my $options = shift;
11 my $x_file;
12 my @x_files = ();
13 my $c_file;
14 my @c_files = ();
15 if (not defined ($prefix)) { $prefix = "asn1"; }
16
17 $dirname = dirname($file);
18 $basename = basename($file);
19 if (not defined $options) {
20     $options = "";
21 }
22
23 my $header = "$dirname/$prefix.h";
24
25 print "$header: $file bin/asn1_compile\n";
26 print "\t\@echo \"Compiling ASN1 file $file\"\n";
27 print "\t\@cd $dirname && ../../../bin/asn1_compile $options $basename $prefix\n\n";
28
29 open(IN,$file) or die("Can't open $file: $!");
30 foreach(<IN>) {
31         if (/^([A-Za-z0-9_-]+)[ \t]*::= /) {
32                 my $output = $1;
33                 $output =~ s/-/_/g;
34                 $c_file = "$dirname/asn1_$output.c";
35                 $x_file = "$dirname/asn1_$output.x";
36                 print "$x_file: $header\n";
37                 print "$c_file: $dirname/asn1_$output.x\n";
38                 print "\t\@cp $x_file $c_file\n\n";
39                 push @x_files, $x_file;
40                 push @c_files, $c_file;
41         }
42 }
43 close(IN);
44 print $prefix."_clean: \n";
45 print "\t\@echo \"Deleting ASN1 output files generated from $file\"";
46 print "\n\t\@rm -f $header";
47 foreach $c_file (@c_files) {
48     print "\n\t\@rm -f $c_file";
49 }
50 foreach $x_file (@x_files) {
51     print "\n\t\@rm -f $x_file";
52 }
53 print "\n\t\@rm -f $dirname/$prefix\_files";
54 print "\n\t\@rm -f $dirname/$prefix\.h";
55 print "\n\n";