source: branches/samba-3.5.x/source4/build/smb_build/main.pl

Last change on this file was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 3.1 KB
Line 
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
8use smb_build::makefile;
9use smb_build::input;
10use smb_build::config_mk;
11use smb_build::output;
12use smb_build::summary;
13use smb_build::config;
14use Getopt::Long;
15use strict;
16
17my $output_file = "data.mk";
18
19my $result = GetOptions (
20 'output=s' => \$output_file);
21
22if (not $result) {
23 exit(1);
24}
25
26my $input_file = shift @ARGV;
27
28my $INPUT = {};
29my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, $input_file);
30
31my $subsys_output_type = ["MERGED_OBJ"];
32
33my $library_output_type;
34my $useshared = (defined($ENV{USESHARED})?$ENV{USESHARED}:$config::config{USESHARED});
35
36if ($useshared eq "true") {
37 $library_output_type = ["SHARED_LIBRARY", "MERGED_OBJ"];
38} else {
39 $library_output_type = ["MERGED_OBJ"];
40 push (@$library_output_type, "SHARED_LIBRARY") if
41 ($config::config{BLDSHARED} eq "true")
42}
43
44my $module_output_type;
45if ($useshared eq "true") {
46 #$module_output_type = ["SHARED_LIBRARY"];
47 $module_output_type = ["MERGED_OBJ"];
48} else {
49 $module_output_type = ["MERGED_OBJ"];
50}
51
52my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
53 $subsys_output_type,
54 $library_output_type,
55 $module_output_type);
56my $OUTPUT = output::create_output($DEPEND, \%config::config);
57my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
58
59my $shared_libs_used = 0;
60foreach my $key (values %$OUTPUT) {
61 next if ($key->{ENABLE} ne "YES");
62 push(@{$mkenv->{all_objs}}, "\$($key->{NAME}_OBJ_FILES)");
63}
64
65foreach my $key (values %$OUTPUT) {
66 next unless defined $key->{OUTPUT_TYPE};
67
68 $mkenv->StaticLibraryPrimitives($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
69 $mkenv->MergedObj($key) if grep(/MERGED_OBJ/, @{$key->{OUTPUT_TYPE}});
70 $mkenv->SharedLibraryPrimitives($key) if ($key->{TYPE} eq "LIBRARY") and
71 grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
72 if ($key->{TYPE} eq "LIBRARY" and
73 ${$key->{OUTPUT_TYPE}}[0] eq "SHARED_LIBRARY") {
74 $shared_libs_used = 1;
75 }
76 if ($key->{TYPE} eq "MODULE" and @{$key->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ" and defined($key->{INIT_FUNCTION})) {
77 $mkenv->output("$key->{SUBSYSTEM}_INIT_FUNCTIONS +=$key->{INIT_FUNCTION},\n");
78 }
79 $mkenv->CFlags($key);
80}
81
82foreach my $key (values %$OUTPUT) {
83 next unless defined $key->{OUTPUT_TYPE};
84
85 $mkenv->Integrated($key) if grep(/INTEGRATED/, @{$key->{OUTPUT_TYPE}});
86}
87
88foreach my $key (values %$OUTPUT) {
89 next unless defined $key->{OUTPUT_TYPE};
90 $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
91
92 $mkenv->SharedLibrary($key) if ($key->{TYPE} eq "LIBRARY") and
93 grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
94 $mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" and
95 grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}}));
96 $mkenv->PythonModule($key) if ($key->{TYPE} eq "PYTHON");
97 $mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
98 $mkenv->InitFunctions($key) if defined($key->{INIT_FUNCTIONS});
99}
100
101$mkenv->write($output_file);
102
103summary::show($OUTPUT, \%config::config);
104
1051;
Note: See TracBrowser for help on using the repository browser.