blob: bc12b9a26827814fc119448a906708c773d92215 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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;
|