Distinguish between private and public dependencies in the dot file.
[gd/samba/.git] / source4 / build / smb_build / main.pl
1 # Samba Build System                                    
2 # - the main program                                    
3 #                                                       
4 #  Copyright (C) Stefan (metze) Metzmacher 2004 
5 #  Copyright (C) Jelmer Vernooij 2005
6 #  Released under the GNU GPL                           
7
8 use smb_build::makefile;
9 use smb_build::input;
10 use smb_build::config_mk;
11 use smb_build::output;
12 use smb_build::summary;
13 use smb_build::config;
14 use strict;
15
16 my $INPUT = {};
17 my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, "main.mk");
18
19 my $subsys_output_type = ["MERGED_OBJ"];
20
21 my $library_output_type;
22 if ($config::config{USESHARED} eq "true") {
23         $library_output_type = ["SHARED_LIBRARY", "STATIC_LIBRARY"];
24 } else {
25         $library_output_type = ["STATIC_LIBRARY"];
26         push (@$library_output_type, "SHARED_LIBRARY") if 
27                                                 ($config::config{BLDSHARED} eq "true")
28 }
29
30 my $module_output_type;
31 if ($config::config{USESHARED} eq "true") {
32         $module_output_type = ["SHARED_LIBRARY"];
33 } else {
34         $module_output_type = ["MERGED_OBJ"];
35 }
36
37 my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
38                                      $subsys_output_type,
39                                      $library_output_type,
40                                      $module_output_type);
41 my $OUTPUT = output::create_output($DEPEND, \%config::config);
42 my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
43
44 my $shared_libs_used = 0;
45 foreach my $key (values %$OUTPUT) {
46         $mkenv->_prepare_list($key, "OBJ_LIST");
47         push(@{$mkenv->{all_objs}}, "\$($key->{NAME}_OBJ_LIST)");
48 }
49
50 foreach my $key (values %$OUTPUT) {
51         next unless defined $key->{OUTPUT_TYPE};
52
53         $mkenv->StaticLibraryPrimitives($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
54         $mkenv->MergedObj($key) if grep(/MERGED_OBJ/, @{$key->{OUTPUT_TYPE}});
55         $mkenv->SharedLibraryPrimitives($key) if ($key->{TYPE} eq "LIBRARY") and
56                                         grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
57         if ($key->{TYPE} eq "LIBRARY" and 
58             ${$key->{OUTPUT_TYPE}}[0] eq "SHARED_LIBRARY") {
59                 $shared_libs_used = 1;
60         }
61         $mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES});
62         if ($key->{TYPE} eq "MODULE" and @{$key->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ" and defined($key->{INIT_FUNCTION})) {
63                 $mkenv->output("$key->{SUBSYSTEM}_INIT_FUNCTIONS += $key->{INIT_FUNCTION},\n");
64         }
65         $mkenv->CFlags($key);
66 }
67
68 foreach my $key (values %$OUTPUT) {
69         next unless defined $key->{OUTPUT_TYPE};
70
71         $mkenv->Integrated($key) if grep(/INTEGRATED/, @{$key->{OUTPUT_TYPE}});
72 }
73
74 foreach my $key (values %$OUTPUT) {
75         next unless defined $key->{OUTPUT_TYPE};
76
77         $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
78         $mkenv->SharedLibrary($key) if ($key->{TYPE} eq "LIBRARY") and
79                                         grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
80         $mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" and
81                                         grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}}));
82         $mkenv->PythonModule($key) if ($key->{TYPE} eq "PYTHON");
83         $mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
84         $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}) or 
85                                          defined($key->{PUBLIC_PROTO_HEADER});
86         $mkenv->InitFunctions($key) if defined($key->{INIT_FUNCTIONS});
87 }
88
89 $mkenv->write("data.mk");
90
91 summary::show($OUTPUT, \%config::config);
92
93 1;