r15064: Remove the change until I find proper solution
[bbaumbach/samba-autobuild/.git] / source / build / smb_build / makefile.pm
index b0c7ea3be1c13128223ac584c90e4db35af3baaf..c6ab0d7220a0156ce477b67db2f65a654447688d 100644 (file)
@@ -10,6 +10,7 @@ use smb_build::env;
 use strict;
 
 use base 'smb_build::env';
+use Cwd 'abs_path';
 
 sub new($$$)
 {
@@ -46,6 +47,11 @@ sub new($$$)
        $self->_prepare_path_vars();
        $self->_prepare_compiler_linker();
 
+       if (!$self->{automatic_deps}) {
+               $self->output("ALL_PREDEP = proto\n");
+               $self->output(".NOTPARALLEL:\n");
+       }
+
        return $self;
 }
 
@@ -64,7 +70,7 @@ sub _prepare_path_vars($)
 prefix = $self->{config}->{prefix}
 exec_prefix = $self->{config}->{exec_prefix}
 selftest_prefix = $self->{config}->{selftest_prefix}
-VPATH = $self->{config}->{srcdir}:heimdal/lib/asn1:heimdal/lib/krb5:heimdal/lib/gssapi:heimdal/lib/hdb
+VPATH = $self->{config}->{srcdir}:heimdal/lib/asn1:heimdal/lib/krb5:heimdal/lib/gssapi:heimdal/lib/hdb:heimdal/lib/roken:heimdal/lib/des
 srcdir = $self->{config}->{srcdir}
 builddir = $self->{config}->{builddir}
 
@@ -98,6 +104,7 @@ sub _prepare_compiler_linker($)
 
        my $devld_local = "";
        my $devld_install = "";
+       my $builddir_headers = "";
 
        $self->{duplicate_build} = 0;
        if ($self->{config}->{LIBRARY_OUTPUT_TYPE} eq "SHARED_LIBRARY") {
@@ -107,6 +114,10 @@ sub _prepare_compiler_linker($)
                }
                $devld_install = " -Wl,-rpath-link,\$(builddir)/bin";
        }
+       
+       if (!(abs_path($self->{config}->{srcdir}) eq abs_path($self->{config}->{builddir}))) {
+           $builddir_headers= "-I\$(builddir)/include -I\$(builddir) -I\$(builddir)/lib ";
+       }
 
        $self->output(<< "__EOD__"
 SHELL=$self->{config}->{SHELL}
@@ -117,7 +128,7 @@ CPP=$self->{config}->{CPP}
 CPPFLAGS=$self->{config}->{CPPFLAGS}
 
 CC=$self->{config}->{CC}
-CFLAGS=-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -D_SAMBA_BUILD_ -DHAVE_CONFIG_H $self->{config}->{CFLAGS} \$(CPPFLAGS)
+CFLAGS=$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -D_SAMBA_BUILD_ -DHAVE_CONFIG_H $self->{config}->{CFLAGS} \$(CPPFLAGS)
 PICFLAG=$self->{config}->{PICFLAG}
 HOSTCC=$self->{config}->{HOSTCC}
 
@@ -128,7 +139,7 @@ LD=$self->{config}->{LD}
 LDFLAGS=$self->{config}->{LDFLAGS} -L\$(builddir)/bin
 
 STLD=$self->{config}->{AR}
-STLD_FLAGS=-rc -L\$(builddir)/bin
+STLD_FLAGS=-rc
 
 SHLD=$self->{config}->{CC}
 SHLD_FLAGS=$self->{config}->{LDSHFLAGS} -L\$(builddir)/bin
@@ -154,7 +165,6 @@ sub _prepare_mk_files($)
        my $self = shift;
        my @tmp = ();
 
-       
        foreach (@smb_build::config_mk::parsed_files) {
                s/ .*$//g;
                push (@tmp, $_);
@@ -201,21 +211,23 @@ sub SharedLibrary($$)
        }
 
        if ($ctx->{TYPE} eq "LIBRARY") {
-               push (@{$self->{shared_libs}}, "$ctx->{DEBUGDIR}/$ctx->{LIBRARY_REALNAME}");
-               push (@{$self->{installable_shared_libs}}, "$installdir/$ctx->{LIBRARY_REALNAME}");
+               push (@{$self->{shared_libs}}, "$ctx->{DEBUGDIR}/$ctx->{LIBRARY_REALNAME}") if (defined($ctx->{SO_VERSION}));
+               push (@{$self->{installable_shared_libs}}, "$installdir/$ctx->{LIBRARY_REALNAME}") if (defined($ctx->{SO_VERSION}));
        } elsif ($ctx->{TYPE} eq "MODULE") {
-               push (@{$self->{shared_modules}}, "$ctx->{DEBUGDIR}/$ctx->{LIBRARY_REALNAME}");
+               push (@{$self->{shared_modules}}, "$ctx->{TARGET}");
                push (@{$self->{plugins}}, "$installdir/$ctx->{LIBRARY_REALNAME}");
 
-               my $fixedname = $ctx->{NAME};
-
-               $fixedname =~ s/^$ctx->{SUBSYSTEM}_//g;
-
-               $self->{install_plugins} .= "\t\@echo Installing $installdir/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$fixedname.\$(SHLIBEXT)\n";
+               $self->{install_plugins} .= "\t\@echo Installing $installdir/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
                $self->{install_plugins} .= "\t\@mkdir -p \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/\n";
-               $self->{install_plugins} .= "\t\@cp $installdir/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$fixedname.\$(SHLIBEXT)\n";
-               $self->{uninstall_plugins} .= "\t\@echo Uninstalling \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$fixedname.\$(SHLIBEXT)\n";
-               $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$fixedname.\$(SHLIBEXT)\n";
+               $self->{install_plugins} .= "\t\@cp $installdir/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
+               $self->{uninstall_plugins} .= "\t\@echo Uninstalling \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
+               $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$ctx->{LIBRARY_REALNAME}\n";
+               if (defined($ctx->{ALIASES})) {
+                       foreach (@{$ctx->{ALIASES}}) {
+                               $self->{install_plugins} .= "\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$_.\$(SHLIBEXT)\n";
+                               $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$ctx->{SUBSYSTEM}/$_.\$(SHLIBEXT)\n";
+                       }
+               }
        }
 
        $self->_prepare_list($ctx, "OBJ_LIST");
@@ -249,11 +261,13 @@ __EOD__
                defined($ctx->{LIBRARY_SONAME})) {
                $soarg = "$self->{config}->{SONAMEFLAG}$ctx->{LIBRARY_SONAME} ";
                if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
-                       $soargdebug = "\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{DEBUGDIR}/$ctx->{LIBRARY_SONAME}\n";
+                       $soargdebug = "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{DEBUGDIR}/$ctx->{LIBRARY_SONAME}";
                }
        }
 
-       if ($self->{duplicate_build}) {
+       my $singlesoarg = "";
+       
+       if ($ctx->{DEBUGDIR} ne $installdir) {
                $self->output(<< "__EOD__"
 #
 
@@ -262,10 +276,23 @@ $ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->
        \@mkdir -p $ctx->{DEBUGDIR}
        \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \$(LOCAL_LINK_FLAGS) \\
                \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) $soarg \\
-               $init_obj \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST)
-$soargdebug
+               $init_obj \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST)$soargdebug
 __EOD__
 );
+               if (defined($ctx->{ALIASES})) {
+                       foreach (@{$ctx->{ALIASES}}) {
+                               $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{DEBUGDIR}/$_.\$(SHLIBEXT)\n");
+                       }
+               }
+
+               $self->output("\n");
+       } else {
+               if ($self->{config}->{SONAMEFLAG} ne "" and 
+                       defined($ctx->{LIBRARY_SONAME}) and 
+                       $ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
+                       $singlesoarg = "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $installdir/$ctx->{LIBRARY_SONAME}";
+               }
+
        }
 
        $self->output(<< "__EOD__"
@@ -273,9 +300,10 @@ __EOD__
 
 $installdir/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) $init_obj
        \@echo Linking \$\@
-       \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \\
+       \@mkdir -p $installdir
+       \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
                \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) $soarg \\
-               $init_obj \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST)
+               $init_obj \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST)$singlesoarg
 
 __EOD__
 );
@@ -320,7 +348,7 @@ sub StaticLibrary($$)
 {
        my ($self,$ctx) = @_;
 
-       push (@{$self->{static_libs}}, $ctx->{OUTPUT});
+       push (@{$self->{static_libs}}, $ctx->{TARGET});
 
        $self->_prepare_list($ctx, "OBJ_LIST");
        $self->_prepare_list($ctx, "CFLAGS");
@@ -333,10 +361,10 @@ sub StaticLibrary($$)
                
        $self->output(<< "__EOD__"
 #
-$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) 
+$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) 
        \@echo Linking \$@
        \@\$(STLD) \$(STLD_FLAGS) \$@ \\
-               \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST)
+               \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)
 
 __EOD__
 );
@@ -346,8 +374,12 @@ sub Header($$)
 {
        my ($self,$ctx) = @_;
 
+       my $dir = $ctx->{BASEDIR};
+
+       $dir =~ s/^\.\///g;
+
        foreach (@{$ctx->{PUBLIC_HEADERS}}) {
-               push (@{$self->{headers}}, "$ctx->{BASEDIR}/$_");
+               push (@{$self->{headers}}, "$dir/$_");
        }
 }
 
@@ -424,10 +456,7 @@ sub PkgConfig($$)
        $link_name =~ s/^LIB//g;
        $link_name = lc($link_name);
 
-       if (not defined($ctx->{DESCRIPTION})) {
-               warn("$ctx->{NAME} has not DESCRIPTION set, not generating .pc file");
-               return;
-       }
+       return if (not defined($ctx->{DESCRIPTION}));
 
        my $path = "$ctx->{BASEDIR}/$link_name.pc";
 
@@ -440,7 +469,7 @@ sub PkgConfig($$)
                "",
                "$ctx->{VERSION}",
                $ctx->{DESCRIPTION},
-               1
+               defined($ctx->{INIT_FUNCTIONS})
        ); 
 }
 
@@ -475,10 +504,10 @@ sub ProtoHeader($$)
                $ctx->{PUBLIC_PROTO_HEADER} = $ctx->{PRIVATE_PROTO_HEADER};
        }       
 
-       $self->output("$dir/$ctx->{PUBLIC_PROTO_HEADER}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST:.o=.c)\n");
+       $self->output("$dir/$ctx->{PUBLIC_PROTO_HEADER}: $ctx->{MK_FILE} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST:.o=.c)\n");
        $self->output("\t\@echo \"$comment\"\n");
 
-       $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --private=$dir/$ctx->{PRIVATE_PROTO_HEADER} --public=$dir/$ctx->{PUBLIC_PROTO_HEADER} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n\n");
+       $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --srcdir=\$(srcdir) --builddir=\$(builddir) --private=$dir/$ctx->{PRIVATE_PROTO_HEADER} --public=$dir/$ctx->{PUBLIC_PROTO_HEADER} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n\n");
 }
 
 sub write($$)
@@ -504,18 +533,26 @@ sub write($$)
 
        # nasty hack to allow running locally
        if ($self->{duplicate_build}) {
-               $self->output("bin/libdynconfig.\$(SHLIBEXT): dynconfig-devel.o\n");
-               $self->output("bin/libdynconfig.\$(SHLIBEXT): LIBRARY_DYNCONFIG_OBJ_LIST=dynconfig-devel.o\n");
+               $self->output("bin/libdynconfig.\$(SHLIBEXT).0.0.1: dynconfig-devel.o\n");
+               $self->output("bin/libdynconfig.\$(SHLIBEXT).0.0.1: LIBRARY_DYNCONFIG_OBJ_LIST=dynconfig-devel.o\n");
        }
 
        $self->_prepare_mk_files();
 
        $self->output($self->{mkfile});
 
-       if ($self->{developer}) {
-               $self->output("-include \$(DEP_FILES)\n");
+       if ($self->{automatic_deps}) {
+               $self->output("
+ifneq (\$(MAKECMDGOALS),clean)
+ifneq (\$(MAKECMDGOALS),distclean)
+ifneq (\$(MAKECMDGOALS),realdistclean)
+-include \$(DEP_FILES)
+endif
+endif
+endif
+");
        } else {
-               $self->output("include static_deps.mk\n");
+               $self->output("include \$(srcdir)/static_deps.mk\n");
        }
 
        open(MAKEFILE,">$file") || die ("Can't open $file\n");