diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-12-15 15:59:10 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:47:24 -0500 |
commit | f8be4e8a4fd853d97c5f3188e93747314618323a (patch) | |
tree | 5aedacafd011823c86cb29486169a9724ecb3978 /source4/build | |
parent | 6589e93b1b8a61860931a171a0306b270597e1f2 (diff) | |
download | samba-f8be4e8a4fd853d97c5f3188e93747314618323a.tar.gz samba-f8be4e8a4fd853d97c5f3188e93747314618323a.tar.bz2 samba-f8be4e8a4fd853d97c5f3188e93747314618323a.zip |
r12253: Automatically build seperate binaries without -rpath to install when
using shared libraries and developer mode is enabled.
(This used to be commit 507bee76dc26b048ead317ec5e10a9deb1ff7f09)
Diffstat (limited to 'source4/build')
-rw-r--r-- | source4/build/smb_build/TODO | 2 | ||||
-rw-r--r-- | source4/build/smb_build/input.pm | 41 | ||||
-rw-r--r-- | source4/build/smb_build/main.pl | 32 | ||||
-rw-r--r-- | source4/build/smb_build/makefile.pm | 59 | ||||
-rw-r--r-- | source4/build/smb_build/output.pm | 2 |
5 files changed, 80 insertions, 56 deletions
diff --git a/source4/build/smb_build/TODO b/source4/build/smb_build/TODO index 8fe11bfc85..190940fadb 100644 --- a/source4/build/smb_build/TODO +++ b/source4/build/smb_build/TODO @@ -3,8 +3,6 @@ - get rid of include/structs.h - install Samba-specific headers in $INCLUDEDIR/samba-4.0. talloc.h, tdb.h and ldb.h belong in $INCLUDEDIR -- never install -rpath binaries / libraries, always relink before install - - keep files without -rpath in bin/install - init functions may be called more then once as different libraries (in Samba or other projects) can use the same (3rd) library. - add register function to smbtorture diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm index ebc91a9107..de558e709a 100644 --- a/source4/build/smb_build/input.pm +++ b/source4/build/smb_build/input.pm @@ -8,11 +8,6 @@ use strict; package smb_build::input; -use vars qw($library_output_type $subsystem_output_type $module_output_type); - -$library_output_type = "OBJ_LIST"; -$subsystem_output_type = "OBJ_LIST"; -$module_output_type = "OBJ_LIST"; my $srcdir = "."; sub strtrim($) @@ -34,22 +29,22 @@ sub str2array($) return split /[ \t\n]/; } -sub check_subsystem($$) +sub check_subsystem($$$) { - my ($INPUT, $subsys) = @_; + my ($INPUT, $subsys, $default_ot) = @_; if ($subsys->{ENABLE} ne "YES") { printf("Subsystem `%s' disabled\n",$subsys->{NAME}); return; } unless(defined($subsys->{OUTPUT_TYPE})) { - $subsys->{OUTPUT_TYPE} = $subsystem_output_type; + $subsys->{OUTPUT_TYPE} = $default_ot; } } -sub check_module($$) +sub check_module($$$) { - my ($INPUT, $mod) = @_; + my ($INPUT, $mod, $default_ot) = @_; die("Module $mod->{NAME} does not have a SUBSYSTEM set") if not defined($mod->{SUBSYSTEM}); @@ -70,7 +65,7 @@ sub check_module($$) { $mod->{OUTPUT_TYPE} = $mod->{CHOSEN_BUILD}; } else { - $mod->{OUTPUT_TYPE} = $module_output_type; + $mod->{OUTPUT_TYPE} = $default_ot; } if ($mod->{OUTPUT_TYPE} eq "SHARED_LIBRARY" or @@ -82,17 +77,16 @@ sub check_module($$) } } -sub check_library($$) +sub check_library($$$) { - my ($INPUT, $lib) = @_; + my ($INPUT, $lib, $default_ot) = @_; if ($lib->{ENABLE} ne "YES") { printf("Library `%s' disabled\n",$lib->{NAME}); return; } - - $lib->{OUTPUT_TYPE} = $library_output_type; + $lib->{OUTPUT_TYPE} = $default_ot; unless (defined($lib->{MAJOR_VERSION})) { print "$lib->{NAME}: Please specify MAJOR_VERSION\n"; @@ -133,16 +127,9 @@ sub calc_unique_deps($$) } } -########################################################### -# This function checks the input from the configure script -# -# check_input($INPUT) -# -# $INPUT - the global INPUT context -# $enabled - list of enabled subsystems/libs -sub check($$) +sub check($$$$$) { - my ($INPUT, $enabled) = @_; + my ($INPUT, $enabled, $subsys_ot, $lib_ot, $module_ot) = @_; foreach my $part (values %$INPUT) { if (defined($enabled->{$part->{NAME}})) { @@ -158,9 +145,9 @@ sub check($$) foreach my $k (keys %$INPUT) { my $part = $INPUT->{$k}; - check_subsystem($INPUT, $part) if ($part->{TYPE} eq "SUBSYSTEM"); - check_module($INPUT, $part) if ($part->{TYPE} eq "MODULE"); - check_library($INPUT, $part) if ($part->{TYPE} eq "LIBRARY"); + check_subsystem($INPUT, $part, $subsys_ot) if ($part->{TYPE} eq "SUBSYSTEM"); + check_module($INPUT, $part, $module_ot) if ($part->{TYPE} eq "MODULE"); + check_library($INPUT, $part, $lib_ot) if ($part->{TYPE} eq "LIBRARY"); check_binary($INPUT, $part) if ($part->{TYPE} eq "BINARY"); } diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl index 0c027facc3..cb25fca4ac 100644 --- a/source4/build/smb_build/main.pl +++ b/source4/build/smb_build/main.pl @@ -18,34 +18,48 @@ my $INPUT = {}; my $mkfile = smb_build::config_mk::run_config_mk($INPUT, "main.mk"); +my $subsystem_output_type; + if (defined($ENV{"SUBSYSTEM_OUTPUT_TYPE"})) { - $smb_build::input::subsystem_output_type = $ENV{SUBSYSTEM_OUTPUT_TYPE}; + $subsystem_output_type = $ENV{SUBSYSTEM_OUTPUT_TYPE}; } elsif ($config::config{BLDMERGED} eq "true") { - $smb_build::input::subsystem_output_type = "MERGEDOBJ"; + $subsystem_output_type = "MERGEDOBJ"; +} else { + $subsystem_output_type = "OBJ_LIST"; } +my $library_output_type; if (defined($ENV{"LIBRARY_OUTPUT_TYPE"})) { - $smb_build::input::library_output_type = $ENV{LIBRARY_OUTPUT_TYPE}; + $library_output_type = $ENV{LIBRARY_OUTPUT_TYPE}; } elsif ($config::config{BLDSHARED} eq "true") { #FIXME: This should eventually become SHARED_LIBRARY # rather then MERGEDOBJ once I'm certain it works ok -- jelmer - $smb_build::input::library_output_type = "MERGEDOBJ"; + $library_output_type = "MERGEDOBJ"; } elsif ($config::config{BLDMERGED} eq "true") { - $smb_build::input::library_output_type = "MERGEDOBJ"; + $library_output_type = "MERGEDOBJ"; +} else { + $library_output_type = "OBJ_LIST"; } +my $module_output_type; if (defined($ENV{"MODULE_OUTPUT_TYPE"})) { - $smb_build::input::module_output_type = $ENV{MODULE_OUTPUT_TYPE}; + $module_output_type = $ENV{MODULE_OUTPUT_TYPE}; } elsif ($config::config{BLDSHARED} eq "true") { #FIXME: This should eventually become SHARED_LIBRARY # rather then MERGEDOBJ once I'm certain it works ok -- jelmer - $smb_build::input::module_output_type = "MERGEDOBJ"; + $module_output_type = "MERGEDOBJ"; } elsif ($config::config{BLDMERGED} eq "true") { - $smb_build::input::module_output_type = "MERGEDOBJ"; + $module_output_type = "MERGEDOBJ"; +} else { + $module_output_type = "OBJ_LIST"; } -my $DEPEND = smb_build::input::check($INPUT, \%config::enabled); +my $DEPEND = smb_build::input::check($INPUT, \%config::enabled, + $subsystem_output_type, $library_output_type, $module_output_type); my $OUTPUT = output::create_output($DEPEND); +$config::config{SUBSYSTEM_OUTPUT_TYPE} = $subsystem_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); foreach my $key (values %$OUTPUT) { diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm index d5ac6de6f9..986d1aa213 100644 --- a/source4/build/smb_build/makefile.pm +++ b/source4/build/smb_build/makefile.pm @@ -89,9 +89,16 @@ sub _prepare_compiler_linker($) { my ($self) = @_; - my $devld = ""; - if ($self->{developer}) { - $devld = " \$(DEVEL_LDFLAGS)"; + my $devld_local = ""; + my $devld_install = ""; + + $self->{duplicate_build} = 0; + if ($self->{config}->{LIBRARY_OUTPUT_TYPE} eq "SHARED_LIBRARY") { + if ($self->{developer}) { + $self->{duplicate_build} = 1; + $devld_local = " -Wl,-rpath,\$(builddir)/bin"; + } + $devld_install = " -Wl,-rpath-link,\$(builddir)/bin"; } $self->output(<< "__EOD__" @@ -107,15 +114,16 @@ CFLAGS=-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -D_SAMBA_BUILD_ -DHAVE PICFLAG=$self->{config}->{PICFLAG} HOSTCC=$self->{config}->{HOSTCC} -DEVEL_LDFLAGS=-Wl,-rpath,bin/ LD=$self->{config}->{LD} -LDFLAGS=$self->{config}->{LDFLAGS} -Lbin/$devld +LDFLAGS=$self->{config}->{LDFLAGS} -L\$(builddir)/bin +LOCAL_LINK_FLAGS=$devld_local +INSTALL_LINK_FLAGS=$devld_install STLD=$self->{config}->{AR} -STLD_FLAGS=-rc -Lbin/ +STLD_FLAGS=-rc -L\$(builddir)/bin SHLD=$self->{config}->{CC} -SHLD_FLAGS=$self->{config}->{LDSHFLAGS} -Lbin/$devld +SHLD_FLAGS=$self->{config}->{LDSHFLAGS} -L\$(builddir)/bin SONAMEFLAG=$self->{config}->{SONAMEFLAG} SHLIBEXT=$self->{config}->{SHLIBEXT} @@ -241,7 +249,7 @@ sub SharedLibrary($$) $self->output(<< "__EOD__" # -$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) bin/.dummy +bin/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) bin/.dummy \@echo Linking \$\@ \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \\ \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) \\ @@ -263,8 +271,6 @@ bin/$ctx->{LIBRARY_NAME}: bin/$ctx->{LIBRARY_SONAME} bin/.dummy __EOD__ ); } - - $self->output("library_$ctx->{NAME}: basics bin/lib$ctx->{LIBRARY_NAME}\n"); } sub MergedObj($$) @@ -318,8 +324,6 @@ $ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx-> \@\$(STLD) \$(STLD_FLAGS) \$@ \\ \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST) -library_$ctx->{NAME}: basics $ctx->{TARGET} - __EOD__ ); } @@ -337,28 +341,48 @@ sub Binary($$) { my ($self,$ctx) = @_; + my $installdir; + + if ($self->{duplicate_build}) { + $installdir = "bin/install"; + } else { + $installdir = "bin"; + } + unless (defined($ctx->{INSTALLDIR})) { } elsif ($ctx->{INSTALLDIR} eq "SBINDIR") { - push (@{$self->{sbin_progs}}, $ctx->{TARGET}); + push (@{$self->{sbin_progs}}, "$installdir/$ctx->{BINARY}"); } elsif ($ctx->{INSTALLDIR} eq "BINDIR") { - push (@{$self->{bin_progs}}, $ctx->{TARGET}); + push (@{$self->{bin_progs}}, "$installdir/$ctx->{BINARY}"); } + push (@{$self->{binaries}}, "bin/$ctx->{BINARY}"); + $self->_prepare_list($ctx, "OBJ_LIST"); $self->_prepare_list($ctx, "CFLAGS"); $self->_prepare_list($ctx, "DEPEND_LIST"); $self->_prepare_list($ctx, "LINK_LIST"); $self->_prepare_list($ctx, "LINK_FLAGS"); + if ($self->{duplicate_build}) { $self->output(<< "__EOD__" # -# bin/$ctx->{BINARY}: bin/.dummy \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) \@echo Linking \$\@ - \@\$(CC) \$(LDFLAGS) -o \$\@ \\ + \@\$(CC) \$(LDFLAGS) -o \$\@ \$(LOCAL_LINK_FLAGS) \\ \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST) \\ \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) -binary_$ctx->{BINARY}: basics bin/$ctx->{BINARY} + +__EOD__ +); + } + +$self->output(<< "__EOD__" +$installdir/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) + \@echo Linking \$\@ + \@\$(CC) \$(LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\ + \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST) \\ + \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) __EOD__ ); @@ -412,6 +436,7 @@ sub write($$) $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("BINARIES = " . array2oneperline($self->{binaries}) . "\n"); $self->output("STATIC_LIBS = " . array2oneperline($self->{static_libs}) . "\n"); $self->output("SHARED_LIBS = " . array2oneperline($self->{shared_libs}) . "\n"); $self->output("PUBLIC_HEADERS = " . array2oneperline($self->{headers}) . "\n"); diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm index b7a9653b2b..d39ff62101 100644 --- a/source4/build/smb_build/output.pm +++ b/source4/build/smb_build/output.pm @@ -51,7 +51,7 @@ sub generate_shared_library($) $link_name =~ s/^LIB//; $link_name = lc($link_name); - $lib->{LIBRARY_NAME} = "lib$link_name.\$(SHLIBEXT)"; + $lib->{LIBRARY_REALNAME} = $lib->{LIBRARY_NAME} = "lib$link_name.\$(SHLIBEXT)"; $lib->{TARGET} = "bin/$lib->{LIBRARY_NAME}"; if (defined($lib->{MAJOR_VERSION})) { $lib->{LIBRARY_SONAME} = $lib->{LIBRARY_NAME}.".$lib->{MAJOR_VERSION}"; |