Move configure output details out of perl code.
[ira/wip.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::env;
13 use smb_build::summary;
14 use smb_build::config;
15 use strict;
16
17 my $INPUT = {};
18 my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, "main.mk");
19
20 my $subsys_output_type = ["MERGED_OBJ"];
21
22 my $library_output_type;
23 if ($config::config{USESHARED} eq "true") {
24         $library_output_type = ["SHARED_LIBRARY", "STATIC_LIBRARY"];
25 } else {
26         $library_output_type = ["STATIC_LIBRARY"];
27         push (@$library_output_type, "SHARED_LIBRARY") if 
28                                                 ($config::config{BLDSHARED} eq "true")
29 }
30
31 my $module_output_type;
32 if ($config::config{USESHARED} eq "true") {
33         $module_output_type = ["SHARED_LIBRARY"];
34 } else {
35         $module_output_type = ["MERGED_OBJ"];
36 }
37
38 my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
39                                      $subsys_output_type,
40                                      $library_output_type,
41                                      $module_output_type);
42 my $OUTPUT = output::create_output($DEPEND, \%config::config);
43 my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
44
45 my $shared_libs_used = 0;
46 foreach my $key (values %$OUTPUT) {
47         $mkenv->_prepare_list($key, "OBJ_LIST");
48         push(@{$mkenv->{all_objs}}, "\$($key->{NAME}_OBJ_LIST)");
49 }
50
51 foreach my $key (values %$OUTPUT) {
52         next unless defined $key->{OUTPUT_TYPE};
53
54         $mkenv->StaticLibraryPrimitives($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
55         $mkenv->MergedObj($key) if grep(/MERGED_OBJ/, @{$key->{OUTPUT_TYPE}});
56         if (defined($key->{PC_FILE})) {
57                 $mkenv->output("PC_FILES += $key->{BASEDIR}/$key->{PC_FILE}\n");
58         } 
59         $mkenv->SharedLibraryPrimitives($key) if ($key->{TYPE} eq "LIBRARY") and
60                                         grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
61         if ($key->{TYPE} eq "LIBRARY" and 
62             ${$key->{OUTPUT_TYPE}}[0] eq "SHARED_LIBRARY") {
63                 $shared_libs_used = 1;
64         }
65         $mkenv->SharedModulePrimitives($key) if ($key->{TYPE} eq "MODULE" or 
66                                                                    $key->{TYPE} eq "PYTHON") and
67                                         grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
68         $mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES});
69         $mkenv->Manpage($key) if defined($key->{MANPAGE});
70         $mkenv->Header($key) if defined($key->{PUBLIC_HEADERS});
71         if ($key->{TYPE} eq "MODULE" and defined($key->{INIT_FUNCTION})) {
72                 $mkenv->output("$key->{SUBSYSTEM}_INIT_FUNCTIONS += \"$key->{INIT_FUNCTION},\"\n");
73         }
74         $mkenv->CFlags($key);
75 }
76
77 foreach my $key (values %$OUTPUT) {
78         next unless defined $key->{OUTPUT_TYPE};
79
80         $mkenv->Integrated($key) if grep(/INTEGRATED/, @{$key->{OUTPUT_TYPE}});
81 }
82
83 foreach my $key (values %$OUTPUT) {
84         next unless defined $key->{OUTPUT_TYPE};
85
86         $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
87         $mkenv->SharedLibrary($key) if ($key->{TYPE} eq "LIBRARY") and
88                                         grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
89         $mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" or 
90                                                                    $key->{TYPE} eq "PYTHON") and
91                                         grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
92         $mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
93         $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}) or 
94                                          defined($key->{PUBLIC_PROTO_HEADER});
95         $mkenv->InitFunctions($key) if defined($key->{INIT_FUNCTIONS});
96 }
97
98 $mkenv->write("data.mk");
99
100 summary::show($OUTPUT, \%config::config);
101
102 1;