1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-29 21:47:30 +03:00
Jelmer Vernooij 0020793515 Fix static module list generation for ldb.
(This used to be commit 92c1c0e9137f0845cac6cc96bf78711b6aaffe21)
2008-02-20 03:40:44 +01:00

93 lines
1.9 KiB
Perl

# SMB Build System
# - create output for build.h
#
# Copyright (C) Stefan (metze) Metzmacher 2004
# Copyright (C) Jelmer Vernooij 2005
# 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 "MODULE" and
$key->{TYPE} ne "SUBSYSTEM" and
$key->{TYPE} ne "BINARY");
next unless defined($key->{INIT_FUNCTIONS});
my $name = $key->{NAME};
$name =~ s/-/_/g;
$DEFINE->{COMMENT} = "$key->{TYPE} $key->{NAME} INIT";
$DEFINE->{KEY} = "STATIC_$name\_MODULES";
$DEFINE->{VAL} = "\\\n";
foreach (@{$key->{INIT_FUNCTIONS}}) {
$DEFINE->{VAL} .= "\t$_, \\\n";
unless (/{/) {
my $fn = $key->{INIT_FUNCTION_TYPE};
my $n = $_;
if ($fn =~ /\(\*\)/) {
$fn =~ s/\(\*\)/$n/;
$output .= "$fn;\n";
} else {
$n =~ s/\&//;
$output .= "$fn $n;\n";
}
}
}
$DEFINE->{VAL} .= "\t$key->{INIT_FUNCTION_SENTINEL} \n";
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;