summaryrefslogtreecommitdiff
path: root/source4/build/smb_build/smb_build_h.pm
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-11-12 01:40:02 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:44 -0500
commitab440ac6f75c12989d5dc15cc75a99e62f35612f (patch)
tree15375ecfbeee53132b2298aa697e9eead69ed3a4 /source4/build/smb_build/smb_build_h.pm
parent79c5d73a71c35f5b16232072a7b52033cb9364cb (diff)
downloadsamba-ab440ac6f75c12989d5dc15cc75a99e62f35612f.tar.gz
samba-ab440ac6f75c12989d5dc15cc75a99e62f35612f.tar.bz2
samba-ab440ac6f75c12989d5dc15cc75a99e62f35612f.zip
r3690: Use perl's 'use' statement to include the build system parts
rather then using "cat" (This used to be commit 4d018b2b701faa56d7e3bb7634729296b53e0acb)
Diffstat (limited to 'source4/build/smb_build/smb_build_h.pm')
-rw-r--r--source4/build/smb_build/smb_build_h.pm133
1 files changed, 133 insertions, 0 deletions
diff --git a/source4/build/smb_build/smb_build_h.pm b/source4/build/smb_build/smb_build_h.pm
new file mode 100644
index 0000000000..bc12b9a268
--- /dev/null
+++ b/source4/build/smb_build/smb_build_h.pm
@@ -0,0 +1,133 @@
+###########################################################
+### SMB Build System ###
+### - create output for smb_build.h ###
+### ###
+### Copyright (C) Stefan (metze) Metzmacher 2004 ###
+### Released under the GNU GPL ###
+###########################################################
+
+sub _add_define_section($)
+{
+ my $DEFINE = shift;
+ my $output = "";
+
+ $output .= "
+/* $DEFINE->{COMMENT} */
+#define $DEFINE->{KEY} $DEFINE->{VAL}
+";
+
+ return $output;
+}
+
+sub _prepare_smb_build_h($)
+{
+ my $CTX = shift;
+ my $output = "";
+
+ #
+ # loop over all subsystems
+ #
+ foreach my $key (sort keys %{$CTX->{DEPEND}{SUBSYSTEMS}}) {
+ my $NAME = $CTX->{INPUT}{SUBSYSTEMS}{$key}{NAME};
+ my $DEFINE = ();
+ my $name = lc($NAME);
+
+ #
+ # Static modules
+ #
+ $DEFINE->{COMMENT} = "SUBSYSTEM $NAME INIT";
+ $DEFINE->{KEY} = $name . "_init_static_modules";
+ $DEFINE->{VAL} = "do { \\\n";
+ foreach my $subkey (@{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{INIT_FUNCTIONS}}) {
+ $DEFINE->{VAL} .= "\t\textern NTSTATUS $subkey(void); \\\n";
+ }
+
+ foreach my $subkey (@{$CTX->{DEPEND}{SUBSYSTEMS}{$key}{INIT_FUNCTIONS}}) {
+ $DEFINE->{VAL} .= "\t\t$subkey(); \\\n";
+ }
+ $DEFINE->{VAL} .= "\t} while(0)";
+
+ push(@{$CTX->{OUTPUT}{SMB_BUILD_H}},$DEFINE);
+ }
+
+ #
+ # loop over all binaries
+ #
+ foreach my $key (sort keys %{$CTX->{DEPEND}{BINARIES}}) {
+ my $NAME = $CTX->{INPUT}{BINARIES}{$key}{NAME};
+ my $DEFINE = ();
+ my $name = lc($NAME);
+
+ #
+ # Static modules
+ #
+ $DEFINE->{COMMENT} = "BINARY $NAME INIT";
+ $DEFINE->{KEY} = $name . "_init_subsystems";
+ $DEFINE->{VAL} = "do { \\\n";
+ foreach my $subkey (@{$CTX->{DEPEND}{BINARIES}{$key}{INIT_FUNCTIONS}}) {
+ $DEFINE->{VAL} .= "\t\tif (NT_STATUS_IS_ERR($subkey())) exit(1); \\\n";
+ }
+ $DEFINE->{VAL} .= "\t} while(0)";
+
+ push(@{$CTX->{OUTPUT}{SMB_BUILD_H}},$DEFINE);
+ }
+
+ #
+ # Shared modules
+ #
+ foreach my $key (sort keys %{$CTX->{INPUT}{MODULES}}) {
+ next if ($CTX->{INPUT}{MODULES}{$key}{BUILD} ne "SHARED");
+
+ my $name = $CTX->{INPUT}{MODULES}{$key}{NAME};
+ my $func = $CTX->{INPUT}{MODULES}{$key}{INIT_FUNCTION};
+ next if $func eq "";
+
+ my $DEFINE = ();
+
+ $DEFINE->{COMMENT} = "$name is built shared";
+ $DEFINE->{KEY} = $func;
+ $DEFINE->{VAL} = "init_module";
+
+ push(@{$CTX->{OUTPUT}{SMB_BUILD_H}},$DEFINE);
+ }
+
+ #
+ # loop over all SMB_BUILD_H define sections
+ #
+ foreach my $key (@{$CTX->{OUTPUT}{SMB_BUILD_H}}) {
+ $output .= _add_define_section($key);
+ }
+
+ return $output;
+}
+
+###########################################################
+# This function creates include/smb_build.h from the SMB_BUILD
+# context
+#
+# create_smb_build_h($SMB_BUILD_CTX)
+#
+# $SMB_BUILD_CTX - the global SMB_BUILD context
+#
+# $output - the resulting output buffer
+sub create_smb_build_h($)
+{
+ my $CTX = shift;
+ my $output = "/* autogenerated by config.smb_build.pl */\n";
+
+ $output .= _prepare_smb_build_h($CTX);
+
+ #
+ # TODO: check if directory include/ exists
+ #
+
+ open(SMB_BUILD_H,"> include/smb_build.h") || die ("Can't open include/smb_build.h\n");
+
+ print SMB_BUILD_H $output;
+
+ close(SMB_BUILD_H);
+
+ print "config.smb_build.pl: creating include/smb_build.h\n";
+ return;
+}
+1;