4 # Copyright (C) Stefan (metze) Metzmacher 2004
5 # Copyright (C) Jelmer Vernooij 2005
6 # Released under the GNU GPL
8 use smb_build::makefile;
11 use smb_build::config_mk;
12 use smb_build::output;
14 use smb_build::cflags;
15 use smb_build::summary;
16 use smb_build::config;
20 my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, "main.mk");
22 my $subsys_output_type;
23 $subsys_output_type = ["STATIC_LIBRARY"];
25 my $library_output_type;
26 if ($config::config{USESHARED} eq "true") {
27 $library_output_type = ["SHARED_LIBRARY", "STATIC_LIBRARY"];
29 $library_output_type = ["STATIC_LIBRARY"];
30 push (@$library_output_type, "SHARED_LIBRARY") if
31 ($config::config{BLDSHARED} eq "true")
34 my $module_output_type;
35 if ($config::config{USESHARED} eq "true") {
36 $module_output_type = ["SHARED_LIBRARY"];
38 $module_output_type = ["INTEGRATED"];
41 my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
45 my $OUTPUT = output::create_output($DEPEND, \%config::config);
46 $config::config{SUBSYSTEM_OUTPUT_TYPE} = $subsys_output_type;
47 $config::config{LIBRARY_OUTPUT_TYPE} = $library_output_type;
48 $config::config{MODULE_OUTPUT_TYPE} = $module_output_type;
49 my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
51 foreach my $key (values %$OUTPUT) {
52 next unless defined $key->{OUTPUT_TYPE};
54 $mkenv->Integrated($key) if grep(/INTEGRATED/, @{$key->{OUTPUT_TYPE}});
57 my $shared_libs_used = 0;
59 foreach my $key (values %$OUTPUT) {
60 next unless defined $key->{OUTPUT_TYPE};
62 $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
63 if (defined($key->{PC_FILE})) {
64 $mkenv->output("PC_FILES += $key->{BASEDIR}/$key->{PC_FILE}\n");
66 $mkenv->SharedLibraryPrimitives($key) if ($key->{TYPE} eq "LIBRARY") and
67 grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
68 if ($key->{TYPE} eq "LIBRARY" and
69 ${$key->{OUTPUT_TYPE}}[0] eq "SHARED_LIBRARY") {
70 $shared_libs_used = 1;
72 $mkenv->SharedModulePrimitives($key) if ($key->{TYPE} eq "MODULE" or
73 $key->{TYPE} eq "PYTHON") and
74 grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
75 $mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES});
76 $mkenv->Manpage($key) if defined($key->{MANPAGE});
77 $mkenv->Header($key) if defined($key->{PUBLIC_HEADERS});
78 $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}) or
79 defined($key->{PUBLIC_PROTO_HEADER});
82 foreach my $key (values %$OUTPUT) {
83 next unless defined $key->{OUTPUT_TYPE};
85 $mkenv->SharedLibrary($key) if ($key->{TYPE} eq "LIBRARY") and
86 grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
87 $mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" or
88 $key->{TYPE} eq "PYTHON") and
89 grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
90 $mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
93 $mkenv->write("data.mk");
94 header::create_smb_build_h($OUTPUT, "include/build.h");
96 cflags::create_cflags($OUTPUT, $config::config{srcdir},
97 $config::config{builddir}, "extra_cflags.txt");
99 summary::show($OUTPUT, \%config::config);
101 if ($shared_libs_used) {
103 To run binaries without installing, set the following environment variable:
104 $config::config{LIB_PATH_VAR}=$config::config{builddir}/bin/shared