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 Getopt::Long;
|
---|
15 | use strict;
|
---|
16 |
|
---|
17 | my $output_file = "data.mk";
|
---|
18 |
|
---|
19 | my $result = GetOptions (
|
---|
20 | 'output=s' => \$output_file);
|
---|
21 |
|
---|
22 | if (not $result) {
|
---|
23 | exit(1);
|
---|
24 | }
|
---|
25 |
|
---|
26 | my $input_file = shift @ARGV;
|
---|
27 |
|
---|
28 | my $INPUT = {};
|
---|
29 | my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, $input_file);
|
---|
30 |
|
---|
31 | my $subsys_output_type = ["MERGED_OBJ"];
|
---|
32 |
|
---|
33 | my $library_output_type;
|
---|
34 | my $useshared = (defined($ENV{USESHARED})?$ENV{USESHARED}:$config::config{USESHARED});
|
---|
35 |
|
---|
36 | if ($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 |
|
---|
44 | my $module_output_type;
|
---|
45 | if ($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 |
|
---|
52 | my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
|
---|
53 | $subsys_output_type,
|
---|
54 | $library_output_type,
|
---|
55 | $module_output_type);
|
---|
56 | my $OUTPUT = output::create_output($DEPEND, \%config::config);
|
---|
57 | my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
|
---|
58 |
|
---|
59 | my $shared_libs_used = 0;
|
---|
60 | foreach my $key (values %$OUTPUT) {
|
---|
61 | next if ($key->{ENABLE} ne "YES");
|
---|
62 | push(@{$mkenv->{all_objs}}, "\$($key->{NAME}_OBJ_FILES)");
|
---|
63 | }
|
---|
64 |
|
---|
65 | foreach 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 |
|
---|
82 | foreach my $key (values %$OUTPUT) {
|
---|
83 | next unless defined $key->{OUTPUT_TYPE};
|
---|
84 |
|
---|
85 | $mkenv->Integrated($key) if grep(/INTEGRATED/, @{$key->{OUTPUT_TYPE}});
|
---|
86 | }
|
---|
87 |
|
---|
88 | foreach 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 |
|
---|
103 | summary::show($OUTPUT, \%config::config);
|
---|
104 |
|
---|
105 | 1;
|
---|