2 # Generate make dependency rules for asn1 files
3 # Jelmer Vernooij <jelmer@samba.org> 2005
4 # Andrew Bartlett <abartlet@samba.org> 2006-2009
5 # Stefan Metzmacher <metze@samba.org> 2007
13 my $options = join(' ', @ARGV);
19 $basename = basename
($file);
20 if (not defined $options) {
24 my $header = "$dirname/$prefix.h";
25 my $headerx = "$dirname/$prefix.hx";
26 my $o_file = "$dirname/asn1_$prefix.o";
27 my $c_file = "$dirname/asn1_$prefix.c";
28 my $x_file = "$dirname/asn1_$prefix.x";
29 my $output_file = "$dirname/" . $prefix . "_asn1_files";
31 print "basics:: $header\n";
32 print "$output_file: \$(heimdalsrcdir)/$file \$(ASN1C)\n";
33 print "\t\@echo \"Compiling ASN1 file \$(heimdalsrcdir)/$file\"\n";
34 print "\t\@\$(heimdalbuildsrcdir)/asn1_compile_wrapper.sh \$(builddir) $dirname \$(ASN1C) \$(call abspath,\$(heimdalsrcdir)/$file) $prefix $options --one-code-file && touch $output_file\n";
35 print "$headerx: $output_file\n";
36 print "$header: $headerx\n";
37 print "\t\@cp $headerx $header\n";
38 print "$x_file: $header\n";
39 print "$c_file: $x_file\n";
40 print "\t\@echo \"#include \\\"config.h\\\"\" > $c_file && cat $x_file >> $c_file\n\n";
42 open(IN
,"heimdal/$file") or die("Can't open heimdal/$file: $!");
45 foreach my $line (@lines) {
46 if ($line =~ /^(\s*IMPORT)([\w\,\s])*(\s+FROM\s+)([\w]+[\w\-]+);/) {
49 push @imports, $import;
51 } elsif ($line =~ /^(\s*IMPORT).*/) {
54 } elsif (defined($import) and ($line =~ /;/)) {
57 push @imports, $import;
59 } elsif (defined($import)) {
65 foreach $import (@imports) {
66 next unless ($import =~ /^(\s*IMPORT)([\w\,\s])*(\s+FROM\s+)([\w]+[\w\-]+);/);
68 my @froms = split (/\s+FROM\s+/, $import);
69 foreach my $from (@froms) {
70 next if ($from =~ /^(\s*IMPORT).*/);
71 if ($from =~ /^(\w+)/) {
73 $dep = 'HEIMDAL_'.uc($f).'_ASN1';
79 unshift @deps, "HEIMDAL_HEIM_ASN1" unless grep /HEIMDAL_HEIM_ASN1/, @deps;
80 my $depstr = join(' ', @deps);
82 print '[SUBSYSTEM::HEIMDAL_'.uc($prefix).']'."\n";
83 print "CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -I$dirname\n";
84 print "PUBLIC_DEPENDENCIES = $depstr\n\n";
86 print "HEIMDAL_".uc($prefix)."_OBJ_FILES = ";
87 print "\\\n\t$o_file";
92 print "\t\@echo \"Deleting ASN1 output files generated from $file\"\n";
93 print "\t\@rm -f $output_file\n";
94 print "\t\@rm -f $header\n";
95 print "\t\@rm -f $c_file\n";
96 print "\t\@rm -f $x_file\n";
97 print "\t\@rm -f $dirname/$prefix\_files\n";
98 print "\t\@rm -f $dirname/$prefix\.h\n";