diff options
Diffstat (limited to 'source4/build/smb_build/makefile.pm')
-rw-r--r-- | source4/build/smb_build/makefile.pm | 140 |
1 files changed, 46 insertions, 94 deletions
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm index 17474db00e..23caec083f 100644 --- a/source4/build/smb_build/makefile.pm +++ b/source4/build/smb_build/makefile.pm @@ -21,17 +21,6 @@ sub new($$$) bless($self, $myname); - $self->{manpages} = []; - $self->{sbin_progs} = []; - $self->{bin_progs} = []; - $self->{static_libs} = []; - $self->{python_dsos} = []; - $self->{python_pys} = []; - $self->{shared_libs} = []; - $self->{headers} = []; - $self->{plugins} = []; - $self->{pc_files} = []; - $self->{proto_headers} = []; $self->{output} = ""; $self->{mkfile} = $mkfile; @@ -123,23 +112,19 @@ sub SharedModule($$) { my ($self,$ctx) = @_; - my $init_obj = ""; - my $sane_subsystem = lc($ctx->{SUBSYSTEM}); $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"); $self->output("\t\@cp $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n"); if (defined($ctx->{ALIASES})) { foreach (@{$ctx->{ALIASES}}) { - $self->output("\t\@rm -f \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n"); $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n"); } } @@ -160,43 +145,24 @@ sub SharedModule($$) $self->_prepare_list($ctx, "DEPEND_LIST"); $self->_prepare_list($ctx, "LINK_FLAGS"); - if (defined($ctx->{INIT_FUNCTION}) and $ctx->{TYPE} ne "PYTHON" and + if (defined($ctx->{INIT_FUNCTION}) and $ctx->{TYPE} ne "PYTHON" and $ctx->{INIT_FUNCTION_TYPE} =~ /\(\*\)/) { - my $init_fn = $ctx->{INIT_FUNCTION_TYPE}; - $init_fn =~ s/\(\*\)/init_module/; - my $proto_fn = $ctx->{INIT_FUNCTION_TYPE}; - $proto_fn =~ s/\(\*\)/$ctx->{INIT_FUNCTION}/; - - $self->output(<< "__EOD__" -bin/$ctx->{NAME}_init_module.c: - \@echo Creating \$\@ - \@echo \"#include \\\"includes.h\\\"\" > \$\@ - \@echo \"$proto_fn;\" >> \$\@ - \@echo \"_PUBLIC_ $init_fn\" >> \$\@ - \@echo \"{\" >> \$\@ - \@echo \" return $ctx->{INIT_FUNCTION}();\" >> \$\@ - \@echo \"}\" >> \$\@ - \@echo \"\" >> \$\@ -__EOD__ -); - $init_obj = "bin/$ctx->{NAME}_init_module.o"; + $self->output("\$($ctx->{NAME}_OBJ_LIST): CFLAGS+=-D$ctx->{INIT_FUNCTION}=init_module\n"); } $self->output(<< "__EOD__" -# -$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST) $init_obj +$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_OBJ_LIST) \@echo Linking \$\@ - \@mkdir -p $ctx->{SHAREDDIR} + \@mkdir -p \$(\@D) \@\$(MDLD) \$(LDFLAGS) \$(MDLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\ - \$($ctx->{NAME}\_FULL_OBJ_LIST) $init_obj \\ + \$($ctx->{NAME}\_FULL_OBJ_LIST) \\ \$($ctx->{NAME}_LINK_FLAGS) __EOD__ ); if (defined($ctx->{ALIASES})) { foreach (@{$ctx->{ALIASES}}) { - $self->output("\t\@rm -f $ctx->{SHAREDDIR}/$_.\$(SHLIBEXT)\n"); $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$_.\$(SHLIBEXT)\n"); } } @@ -220,36 +186,28 @@ sub SharedLibrary($$) { my ($self,$ctx) = @_; - push (@{$self->{shared_libs}}, $ctx->{RESULT_SHARED_LIBRARY}) if (defined($ctx->{SO_VERSION})); + $self->output("SHARED_LIBS += $ctx->{RESULT_SHARED_LIBRARY}\n") if (defined($ctx->{SO_VERSION})); $self->_prepare_list($ctx, "DEPEND_LIST"); $self->_prepare_list($ctx, "LINK_FLAGS"); - my $soarg = ""; - my $lns = ""; - if ($self->{config}->{SONAMEFLAG} ne "#" and defined($ctx->{LIBRARY_SONAME})) { - $soarg = "$self->{config}->{SONAMEFLAG}$ctx->{LIBRARY_SONAME}"; - if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) { - $lns .= "\n\t\@test \$($ctx->{NAME}_VERSION) = \$($ctx->{NAME}_SOVERSION) || ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}"; - } - } - - if (defined($ctx->{LIBRARY_SONAME})) { - $lns .= "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}"; - } - $self->output(<< "__EOD__" -# + $ctx->{RESULT_SHARED_LIBRARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST) \@echo Linking \$\@ \@mkdir -p $ctx->{SHAREDDIR} \@\$(SHLD) \$(LDFLAGS) \$(SHLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\ \$($ctx->{NAME}\_FULL_OBJ_LIST) \\ \$($ctx->{NAME}_LINK_FLAGS) \\ - $soarg$lns + \$(if \$(SONAMEFLAG), \$(SONAMEFLAG)$ctx->{LIBRARY_SONAME}) __EOD__ ); - $self->output("\n"); + if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) { + $self->output("\t\@test \$($ctx->{NAME}_VERSION) = \$($ctx->{NAME}_SOVERSION) || ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}\n"); + } + $self->output("ifdef $ctx->{NAME}_SOVERSION\n"); + $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}\n"); + $self->output("endif\n"); } sub MergedObj($$) @@ -270,7 +228,7 @@ __EOD__ ); } -sub StaticLibrary($$) +sub StaticLibraryPrimitives($$) { my ($self,$ctx) = @_; @@ -280,39 +238,49 @@ sub StaticLibrary($$) $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n"); $self->_prepare_list($ctx, "FULL_OBJ_LIST"); +} - $self->output(<< "__EOD__" -# -$ctx->{RESULT_STATIC_LIBRARY}: \$($ctx->{NAME}_FULL_OBJ_LIST) - \@echo Linking \$@ - \@rm -f \$@ - \@mkdir -p $ctx->{STATICDIR} - \@\$(STLD) \$(STLD_FLAGS) \$@ \$($ctx->{NAME}_FULL_OBJ_LIST) +sub InitFunctions($$) +{ + my ($self, $ctx) = @_; + $self->output("\$($ctx->{NAME}_OBJ_LIST): CFLAGS+=-DSTATIC_$ctx->{NAME}_MODULES=\"\$($ctx->{NAME}_INIT_FUNCTIONS)$ctx->{INIT_FUNCTION_SENTINEL}\"\n"); +} -__EOD__ -); +sub StaticLibrary($$) +{ + my ($self,$ctx) = @_; + + return unless (defined($ctx->{OBJ_FILES})); + + $self->output("STATIC_LIBS += $ctx->{RESULT_STATIC_LIBRARY}\n") if ($ctx->{TYPE} eq "LIBRARY"); + $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n"); + $self->output("$ctx->{RESULT_STATIC_LIBRARY}: \$($ctx->{NAME}_FULL_OBJ_LIST)\n"); } sub Header($$) { my ($self,$ctx) = @_; + return if ($#{$ctx->{PUBLIC_HEADERS}} == -1); + + $self->output("PUBLIC_HEADERS +="); + foreach (@{$ctx->{PUBLIC_HEADERS}}) { - push (@{$self->{headers}}, output::add_dir_str($ctx->{BASEDIR}, $_)); + $self->output(" " . output::add_dir_str($ctx->{BASEDIR}, $_)); } + + $self->output("\n"); } sub Binary($$) { my ($self,$ctx) = @_; - my $extradir = ""; - unless (defined($ctx->{INSTALLDIR})) { } elsif ($ctx->{INSTALLDIR} eq "SBINDIR") { - push (@{$self->{sbin_progs}}, $ctx->{RESULT_BINARY}); + $self->output("SBIN_PROGS += $ctx->{RESULT_BINARY}\n"); } elsif ($ctx->{INSTALLDIR} eq "BINDIR") { - push (@{$self->{bin_progs}}, $ctx->{RESULT_BINARY}); + $self->output("BIN_PROGS += $ctx->{RESULT_BINARY}\n"); } $self->output("binaries:: $ctx->{TARGET_BINARY}\n"); @@ -350,10 +318,8 @@ sub PythonFiles($$) foreach (@{$ctx->{PYTHON_FILES}}) { my $target = "bin/python/".basename($_); my $source = output::add_dir_str($ctx->{BASEDIR}, $_); - $self->output("$target: $source\n" . - "\tmkdir -p \$(builddir)/bin/python\n" . - "\tcp $source \$@\n\n"); - push (@{$self->{python_pys}}, $target); + $self->output("$target: $source\n\n"); + $self->output("PYTHON_PYS += $target\n"); } } @@ -361,8 +327,7 @@ sub Manpage($$) { my ($self,$ctx) = @_; - my $path = output::add_dir_str($ctx->{BASEDIR}, $ctx->{MANPAGE}); - push (@{$self->{manpages}}, $path); + $self->output("MANPAGES += " . output::add_dir_str($ctx->{BASEDIR}, $ctx->{MANPAGE}) . "\n"); } sub ProtoHeader($$) @@ -383,7 +348,7 @@ sub ProtoHeader($$) $comment .= " and "; $target.= " "; } - push (@{$self->{proto_headers}}, $priv); + $self->output("PROTO_HEADERS += $priv\n"); } else { $ctx->{PRIVATE_PROTO_HEADER} = $ctx->{PUBLIC_PROTO_HEADER}; $priv = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PRIVATE_PROTO_HEADER}); @@ -393,7 +358,7 @@ sub ProtoHeader($$) $pub = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PUBLIC_PROTO_HEADER}); $comment .= $pub; $target .= $pub; - push (@{$self->{proto_headers}}, $pub); + $self->output("PROTO_HEADERS += $pub\n"); } else { $ctx->{PUBLIC_PROTO_HEADER} = $ctx->{PRIVATE_PROTO_HEADER}; $pub = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PUBLIC_PROTO_HEADER}); @@ -408,19 +373,6 @@ sub write($$) { my ($self, $file) = @_; - $self->output("MANPAGES = " . array2oneperline($self->{manpages})."\n"); - $self->output("BIN_PROGS = " . array2oneperline($self->{bin_progs}) . "\n"); - $self->output("SBIN_PROGS = " . array2oneperline($self->{sbin_progs}) . "\n"); - $self->output("STATIC_LIBS = " . array2oneperline($self->{static_libs}) . "\n"); - $self->output("SHARED_LIBS = " . array2oneperline($self->{shared_libs}) . "\n"); - $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("PROTO_HEADERS = " . array2oneperline($self->{proto_headers}) . "\n"); - $self->output("PLUGINS = " . array2oneperline($self->{plugins}) . "\n"); - $self->_prepare_mk_files(); $self->output($self->{mkfile}); |