4 # Copyright (C) Stefan (metze) Metzmacher 2004
5 # Copyright (C) Jelmer Vernooij 2005
6 # Released under the GNU GPL
8 use smb_build::makefile;
10 use smb_build::config_mk;
11 use smb_build::output;
12 use smb_build::summary;
13 use smb_build::config;
17 my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, "main.mk");
19 my $subsys_output_type = ["MERGED_OBJ"];
21 my $library_output_type;
22 if ($config::config{USESHARED} eq "true") {
23 $library_output_type = ["SHARED_LIBRARY", "STATIC_LIBRARY"];
25 $library_output_type = ["STATIC_LIBRARY"];
26 push (@$library_output_type, "SHARED_LIBRARY") if
27 ($config::config{BLDSHARED} eq "true")
30 my $module_output_type;
31 if ($config::config{USESHARED} eq "true") {
32 $module_output_type = ["SHARED_LIBRARY"];
34 $module_output_type = ["MERGED_OBJ"];
37 my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
41 my $OUTPUT = output::create_output($DEPEND, \%config::config);
42 my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
44 my $shared_libs_used = 0;
45 foreach my $key (values %$OUTPUT) {
46 push(@{$mkenv->{all_objs}}, "\$($key->{NAME}_OBJ_FILES)");
49 foreach my $key (values %$OUTPUT) {
50 next unless defined $key->{OUTPUT_TYPE};
52 $mkenv->StaticLibraryPrimitives($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
53 $mkenv->MergedObj($key) if grep(/MERGED_OBJ/, @{$key->{OUTPUT_TYPE}});
54 $kenv->SharedLibraryPrimitives($key) if ($key->{TYPE} eq "LIBRARY") and
55 grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
56 if ($key->{TYPE} eq "LIBRARY" and
57 ${$key->{OUTPUT_TYPE}}[0] eq "SHARED_LIBRARY") {
58 $shared_libs_used = 1;
60 $mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES});
61 if ($key->{TYPE} eq "MODULE" and @{$key->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ" and defined($key->{INIT_FUNCTION})) {
62 $mkenv->output("$key->{SUBSYSTEM}_INIT_FUNCTIONS += $key->{INIT_FUNCTION},\n");
67 foreach my $key (values %$OUTPUT) {
68 next unless defined $key->{OUTPUT_TYPE};
70 $mkenv->Integrated($key) if grep(/INTEGRATED/, @{$key->{OUTPUT_TYPE}});
73 foreach my $key (values %$OUTPUT) {
74 next unless defined $key->{OUTPUT_TYPE};
75 $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
77 $mkenv->SharedLibrary($key) if ($key->{TYPE} eq "LIBRARY") and
78 grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
79 $mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" and
80 grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}}));
81 $mkenv->PythonModule($key) if ($key->{TYPE} eq "PYTHON");
82 $mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
83 $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER});
84 $mkenv->InitFunctions($key) if defined($key->{INIT_FUNCTIONS});
87 $mkenv->write("data.mk");
89 summary::show($OUTPUT, \%config::config);