diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-02-23 12:44:21 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:52:05 -0500 |
commit | d3bcaf66a8568fc19a3013f9dc974fb08ee3a39a (patch) | |
tree | 2c567a9bf3c8f28bc19c546dd0cfad2aa0dc816e /source4/build/smb_build/header.pm | |
parent | 559ba6f12aacf3639ad6268490bc8ed33b1fb803 (diff) | |
download | samba-d3bcaf66a8568fc19a3013f9dc974fb08ee3a39a.tar.gz samba-d3bcaf66a8568fc19a3013f9dc974fb08ee3a39a.tar.bz2 samba-d3bcaf66a8568fc19a3013f9dc974fb08ee3a39a.zip |
r13654: Move some more stuff out of include/
(This used to be commit 2ec7bba03a2edf713004941e9ed74798f5cf8d32)
Diffstat (limited to 'source4/build/smb_build/header.pm')
-rw-r--r-- | source4/build/smb_build/header.pm | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/source4/build/smb_build/header.pm b/source4/build/smb_build/header.pm new file mode 100644 index 0000000000..456c29368a --- /dev/null +++ b/source4/build/smb_build/header.pm @@ -0,0 +1,95 @@ +# SMB Build System +# - create output for build.h +# +# Copyright (C) Stefan (metze) Metzmacher 2004 +# Released under the GNU GPL + +package header; +use strict; + +sub _add_define_section($) +{ + my $DEFINE = shift; + my $output = ""; + + $output .= " +/* $DEFINE->{COMMENT} */ +#define $DEFINE->{KEY} $DEFINE->{VAL} +"; + + return $output; +} + +sub _prepare_build_h($) +{ + my $depend = shift; + my @defines = (); + my $output = ""; + + foreach my $key (values %{$depend}) { + my $DEFINE = (); + next if ($key->{TYPE} ne "LIBRARY" and $key->{TYPE} ne "SUBSYSTEM"); + next unless defined($key->{INIT_FUNCTIONS}); + + $DEFINE->{COMMENT} = "$key->{TYPE} $key->{NAME} INIT"; + $DEFINE->{KEY} = "STATIC_$key->{NAME}_MODULES"; + $DEFINE->{VAL} = "{ \\\n"; + foreach (@{$key->{INIT_FUNCTIONS}}) { + $DEFINE->{VAL} .= "\t$_, \\\n"; + $output .= "NTSTATUS $_(void);\n"; + } + + $DEFINE->{VAL} .= "\tNULL \\\n }"; + + push(@defines,$DEFINE); + } + + # + # Shared modules + # + foreach my $key (values %{$depend}) { + next if $key->{TYPE} ne "MODULE"; + next if $key->{ENABLE} ne "YES"; + next if $key->{OUTPUT_TYPE} ne "SHARED_LIBRARY"; + + my $name = $key->{NAME}; + next if not defined($key->{INIT_FUNCTION}); + + my $DEFINE = (); + + $DEFINE->{COMMENT} = "$name is built shared"; + $DEFINE->{KEY} = $key->{INIT_FUNCTION}; + $DEFINE->{VAL} = "init_module"; + + push(@defines,$DEFINE); + } + + # + # loop over all BUILD_H define sections + # + foreach (@defines) { $output .= _add_define_section($_); } + + return $output; +} + +########################################################### +# This function creates include/build.h from the SMB_BUILD +# context +# +# create_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, $file) = @_; + + open(BUILD_H,">$file") || die ("Can't open `$file'\n"); + print BUILD_H "/* autogenerated by build/smb_build/main.pl */\n"; + print BUILD_H _prepare_build_h($CTX); + close(BUILD_H); + + print __FILE__.": creating $file\n"; +} +1; |