2 # Generate make dependency rules for asn1 files
3 # Jelmer Vernooij <jelmer@samba.org> 2005
4 # Andrew Bartlett <abartlet@samba.org> 2006
5 # Stefan Metzmacher <metze@samba.org> 2007
13 my $options = join(' ', @ARGV);
25 $basename = basename($file);
26 if (not defined $options) {
30 my $header = "$dirname/$prefix.h";
31 my $headerx = "$dirname/$prefix.hx";
33 print "basics:: $header\n";
34 print "$header: $headerx\n";
35 print "\t\@cp $headerx $header\n";
36 print "$headerx: \$(heimdalsrcdir)/$file \$(ASN1C)\n";
37 print "\t\@echo \"Compiling ASN1 file \$(heimdalsrcdir)/$file\"\n";
38 print "\t\@\$(heimdalbuildsrcdir)/asn1_compile_wrapper.sh \$(builddir) $dirname \$(ASN1C) \$(call abspath,\$(heimdalsrcdir)/$file) $prefix $options\n\n";
40 open(IN,"heimdal/$file") or die("Can't open heimdal/$file: $!");
43 foreach my $line (@lines) {
44 if ($line =~ /^([\w]+[\w\-]+)(\s+OBJECT IDENTIFIER)?\s*::=/) {
47 $c_file = "$dirname/asn1_$output.c";
48 $x_file = "$dirname/asn1_$output.x";
49 $o_file = "$dirname/asn1_$output.o";
50 print "$x_file: $header\n";
51 print "$c_file: $dirname/asn1_$output.x\n";
52 print "\t\@echo \"#include \\\"config.h\\\"\" > $c_file && cat $x_file >> $c_file\n\n";
53 push @x_files, $x_file;
54 push @c_files, $c_file;
55 push @o_files, $o_file;
56 } elsif ($line =~ /^(\s*IMPORT)([\w\,\s])*(\s+FROM\s+)([\w]+[\w\-]+);/) {
59 push @imports, $import;
61 } elsif ($line =~ /^(\s*IMPORT).*/) {
64 } elsif (defined($import) and ($line =~ /;/)) {
67 push @imports, $import;
69 } elsif (defined($import)) {
75 foreach $import (@imports) {
76 next unless ($import =~ /^(\s*IMPORT)([\w\,\s])*(\s+FROM\s+)([\w]+[\w\-]+);/);
78 my @froms = split (/\s+FROM\s+/, $import);
79 foreach my $from (@froms) {
80 next if ($from =~ /^(\s*IMPORT).*/);
81 if ($from =~ /^(\w+)/) {
83 $dep = 'HEIMDAL_'.uc($f).'_ASN1';
89 unshift @deps, "HEIMDAL_HEIM_ASN1" unless grep /HEIMDAL_HEIM_ASN1/, @deps;
90 my $depstr = join(' ', @deps);
92 print '[SUBSYSTEM::HEIMDAL_'.uc($prefix).']'."\n";
93 print "CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -I$dirname\n";
94 print "PUBLIC_DEPENDENCIES = $depstr\n\n";
96 print "HEIMDAL_".uc($prefix)."_OBJ_FILES = ";
97 foreach $o_file (@o_files) {
98 print "\\\n\t$o_file";
104 print "\t\@echo \"Deleting ASN1 output files generated from $file\"\n";
105 print "\t\@rm -f $header\n";
106 foreach $c_file (@c_files) {
107 print "\t\@rm -f $c_file\n";
109 foreach $x_file (@x_files) {
110 print "\t\@rm -f $x_file\n";
112 print "\t\@rm -f $dirname/$prefix\_files\n";
113 print "\t\@rm -f $dirname/$prefix\.h\n";