Move manpage management out of the perl build system.
[jelmer/samba4-debian.git] / source / 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::header;
10 use smb_build::input;
11 use smb_build::config_mk;
12 use smb_build::output;
13 use smb_build::cflags;
14 use smb_build::summary;
15 use smb_build::config;
16 use strict;
17
18 my $INPUT = {};
19 my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, "main.mk");
20
21 my $subsys_output_type = ["MERGED_OBJ"];
22
23 my $library_output_type;
24 if ($config::config{USESHARED} eq "true") {
25         $library_output_type = ["SHARED_LIBRARY", "STATIC_LIBRARY"];
26 } else {
27         $library_output_type = ["STATIC_LIBRARY"];
28         push (@$library_output_type, "SHARED_LIBRARY") if 
29                                                 ($config::config{BLDSHARED} eq "true")
30 }
31
32 my $module_output_type;
33 if ($config::config{USESHARED} eq "true") {
34         $module_output_type = ["SHARED_LIBRARY"];
35 } else {
36         $module_output_type = ["MERGED_OBJ"];
37 }
38
39 my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
40                                      $subsys_output_type,
41                                      $library_output_type,
42                                      $module_output_type);
43 my $OUTPUT = output::create_output($DEPEND, \%config::config);
44 my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
45
46 my $shared_libs_used = 0;
47 foreach my $key (values %$OUTPUT) {
48         $mkenv->_prepare_list($key, "OBJ_LIST");
49         push(@{$mkenv->{all_objs}}, "\$($key->{NAME}_OBJ_LIST)");
50 }
51
52 foreach my $key (values %$OUTPUT) {
53         next unless defined $key->{OUTPUT_TYPE};
54
55         $mkenv->MergedObj($key) if grep(/MERGED_OBJ/, @{$key->{OUTPUT_TYPE}});
56         $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
57         if (defined($key->{PC_FILE})) {
58                 $mkenv->output("PC_FILES += $key->{BASEDIR}/$key->{PC_FILE}\n");
59         } 
60         $mkenv->SharedLibraryPrimitives($key) if ($key->{TYPE} eq "LIBRARY") and
61                                         grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
62         if ($key->{TYPE} eq "LIBRARY" and 
63             ${$key->{OUTPUT_TYPE}}[0] eq "SHARED_LIBRARY") {
64                 $shared_libs_used = 1;
65         }
66         $mkenv->SharedModulePrimitives($key) if ($key->{TYPE} eq "MODULE" or 
67                                                                    $key->{TYPE} eq "PYTHON") and
68                                         grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
69         $mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES});
70         $mkenv->Header($key) if defined($key->{PUBLIC_HEADERS});
71         $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}) or 
72                                          defined($key->{PUBLIC_PROTO_HEADER});
73 }
74
75 foreach my $key (values %$OUTPUT) {
76         next unless defined $key->{OUTPUT_TYPE};
77
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" or 
81                                                                    $key->{TYPE} eq "PYTHON") and
82                                         grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
83         $mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
84 }
85
86 $mkenv->write("data.mk");
87 header::create_smb_build_h($OUTPUT, "include/build.h");
88
89 cflags::create_cflags($OUTPUT, $config::config{srcdir},
90                     $config::config{builddir}, "extra_cflags.txt");
91
92 summary::show($OUTPUT, \%config::config);
93
94 print "To build Samba, run $config::config{MAKE}\n";
95
96 1;