1 ###########################################################
2 ### SMB Build System ###
3 ### - the input checking functions ###
5 ### Copyright (C) Stefan (metze) Metzmacher 2004 ###
6 ### Copyright (C) Jelmer Vernooij 2004 ###
7 ### Released under the GNU GPL ###
8 ###########################################################
11 package smb_build
::input
;
13 my $subsystem_default_output_type = "OBJLIST";
31 return () if (length($_)==0);
32 return split /[ \t\n]/;
35 sub check_subsystem
($$)
37 my ($INPUT, $subsys) = @_;
38 if ($subsys->{ENABLE
} ne "YES") {
39 printf("Subsystem: %s disabled!\n",$subsys->{NAME
});
43 unless(defined($subsys->{OUTPUT_TYPE
})) {
44 $subsys->{OUTPUT_TYPE
} = $subsystem_default_output_type;
50 my ($INPUT, $mod) = @_;
52 die("Module $mod->{NAME} does not have a SUBSYSTEM set") if not defined($mod->{SUBSYSTEM
});
55 ($mod->{DEFAULT_BUILD
} = "STATIC") if not defined($mod->{DEFAULT_BUILD
});
59 if (!(defined($INPUT->{$mod->{SUBSYSTEM
}}))) {
60 $mod->{BUILD
} = "NOT";
61 $mod->{ENABLE
} = "NO";
62 printf("Module: %s...PARENT SUBSYSTEM ($mod->{SUBSYSTEM}) DISABLED\n",$mod->{NAME
});
66 if (($mod->{ENABLE
} eq "STATIC") or
67 ($mod->{ENABLE
} eq "NOT") or
68 ($mod->{ENABLE
} eq "SHARED")) {
69 $mod->{DEFAULT_BUILD
} = $mod->{ENABLE
};
70 } elsif ($mod->{ENABLE
} ne "YES")
72 $mod->{CHOSEN_BUILD
} = "NOT";
75 if (not defined($mod->{CHOSEN_BUILD
}) or $mod->{CHOSEN_BUILD
} eq "DEFAULT")
77 $mod->{CHOSEN_BUILD
} = $mod->{DEFAULT_BUILD
};
80 if ($mod->{CHOSEN_BUILD
} eq "SHARED") {
81 $mod->{ENABLE
} = "YES";
82 $mod->{OUTPUT_TYPE
} = "SHARED_LIBRARY";
83 push (@
{$mod->{REQUIRED_SUBSYSTEMS
}}, $mod->{SUBSYSTEM
});
84 printf("Module: %s...shared\n",$mod->{NAME
});
85 } elsif ($mod->{CHOSEN_BUILD
} eq "STATIC") {
86 $mod->{ENABLE
} = "YES";
87 push (@
{$INPUT->{$mod->{SUBSYSTEM
}}{REQUIRED_SUBSYSTEMS
}}, $mod->{NAME
});
88 printf("Module: %s...static\n",$mod->{NAME
});
89 $mod->{OUTPUT_TYPE
} = $subsystem_default_output_type;
91 $mod->{ENABLE
} = "NO";
92 printf("Module: %s...not\n",$mod->{NAME
});
99 my ($INPUT, $lib) = @_;
101 if ($lib->{ENABLE
} ne "YES") {
102 printf("Library: %s...disabled\n",$lib->{NAME
});
106 $lib->{OUTPUT_TYPE
} = "SHARED_LIBRARY";
111 my ($INPUT, $bin) = @_;
113 if (!defined($bin->{CMD
})) {
114 print "CMD not defined for target!\n";
117 $bin->{OUTPUT_TYPE
} = "CUSTOM";
122 my ($INPUT, $bin) = @_;
124 if ($bin->{ENABLE
} ne "YES") {
125 printf("Binary: %s...disabled\n",$bin->{NAME
});
129 ($bin->{BINARY
} = (lc $bin->{NAME
})) if not defined($bin->{BINARY
});
131 $bin->{OUTPUT_TYPE
} = "BINARY";
134 sub calc_unique_deps
($$)
136 sub calc_unique_deps
($$);
137 my ($deps, $udeps) = @_;
139 foreach my $dep (@
{$deps}) {
140 if (not defined($udeps->{$$dep->{NAME
}})) {
141 $udeps->{$$dep->{NAME
}} = "BUSY";
142 calc_unique_deps
($$dep->{DEPENDENCIES
}, $udeps);
143 $udeps->{$$dep->{NAME
}} = $$dep;
148 ###########################################################
149 # This function checks the input from the configure script
151 # check_input($INPUT)
153 # $INPUT - the global INPUT context
154 # $enabled - list of enabled subsystems/libs
157 my ($INPUT, $enabled) = @_;
159 ($subsystem_default_output_type = $ENV{SUBSYSTEM_OUTPUT_TYPE
}) if (defined($ENV{"SUBSYSTEM_OUTPUT_TYPE"}));
161 foreach my $part (values %$INPUT) {
162 if (defined($enabled->{$part->{NAME
}})) {
163 $part->{ENABLE
} = $enabled->{$part->{NAME
}};
167 unless(defined($part->{ENABLE
})) {
168 $part->{ENABLE
} = "YES";
172 foreach my $k (keys %$INPUT) {
173 my $part = $INPUT->{$k};
174 if (not defined($part->{TYPE
})) {
175 print STDERR
"$k does not have a type set.. Perhaps it's only mentioned in a .m4 but not in a .mk file?\n";
178 check_subsystem
($INPUT, $part) if ($part->{TYPE
} eq "SUBSYSTEM");
179 check_module
($INPUT, $part) if ($part->{TYPE
} eq "MODULE");
180 check_library
($INPUT, $part) if ($part->{TYPE
} eq "LIBRARY");
181 check_binary
($INPUT, $part) if ($part->{TYPE
} eq "BINARY");
182 check_target
($INPUT, $part) if ($part->{TYPE
} eq "TARGET");
185 my %depend = %$INPUT;
187 foreach my $part (values %depend) {
189 # Generate list of dependencies
190 $part->{DEPENDENCIES
} = [];
192 foreach my $key (@
{$part->{REQUIRED_SUBSYSTEMS
}}) {
193 die("$part->{NAME} has undefined dependency $key\n") if not defined($depend{$key});
194 push (@
{$part->{DEPENDENCIES
}}, \
$depend{$key});
197 delete ($part->{REQUIRED_SUBSYSTEMS
});
200 foreach my $part (values %depend) {
201 $part->{UNIQUE_DEPENDENCIES
} = {};
202 calc_unique_deps
($part->{DEPENDENCIES
}, $part->{UNIQUE_DEPENDENCIES
});