s3-printing: move driver_info_ctr_to_info8 to init_spoolss.h
[Samba.git] / source4 / heimdal_build / asn1_deps.pl
blob26be254f1430aeb6e45bb1bc796d2cbc2365d518
1 #!/usr/bin/perl
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
6 # GPL
8 use File::Basename;
10 my $file = shift;
11 my $prefix = shift;
12 my $dirname = shift;
13 my $options = join(' ', @ARGV);
14 my $import;
15 my @imports = ();
16 my $dep;
17 my @deps = ();
19 $basename = basename($file);
20 if (not defined $options) {
21 $options = "";
24 my $header = "$dirname/$prefix.h";
25 my $headerx = "$dirname/$prefix.hx";
26 my $headerpriv = "$dirname/$prefix-priv.h";
27 my $headerprivx = "$dirname/$prefix-priv.hx";
28 my $o_file = "$dirname/asn1_$prefix.o";
29 my $c_file = "$dirname/asn1_$prefix.c";
30 my $x_file = "$dirname/asn1_$prefix.x";
31 my $output_file = "$dirname/" . $prefix . "_asn1_files";
33 print "basics:: $header\n";
34 print "$output_file: \$(heimdalsrcdir)/$file \$(ASN1C)\n";
35 print "\t\@echo \"Compiling ASN1 file \$(heimdalsrcdir)/$file\"\n";
36 print "\t\@\$(heimdalbuildsrcdir)/asn1_compile_wrapper.sh \$(builddir) $dirname \$(ASN1C) \$(call abspath,\$(heimdalsrcdir)/$file) $prefix $options --one-code-file && touch $output_file\n";
37 print "$headerx: $output_file\n";
38 print "$header: $headerx\n";
39 print "\t\@cp $headerx $header\n";
40 print "$headerpriv: $headerprivx\n";
41 print "\t\@cp $headerprivx $headerpriv\n";
42 print "$x_file: $header $headerpriv\n";
43 print "$c_file: $x_file\n";
44 print "\t\@echo \"#include \\\"config.h\\\"\" > $c_file && cat $x_file >> $c_file\n\n";
46 open(IN,"heimdal/$file") or die("Can't open heimdal/$file: $!");
47 my @lines = <IN>;
48 close(IN);
49 foreach my $line (@lines) {
50 if ($line =~ /^(\s*IMPORT)([\w\,\s])*(\s+FROM\s+)([\w]+[\w\-]+);/) {
51 $import = $line;
52 chomp $import;
53 push @imports, $import;
54 $import = undef;
55 } elsif ($line =~ /^(\s*IMPORT).*/) {
56 $import = $line;
57 chomp $import;
58 } elsif (defined($import) and ($line =~ /;/)) {
59 $import .= $line;
60 chomp $import;
61 push @imports, $import;
62 $import = undef;
63 } elsif (defined($import)) {
64 $import .= $line;
65 chomp $import;
69 foreach $import (@imports) {
70 next unless ($import =~ /^(\s*IMPORT)([\w\,\s])*(\s+FROM\s+)([\w]+[\w\-]+);/);
72 my @froms = split (/\s+FROM\s+/, $import);
73 foreach my $from (@froms) {
74 next if ($from =~ /^(\s*IMPORT).*/);
75 if ($from =~ /^(\w+)/) {
76 my $f = $1;
77 $dep = 'HEIMDAL_'.uc($f).'_ASN1';
78 push @deps, $dep;
83 unshift @deps, "HEIMDAL_HEIM_ASN1" unless grep /HEIMDAL_HEIM_ASN1/, @deps;
84 my $depstr = join(' ', @deps);
86 print '[SUBSYSTEM::HEIMDAL_'.uc($prefix).']'."\n";
87 print "CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -I$dirname\n";
88 print "PUBLIC_DEPENDENCIES = $depstr\n\n";
90 print "HEIMDAL_".uc($prefix)."_OBJ_FILES = ";
91 print "\\\n\t$o_file";
93 print "\n\n";
95 print "clean:: \n";
96 print "\t\@echo \"Deleting ASN1 output files generated from $file\"\n";
97 print "\t\@rm -f $output_file\n";
98 print "\t\@rm -f $header\n";
99 print "\t\@rm -f $c_file\n";
100 print "\t\@rm -f $x_file\n";
101 print "\t\@rm -f $dirname/$prefix\_files\n";
102 print "\t\@rm -f $dirname/$prefix\.h\n";
103 print "\n";