Fix use of realpath, fix init functions for ldb.
[kai/samba.git] / source4 / build / smb_build / main.pl
index d4d18a5cb94587d41d3f2aa3e727e8ede09edf9a..b23976956c8e5db4fcb86b3674c767acfd8665ee 100644 (file)
@@ -6,12 +6,9 @@
 #  Released under the GNU GPL                          
 
 use smb_build::makefile;
-use smb_build::header;
 use smb_build::input;
 use smb_build::config_mk;
 use smb_build::output;
-use smb_build::env;
-use smb_build::cflags;
 use smb_build::summary;
 use smb_build::config;
 use strict;
@@ -19,8 +16,7 @@ use strict;
 my $INPUT = {};
 my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, "main.mk");
 
-my $subsys_output_type;
-$subsys_output_type = ["MERGED_OBJ"];
+my $subsys_output_type = ["MERGED_OBJ"];
 
 my $library_output_type;
 if ($config::config{USESHARED} eq "true") {
@@ -35,7 +31,7 @@ my $module_output_type;
 if ($config::config{USESHARED} eq "true") {
        $module_output_type = ["SHARED_LIBRARY"];
 } else {
-       $module_output_type = ["INTEGRATED"];
+       $module_output_type = ["MERGED_OBJ"];
 }
 
 my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
@@ -43,23 +39,21 @@ my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
                                     $library_output_type,
                                     $module_output_type);
 my $OUTPUT = output::create_output($DEPEND, \%config::config);
-$config::config{SUBSYSTEM_OUTPUT_TYPE} = $subsys_output_type;
-$config::config{LIBRARY_OUTPUT_TYPE} = $library_output_type;
-$config::config{MODULE_OUTPUT_TYPE} = $module_output_type;
 my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
 
 my $shared_libs_used = 0;
 foreach my $key (values %$OUTPUT) {
        $mkenv->_prepare_list($key, "OBJ_LIST");
+       push(@{$mkenv->{all_objs}}, "\$($key->{NAME}_OBJ_LIST)");
 }
 
 foreach my $key (values %$OUTPUT) {
        next unless defined $key->{OUTPUT_TYPE};
 
+       $mkenv->StaticLibraryPrimitives($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
        $mkenv->MergedObj($key) if grep(/MERGED_OBJ/, @{$key->{OUTPUT_TYPE}});
-       $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
        if (defined($key->{PC_FILE})) {
-               push(@{$mkenv->{pc_files}}, "$key->{BASEDIR}/$key->{PC_FILE}");
+               $mkenv->output("PC_FILES += $key->{BASEDIR}/$key->{PC_FILE}\n");
        } 
        $mkenv->SharedLibraryPrimitives($key) if ($key->{TYPE} eq "LIBRARY") and
                                        grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
@@ -73,34 +67,35 @@ foreach my $key (values %$OUTPUT) {
        $mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES});
        $mkenv->Manpage($key) if defined($key->{MANPAGE});
        $mkenv->Header($key) if defined($key->{PUBLIC_HEADERS});
-       $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}) or 
-                                        defined($key->{PUBLIC_PROTO_HEADER});
+       if ($key->{TYPE} eq "MODULE" and $key->{OUTPUT_TYPE} eq "MERGED_OBJ" and defined($key->{INIT_FUNCTION})) {
+               $mkenv->output("$key->{SUBSYSTEM}_INIT_FUNCTIONS += $key->{INIT_FUNCTION},\n");
+       }
+       $mkenv->CFlags($key);
 }
 
 foreach my $key (values %$OUTPUT) {
        next unless defined $key->{OUTPUT_TYPE};
 
+       $mkenv->Integrated($key) if grep(/INTEGRATED/, @{$key->{OUTPUT_TYPE}});
+}
+
+foreach my $key (values %$OUTPUT) {
+       next unless defined $key->{OUTPUT_TYPE};
+
+       $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
        $mkenv->SharedLibrary($key) if ($key->{TYPE} eq "LIBRARY") and
                                        grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
        $mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" or 
                                                                   $key->{TYPE} eq "PYTHON") and
                                        grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
        $mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
+       $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}) or 
+                                        defined($key->{PUBLIC_PROTO_HEADER});
+       $mkenv->InitFunctions($key) if defined($key->{INIT_FUNCTIONS});
 }
 
 $mkenv->write("data.mk");
-header::create_smb_build_h($OUTPUT, "include/build.h");
-
-cflags::create_cflags($OUTPUT, $config::config{srcdir},
-                   $config::config{builddir}, "extra_cflags.txt");
 
 summary::show($OUTPUT, \%config::config);
 
-if ($shared_libs_used) {
-       print <<EOF;
-To run binaries without installing, set the following environment variable:
-       $config::config{LIB_PATH_VAR}=$config::config{builddir}/bin/shared
-EOF
-}
-
 1;