svn commit: samba r12520 - in branches/SAMBA_4_0/source: . build/smb_build script

jelmer at samba.org jelmer at samba.org
Tue Dec 27 20:29:20 GMT 2005


Author: jelmer
Date: 2005-12-27 20:29:19 +0000 (Tue, 27 Dec 2005)
New Revision: 12520

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=12520

Log:
Add support for --help to mkproto.pl
Allow the use of {PRIVATE,PUBLIC}_PROTO_HEADER for [SUBSYSTEM]
and [LIBRARY] sections in .mk files. Public functions can be marked 
by adding _PUBLIC_ between their return type and function name.

This should eventually make include/proto.h and include/structs.h obsolete.

Modified:
   branches/SAMBA_4_0/source/build/smb_build/config_mk.pm
   branches/SAMBA_4_0/source/build/smb_build/input.pm
   branches/SAMBA_4_0/source/build/smb_build/main.pl
   branches/SAMBA_4_0/source/build/smb_build/makefile.pm
   branches/SAMBA_4_0/source/main.mk
   branches/SAMBA_4_0/source/script/mkproto.pl


Changeset:
Modified: branches/SAMBA_4_0/source/build/smb_build/config_mk.pm
===================================================================
--- branches/SAMBA_4_0/source/build/smb_build/config_mk.pm	2005-12-27 20:20:03 UTC (rev 12519)
+++ branches/SAMBA_4_0/source/build/smb_build/config_mk.pm	2005-12-27 20:29:19 UTC (rev 12520)
@@ -29,6 +29,9 @@
 		"NOPROTO"		=> "bool",
 
 		"MANPAGE"		=> "string",
+
+		"PUBLIC_PROTO_HEADER" => "string",
+		"PRIVATE_PROTO_HEADER" => "string"
 		},
 	"MODULE" => {
 		"SUBSYSTEM"		=> "string",
@@ -71,7 +74,10 @@
 
 		"MANPAGE"		=> "string",
 
-		"PUBLIC_HEADERS" => "list"
+		"PUBLIC_HEADERS" => "list",
+
+		"PUBLIC_PROTO_HEADER" => "string",
+		"PRIVATE_PROTO_HEADER" => "string"
 		}
 };
 

Modified: branches/SAMBA_4_0/source/build/smb_build/input.pm
===================================================================
--- branches/SAMBA_4_0/source/build/smb_build/input.pm	2005-12-27 20:20:03 UTC (rev 12519)
+++ branches/SAMBA_4_0/source/build/smb_build/input.pm	2005-12-27 20:29:19 UTC (rev 12520)
@@ -140,6 +140,11 @@
 			$part->{NOPROTO} = "NO";
 		}
 
+		if (defined($part->{PRIVATE_PROTO_HEADER}) or 
+			defined($part->{PUBLIC_PROTO_HEADER})) {
+			$part->{NOPROTO} = "YES";
+		}
+
 		if (defined($enabled->{$part->{NAME}})) { 
 			$part->{ENABLE} = $enabled->{$part->{NAME}};
 			next;

Modified: branches/SAMBA_4_0/source/build/smb_build/main.pl
===================================================================
--- branches/SAMBA_4_0/source/build/smb_build/main.pl	2005-12-27 20:20:03 UTC (rev 12519)
+++ branches/SAMBA_4_0/source/build/smb_build/main.pl	2005-12-27 20:29:19 UTC (rev 12520)
@@ -74,6 +74,8 @@
 	$mkenv->Binary($key) if $key->{OUTPUT_TYPE} eq "BINARY";
 	$mkenv->Manpage($key) if defined($key->{MANPAGE});
 	$mkenv->Header($key) if defined($key->{PUBLIC_HEADERS});
+	$mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER});
+
 }
 
 $mkenv->write("Makefile");

Modified: branches/SAMBA_4_0/source/build/smb_build/makefile.pm
===================================================================
--- branches/SAMBA_4_0/source/build/smb_build/makefile.pm	2005-12-27 20:20:03 UTC (rev 12519)
+++ branches/SAMBA_4_0/source/build/smb_build/makefile.pm	2005-12-27 20:29:19 UTC (rev 12520)
@@ -425,9 +425,9 @@
 	my ($self,$ctx) = @_;
 
 	my $dir = $ctx->{BASEDIR};
+	
+	$ctx->{BASEDIR} =~ s/^\.\///g;
 
-	$dir =~ s/^\.\///g;
-
 	push (@{$self->{manpages}}, "$dir/$ctx->{MANPAGE}");
 }
 
@@ -463,7 +463,21 @@
 {
 	my ($self,$ctx) = @_;
 
-	$self->_prepare_list($ctx, "OBJ_LIST");
+	my $dir = $ctx->{BASEDIR};
+	$ctx->{BASEDIR} =~ s/^\.\///g;
+
+	my $comment = "";
+	my $target = "$dir/$ctx->{PRIVATE_PROTO_HEADER}";
+	if (defined($ctx->{PUBLIC_PROTO_HEADER})) {
+		$comment.= " and $dir/$ctx->{PRIVATE_PROTO_HEADER}";
+	} else {
+		$ctx->{PUBLIC_PROTO_HEADER} = $ctx->{PRIVATE_PROTO_HEADER};
+	}	
+
+	$self->output("$target: \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST:.o=.c)\n");
+	$self->output("\t\@echo \"Creating $dir/$ctx->{PRIVATE_PROTO_HEADER}$comment\"\n");
+
+	$self->output("\t\@\$(PERL) \${srcdir}/script/mkproto.pl --private=$dir/$ctx->{PRIVATE_PROTO_HEADER} --public=$dir/$ctx->{PUBLIC_PROTO_HEADER} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n\n");
 }
 
 sub write($$)
@@ -479,9 +493,8 @@
 	$self->output("PUBLIC_HEADERS = " . array2oneperline($self->{headers}) . "\n");
 	$self->output("PC_FILES = " . array2oneperline($self->{pc_files}) . "\n");
 	$self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
-	$self->output("PROTO_OBJS = " . array2oneperline($self->{proto_objs}) . "\n");
+	$self->output("PROTO_OBJS = " . array2oneperline($self->{proto_objs}) .  "\n");
 
-
 	$self->_prepare_mk_files();
 
 	if ($self->{developer}) {

Modified: branches/SAMBA_4_0/source/main.mk
===================================================================
--- branches/SAMBA_4_0/source/main.mk	2005-12-27 20:20:03 UTC (rev 12519)
+++ branches/SAMBA_4_0/source/main.mk	2005-12-27 20:29:19 UTC (rev 12520)
@@ -198,18 +198,21 @@
 	@/bin/false
 
 include/proto.h: $(PROTO_OBJS:.o=.c)
-	@-rm -f include/includes.h.gch
 	@echo "Creating include/proto.h"
 	@$(PERL) script/mkproto.pl --public-define=_PROTO_H_ \
 		--public=include/proto.h --private=include/proto.h \
 		$(PROTO_OBJS)
 
 proto: include/proto.h
+
 pch: include/config.h \
 	include/proto.h \
 	idl \
 	include/includes.h.gch
 
+clean_pch: 
+	-rm -f include/includes.h.gch
+
 basics: include/config.h \
 	include/proto.h \
 	idl \

Modified: branches/SAMBA_4_0/source/script/mkproto.pl
===================================================================
--- branches/SAMBA_4_0/source/script/mkproto.pl	2005-12-27 20:20:03 UTC (rev 12519)
+++ branches/SAMBA_4_0/source/script/mkproto.pl	2005-12-27 20:29:19 UTC (rev 12520)
@@ -15,6 +15,19 @@
 my $public_fd = \*STDOUT;
 my $private_fd = \*STDOUT;
 
+sub usage()
+{
+	print "Usage: mkproto.pl [options] [c files]\n";
+	print "OPTIONS:\n";
+	print "  --public=FILE          Write prototypes for public functions to FILE\n";
+	print "  --private=FILE         Write prototypes for private functions to FILE\n";
+	print "  --define=DEF           Use DEF to check whether header was already included\n";
+	print "  --public-define=DEF    Same as --define, but just for public header\n";
+	print "  --private-define=DEF   Same as --define, but just for private header\n";
+	print "  --help                 Print this help message\n\n";
+	exit 0;
+}
+
 GetOptions(
 	'public=s' => sub { my ($f,$v) = @_; $public_file = $v; },
 	'private=s' => sub { my ($f,$v) = @_; $private_file = $v; },
@@ -24,18 +37,19 @@
 		$private_define = "$v\_PRIVATE"; 
 	},
 	'public-define=s' => \$public_define,
-	'private-define=s' => \$private_define
-);
+	'private-define=s' => \$private_define,
+	'help' => \&usage
+) or exit(1);
 
 if (not defined($public_define) and defined($public_file)) {
-	$public_define = $public_file;
+	$public_define = ".." . uc($public_file) . "__";
 	$public_define =~ tr{./}{__};
 } elsif (not defined($public_define)) {
 	$public_define = '_PROTO_H_';
 }
 
 if (not defined($private_define) and defined($private_file)) {
-	$private_define = $private_file;
+	$private_define = "__" . uc($private_file) . "__";
 	$private_define =~ tr{./}{__};
 } elsif (not defined($public_define)) {
 	$public_define = '_PROTO_H_';
@@ -48,7 +62,7 @@
 
 if ($private_file eq $public_file) {
 	$private_fd = $public_fd;
-} elsif (not defined($private_file)) {
+} elsif (defined($private_file)) {
 	open PRIVATE, ">$private_file"; 
 	$private_fd = \*PRIVATE;
 }
@@ -58,7 +72,7 @@
 	my ($file, $header_name) = @_;
 	print $file "#ifndef $header_name\n";
 	print $file "#define $header_name\n\n";
-	print $file "/* This file is automatically generated with \"make proto\". DO NOT EDIT */\n\n";
+	print $file "/* This file was automatically generated by mkproto.pl. DO NOT EDIT */\n\n";
 }
 
 sub print_footer($$) 
@@ -153,10 +167,17 @@
 	close(FH);
 }
 
+print_header($public_fd, $public_define);
 if ($public_file ne $private_file) {
 	print_header($private_fd, $private_define);
+
+	print $private_fd "/* this file contains prototypes for functions that " .
+			"are private \n * to this subsystem or library. These functions " .
+			"should not be \n * used outside this particular subsystem! */\n\n";
+
+	print $public_fd "/* this file contains prototypes for functions that " . 
+			"are part of \n * the public API of this subsystem or library. */\n\n";
 }
-print_header($public_fd, $public_define);
 process_file($public_fd, $private_fd, $_) foreach (@ARGV);
 print_footer($public_fd, $public_define);
 if ($public_file ne $private_file) {



More information about the samba-cvs mailing list