2005-08-03 09:28:08 +04:00
#!/usr/bin/perl
# Generate make dependency rules for asn1 files
# Jelmer Vernooij <jelmer@samba.org> 2005
# GPL
use File::Basename ;
my $ file = shift ;
my $ prefix = shift ;
2005-08-09 07:04:47 +04:00
my $ options = shift ;
2005-12-20 02:13:12 +03:00
my $ x_file ;
my @ x_files = ( ) ;
my $ c_file ;
my @ c_files = ( ) ;
2005-08-03 09:28:08 +04:00
if ( not defined ( $ prefix ) ) { $ prefix = "asn1" ; }
$ dirname = dirname ( $ file ) ;
$ basename = basename ( $ file ) ;
2005-08-09 07:04:47 +04:00
if ( not defined $ options ) {
$ options = "" ;
}
2005-08-03 09:28:08 +04:00
my $ header = "$dirname/$prefix.h" ;
2006-03-19 18:59:12 +03:00
print "$header: $file bin/asn1_compile\n" ;
2005-08-03 09:28:08 +04:00
print "\t\@echo \"Compiling ASN1 file $file\"\n" ;
2005-08-09 07:04:47 +04:00
print "\t\@cd $dirname && ../../../bin/asn1_compile $options $basename $prefix\n\n" ;
2005-08-03 09:28:08 +04:00
open ( IN , $ file ) or die ( "Can't open $file: $!" ) ;
foreach ( <IN> ) {
if ( /^([A-Za-z0-9_-]+)[ \t]*::= / ) {
my $ output = $ 1 ;
$ output =~ s/-/_/g ;
2005-08-09 02:14:40 +04:00
$ c_file = "$dirname/asn1_$output.c" ;
$ x_file = "$dirname/asn1_$output.x" ;
print "$x_file: $header\n" ;
print "$c_file: $dirname/asn1_$output.x\n" ;
print "\t\@cp $x_file $c_file\n\n" ;
push @ x_files , $ x_file ;
push @ c_files , $ c_file ;
2005-08-03 09:28:08 +04:00
}
}
close ( IN ) ;
2006-03-19 02:51:55 +03:00
print "clean:: \n" ;
2005-08-22 03:56:47 +04:00
print "\t\@echo \"Deleting ASN1 output files generated from $file\"" ;
2005-08-09 02:14:40 +04:00
print "\n\t\@rm -f $header" ;
foreach $ c_file ( @ c_files ) {
print "\n\t\@rm -f $c_file" ;
}
foreach $ x_file ( @ x_files ) {
print "\n\t\@rm -f $x_file" ;
}
2006-01-07 01:55:03 +03:00
print "\n\t\@rm -f $dirname/$prefix\_files" ;
print "\n\t\@rm -f $dirname/$prefix\.h" ;
2005-08-09 02:14:40 +04:00
print "\n\n" ;