Fix typos, avoid DEPEND_LIST from growing with empty elements.
[samba.git] / source4 / build / smb_build / makefile.pm
index 2acd0225038f95422d7c6e6c8a9309c2b88fe9d2..5fe0e68e9525f2260bf55d2ee0a077c0d59d9ae6 100644 (file)
@@ -6,26 +6,21 @@
 #  Released under the GNU GPL
 
 package smb_build::makefile;
-use smb_build::env;
 use smb_build::output;
 use File::Basename;
 use strict;
 
-use base 'smb_build::env';
 use Cwd 'abs_path';
 
 sub new($$$)
 {
        my ($myname, $config, $mkfile) = @_;
-       my $self = new smb_build::env($config);
-       
+       my $self = {};
+
        bless($self, $myname);
 
-       $self->{python_dsos} = [];
-       $self->{python_pys} = [];
-       $self->{headers} = [];
-       $self->{plugins} = [];
-       $self->{pc_files} = [];
+       $self->_set_config($config);
+
        $self->{output} = "";
 
        $self->{mkfile} = $mkfile;
@@ -43,6 +38,29 @@ sub new($$$)
        return $self;
 }
 
+sub _set_config($$)
+{
+       my ($self, $config) = @_;
+
+       $self->{config} = $config;
+
+       if (not defined($self->{config}->{srcdir})) {
+               $self->{config}->{srcdir} = '.';
+       }
+
+       if (not defined($self->{config}->{builddir})) {
+               $self->{config}->{builddir}  = '.';
+       }
+
+       if ($self->{config}->{prefix} eq "NONE") {
+               $self->{config}->{prefix} = $self->{config}->{ac_default_prefix};
+       }
+
+       if ($self->{config}->{exec_prefix} eq "NONE") {
+               $self->{config}->{exec_prefix} = $self->{config}->{prefix};
+       }
+}
+
 sub output($$)
 {
        my ($self, $text) = @_;
@@ -123,10 +141,9 @@ sub SharedModule($$)
        $sane_subsystem =~ s/^lib//;
        
        if ($ctx->{TYPE} eq "PYTHON") {
-               push (@{$self->{python_dsos}}, 
-                       "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
+               $self->output("PYTHON_DSOS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
        } else {
-               push (@{$self->{plugins}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
+               $self->output("PLUGINS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
                $self->output("installplugins:: $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
                $self->output("\t\@echo Installing $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
                $self->output("\t\@mkdir -p \$(DESTDIR)\$(modulesdir)/$sane_subsystem/\n");
@@ -214,7 +231,7 @@ sub SharedLibrary($$)
 {
        my ($self,$ctx) = @_;
 
-       $self->output("SHARED_LIBS += $ctx->{RESULT_SHARED_LIBRARY}\n") if (defined($ctx->{SO_VERSION}));
+       $self->output("SHARED_LIBS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n") if (defined($ctx->{SO_VERSION}));
 
        $self->_prepare_list($ctx, "DEPEND_LIST");
        $self->_prepare_list($ctx, "LINK_FLAGS");
@@ -228,15 +245,15 @@ sub SharedLibrary($$)
                }
        }
 
-       if (defined($ctx->{LIBRARY_SONAME})) {
-               $lns .= "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}";
-       }
+       $lns .= "\nifdef $ctx->{NAME}_SOVERSION";
+       $lns .= "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}";
+       $lns .= "\nendif";
 
        $self->output(<< "__EOD__"
 #
 $ctx->{RESULT_SHARED_LIBRARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST)
        \@echo Linking \$\@
-       \@mkdir -p $ctx->{SHAREDDIR}
+       \@mkdir -p \$(\@D)
        \@\$(SHLD) \$(LDFLAGS) \$(SHLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
                \$($ctx->{NAME}\_FULL_OBJ_LIST) \\
                \$($ctx->{NAME}_LINK_FLAGS) \\
@@ -257,7 +274,7 @@ sub MergedObj($$)
 #
 $ctx->{RESULT_MERGED_OBJ}: \$($ctx->{NAME}_OBJ_LIST)
        \@echo Partially linking \$@
-       \@mkdir -p bin/mergedobj
+       \@mkdir -p \$(\@D)
        \$(PARTLINK) -o \$@ \$($ctx->{NAME}_OBJ_LIST)
 
 __EOD__
@@ -278,26 +295,15 @@ sub StaticLibrary($$)
        $self->output("$ctx->{RESULT_STATIC_LIBRARY}: \$($ctx->{NAME}_FULL_OBJ_LIST)\n");
 }
 
-sub Header($$)
-{
-       my ($self,$ctx) = @_;
-
-       foreach (@{$ctx->{PUBLIC_HEADERS}}) {
-               push (@{$self->{headers}}, output::add_dir_str($ctx->{BASEDIR}, $_));
-       }
-}
-
 sub Binary($$)
 {
        my ($self,$ctx) = @_;
 
-       my $extradir = "";
-
        unless (defined($ctx->{INSTALLDIR})) {
        } elsif ($ctx->{INSTALLDIR} eq "SBINDIR") {
-               $self->output("SBIN_PROGS += $installdir/$ctx->{BINARY}\n");
+               $self->output("SBIN_PROGS += bin/$ctx->{BINARY}\n");
        } elsif ($ctx->{INSTALLDIR} eq "BINDIR") {
-               $self->output("BIN_PROGS += $installdir/$ctx->{BINARY}\n");
+               $self->output("BIN_PROGS += bin/$ctx->{BINARY}\n");
        }
 
        $self->output("binaries:: $ctx->{TARGET_BINARY}\n");
@@ -336,18 +342,10 @@ sub PythonFiles($$)
                my $target = "bin/python/".basename($_);
                my $source = output::add_dir_str($ctx->{BASEDIR}, $_);
                $self->output("$target: $source\n\n");
-               push (@{$self->{python_pys}}, $target);
+               $self->output("PYTHON_PYS += $target\n");
        }
 }
 
-sub Manpage($$)
-{
-       my ($self,$ctx) = @_;
-
-       my $path = output::add_dir_str($ctx->{BASEDIR}, $ctx->{MANPAGE});
-       push (@{$self->{manpages}}, $path);
-}
-
 sub ProtoHeader($$)
 {
        my ($self,$ctx) = @_;
@@ -391,12 +389,7 @@ sub write($$)
 {
        my ($self, $file) = @_;
 
-       $self->output("PYTHON_DSOS = " . array2oneperline($self->{python_dsos}) . "\n");
-       $self->output("PYTHON_PYS = " . array2oneperline($self->{python_pys}) . "\n");
-       $self->output("PUBLIC_HEADERS = " . array2oneperline($self->{headers}) . "\n");
-       $self->output("PC_FILES = " . array2oneperline($self->{pc_files}) . "\n");
        $self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
-       $self->output("PLUGINS = " . array2oneperline($self->{plugins}) . "\n");
 
        $self->_prepare_mk_files();