2 # Generate make dependency rules for asn1 files
3 # Jelmer Vernooij <jelmer@samba.org> 2005
4 # Stefan Metzmacher <metze@samba.org> 2007
12 my $options = join(' ', @ARGV);
24 $basename = basename($file);
25 if (not defined $options) {
29 my $header = "$dirname/$prefix.h";
31 print "$header: $file bin/asn1_compile\n";
32 print "\t\@echo \"Compiling ASN1 file $file\"\n";
33 print "\t\@\$(builddir)/heimdal_build/asn1_compile_wrapper.sh \$(srcdir) \$(builddir) $dirname bin/asn1_compile $file $prefix $options\n\n";
35 open(IN,$file) or die("Can't open $file: $!");
38 foreach my $line (@lines) {
39 if ($line =~ /^([\w]+[\w\-]+)(\s+OBJECT IDENTIFIER)?\s*::=/) {
42 $c_file = "$dirname/asn1_$output.c";
43 $x_file = "$dirname/asn1_$output.x";
44 $o_file = "$dirname/asn1_$output.o";
45 print "$x_file: $header\n";
46 print "$c_file: $dirname/asn1_$output.x\n";
47 print "\t\@cp $x_file $c_file\n\n";
48 push @x_files, $x_file;
49 push @c_files, $c_file;
50 push @o_files, $o_file;
51 } elsif ($line =~ /^(\s*IMPORT)([\w\,\s])*(\s+FROM\s+)([\w]+[\w\-]+);/) {
54 push @imports, $import;
56 } elsif ($line =~ /^(\s*IMPORT).*/) {
59 } elsif (defined($import) and ($line =~ /;/)) {
62 push @imports, $import;
64 } elsif (defined($import)) {
70 foreach $import (@imports) {
71 next unless ($import =~ /^(\s*IMPORT)([\w\,\s])*(\s+FROM\s+)([\w]+[\w\-]+);/);
73 my @froms = split (/\s+FROM\s+/, $import);
74 foreach my $from (@froms) {
75 next if ($from =~ /^(\s*IMPORT).*/);
76 if ($from =~ /^(\w+)/) {
78 $dep = 'HEIMDAL_'.uc($f).'_ASN1';
84 unshift @deps, "HEIMDAL_HEIM_ASN1" unless grep /HEIMDAL_HEIM_ASN1/, @deps;
85 my $depstr = join(' ', @deps);
87 print '[SUBSYSTEM::HEIMDAL_'.uc($prefix).']'."\n";
88 print "CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -I$dirname\n";
90 foreach $o_file (@o_files) {
91 print "\\\n\t$o_file";
93 print "\nPUBLIC_DEPENDENCIES = $depstr\n\n";
96 print "\t\@echo \"Deleting ASN1 output files generated from $file\"\n";
97 print "\t\@rm -f $header\n";
98 foreach $c_file (@c_files) {
99 print "\t\@rm -f $c_file\n";
101 foreach $x_file (@x_files) {
102 print "\t\@rm -f $x_file\n";
104 print "\t\@rm -f $dirname/$prefix\_files\n";
105 print "\t\@rm -f $dirname/$prefix\.h\n";