summaryrefslogtreecommitdiff
path: root/source4/build/smb_build/input.pl
blob: 91ce42bdc865b89c906b26af8d440424e742a3b2 (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
134
135
136
137
138
139
###########################################################
### SMB Build System					###
### - the input checking functions			###
###							###
###  Copyright (C) Stefan (metze) Metzmacher 2004	###
###  Released under the GNU GPL				###
###########################################################

sub strtrim($)
{
	my $str = shift;
	my @ar = ();

	$str =~ s/^[\t\n ]*//g;

	$str =~ s/[\t\n ]*$//g;

	return $str;
}

sub str2array($)
{
	my $str = shift;
	my @ar = ();

	$str =~ s/^[\t\n ]*//g;

	$str =~ s/[\t\n ]*$//g;

	$str =~ s/([\t\n ]+)/ /g;

	if (length($str)==0) {
		return ();
	}

	@ar = split(/[ \t\n]/,$str);

	return @ar;
}

sub _check_subsystems($)
{
	my $CTX = shift;

	foreach my $subsys (sort keys %{$CTX->{INPUT}{SUBSYSTEMS}}) {
		if ($CTX->{INPUT}{SUBSYSTEMS}{$subsys}{ENABLE} ne "YES") {
			printf("Subsystem: %s disabled!\n",$CTX->{INPUT}{SUBSYSTEMS}{$subsys}{NAME});
			next;
		}
	}

	return;
}

sub _check_modules($)
{
	my $CTX = shift;
	
	foreach my $mod (sort keys %{$CTX->{INPUT}{MODULES}}) {
		my $subsys = $CTX->{INPUT}{MODULES}{$mod}{SUBSYSTEM};
		my $default_build = $CTX->{INPUT}{MODULES}{$mod}{DEFAULT_BUILD};
		my $build = $CTX->{INPUT}{MODULES}{$mod}{CHOSEN_BUILD};
		my $use_default = 0;

		if (!(defined($CTX->{INPUT}{SUBSYSTEMS}{$subsys}))) {
			$CTX->{INPUT}{MODULES}{$mod}{BUILD} = "NOT";
			printf("Module: %s...PARENT SUBSYSTEM DISABLED\n",$mod);
			next;
		}

		if ($build eq "DEFAULT") {
			$build = $default_build;
			$use_default = 1;
		}

		if ($build eq "SHARED") {
			$CTX->{INPUT}{MODULES}{$mod}{BUILD} = "SHARED";
			printf("Module: %s...SHARED\n",$mod);
		} elsif ($build eq "STATIC") {
			$CTX->{INPUT}{MODULES}{$mod}{BUILD} = "STATIC";
			printf("Module: %s...STATIC\n",$mod);
		} else {
			$CTX->{INPUT}{MODULES}{$mod}{BUILD} = "NOT";
			printf("Module: %s...NOT\n",$mod);
			next;
		}
	}

	return;
}

sub _check_libraries($)
{
	my $CTX = shift;

	foreach my $lib (sort keys %{$CTX->{INPUT}{LIBRARIES}}) {
		if ($CTX->{INPUT}{LIBRARIES}{$lib}{ENABLE} ne "YES") {
			printf("Library: %s disabled!\n",$CTX->{INPUT}{LIBRARIES}{$lib}{NAME});
			next;
		}
	}

	return;
}

sub _check_binaries($)
{
	my $CTX = shift;

	foreach my $bin (sort keys %{$CTX->{INPUT}{BINARIES}}) {
		if ($CTX->{INPUT}{BINARIES}{$bin}{ENABLE} ne "YES") {
			printf("Binary: %s disabled!\n",$CTX->{INPUT}{BINARIES}{$bin}{NAME});
			next;
		}
	}

	return;
}

###########################################################
# This function checks the input from the configure script 
#
# check_input($SMB_BUILD_CTX)
#
# $SMB_BUILD_CTX -	the global SMB_BUILD context
sub check_input($)
{
	my $CTX = shift;

	_check_subsystems($CTX);

	_check_modules($CTX);

	_check_libraries($CTX);

	_check_binaries($CTX);

	return;
}