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 = ["MERGED_OBJ"];
24 $subsys_output_type = ["STATIC_LIBRARY"];
26 my $library_output_type;
27 if ($config::config{USESHARED} eq "true") {
28 $library_output_type = ["SHARED_LIBRARY", "STATIC_LIBRARY"];
30 $library_output_type = ["STATIC_LIBRARY"];
31 push (@$library_output_type, "SHARED_LIBRARY") if
32 ($config::config{BLDSHARED} eq "true")
35 my $module_output_type;
36 if ($config::config{USESHARED} eq "true") {
37 $module_output_type = ["SHARED_LIBRARY"];
39 $module_output_type = ["INTEGRATED"];
42 my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
46 my $OUTPUT = output::create_output($DEPEND, \%config::config);
47 $config::config{SUBSYSTEM_OUTPUT_TYPE} = $subsys_output_type;
48 $config::config{LIBRARY_OUTPUT_TYPE} = $library_output_type;
49 $config::config{MODULE_OUTPUT_TYPE} = $module_output_type;
50 my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
52 foreach my $key (values %$OUTPUT) {
53 next unless defined $key->{OUTPUT_TYPE};
55 $mkenv->Integrated($key) if grep(/INTEGRATED/, @{$key->{OUTPUT_TYPE}});
58 my $shared_libs_used = 0;
60 foreach my $key (values %$OUTPUT) {
61 next unless defined $key->{OUTPUT_TYPE};
63 $mkenv->MergedObj($key) if grep(/MERGED_OBJ/, @{$key->{OUTPUT_TYPE}});
64 $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
65 if (defined($key->{PC_FILE})) {
66 push(@{$mkenv->{pc_files}}, "$key->{BASEDIR}/$key->{PC_FILE}");
68 $mkenv->SharedLibraryPrimitives($key) if ($key->{TYPE} eq "LIBRARY") and
69 grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
70 if ($key->{TYPE} eq "LIBRARY" and
71 ${$key->{OUTPUT_TYPE}}[0] eq "SHARED_LIBRARY") {
72 $shared_libs_used = 1;
74 $mkenv->SharedModulePrimitives($key) if ($key->{TYPE} eq "MODULE" or
75 $key->{TYPE} eq "PYTHON") and
76 grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
77 $mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES});
78 $mkenv->Manpage($key) if defined($key->{MANPAGE});
79 $mkenv->Header($key) if defined($key->{PUBLIC_HEADERS});
80 $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}) or
81 defined($key->{PUBLIC_PROTO_HEADER});
84 foreach my $key (values %$OUTPUT) {
85 next unless defined $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}});
95 $mkenv->write("data.mk");
96 header::create_smb_build_h($OUTPUT, "include/build.h");
98 cflags::create_cflags($OUTPUT, $config::config{srcdir},
99 $config::config{builddir}, "extra_cflags.txt");
101 summary::show($OUTPUT, \%config::config);
103 if ($shared_libs_used) {
105 To run binaries without installing, set the following environment variable:
106 $config::config{LIB_PATH_VAR}=$config::config{builddir}/bin/shared