s3: Make TLDAP_IS_ALPHA and TLDAP_IS_ADH static functions
[Samba/kamenim.git] / source4 / heimdal_build / asn1_deps.pl
blobb71abc72c51f200e61ec011640fbf012e9a08a48
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 $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: $!");
43 my @lines = <IN>;
44 close(IN);
45 foreach my $line (@lines) {
46 if ($line =~ /^(\s*IMPORT)([\w\,\s])*(\s+FROM\s+)([\w]+[\w\-]+);/) {
47 $import = $line;
48 chomp $import;
49 push @imports, $import;
50 $import = undef;
51 } elsif ($line =~ /^(\s*IMPORT).*/) {
52 $import = $line;
53 chomp $import;
54 } elsif (defined($import) and ($line =~ /;/)) {
55 $import .= $line;
56 chomp $import;
57 push @imports, $import;
58 $import = undef;
59 } elsif (defined($import)) {
60 $import .= $line;
61 chomp $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+)/) {
72 my $f = $1;
73 $dep = 'HEIMDAL_'.uc($f).'_ASN1';
74 push @deps, $dep;
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";
89 print "\n\n";
91 print "clean:: \n";
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";
99 print "\n";