summaryrefslogtreecommitdiff
path: root/source4/build/smb_build
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-10-28 18:26:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:45:28 -0500
commit93fd08168fdc881fdef099991bd7a22448841dc4 (patch)
tree4e70a8b329f194c401fb5f412c0e478f15744fc3 /source4/build/smb_build
parent17f8b87cb0731d716ac717b7796f50c252904b36 (diff)
downloadsamba-93fd08168fdc881fdef099991bd7a22448841dc4.tar.gz
samba-93fd08168fdc881fdef099991bd7a22448841dc4.tar.bz2
samba-93fd08168fdc881fdef099991bd7a22448841dc4.zip
r11377: Add support for building LIBRARY elements as shared libraries:
- Adds -rpath bin/ so you don't have to install Samba in order to use compiled binaries. - Writes out pkg-config files when building shared libs - Supports automatic fallback to MERGEDOBJ (which is the default) or OBJ_LIST (if ld -r is not supported) Building with shared libs reduces the size of the Samba binaries from 197 Mb to 60 Mb (including libraries) on my system (GCC4, with debugging). To build with shared libraries support enabled, run: LIBRARY_OUTPUT_TYPE=SHARED_LIBRARY ./config.status init functions don't get called correctly yet when using shared libs, so you won't be able to actually run anything with success :-) Once init functions are done, I'll look at support for loading shared modules once again. Based on a patch by Peter Novodvorsky (nidd on IRC). (This used to be commit 0b54405685674a2b19a28d77aae5b1136b5a4728)
Diffstat (limited to 'source4/build/smb_build')
-rw-r--r--source4/build/smb_build/config_mk.pm8
-rw-r--r--source4/build/smb_build/env.pm11
-rw-r--r--source4/build/smb_build/input.pm25
-rw-r--r--source4/build/smb_build/main.pl3
-rw-r--r--source4/build/smb_build/makefile.pm34
-rw-r--r--source4/build/smb_build/output.pm31
6 files changed, 76 insertions, 36 deletions
diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm
index 2adc219605..d7408a5f8f 100644
--- a/source4/build/smb_build/config_mk.pm
+++ b/source4/build/smb_build/config_mk.pm
@@ -26,7 +26,6 @@ my $section_types = {
"OBJ_FILES" => "list",
"REQUIRED_SUBSYSTEMS" => "list",
- "TARGET_DEPS" => "list",
"ENABLE" => "bool",
"NOPROTO" => "bool",
@@ -42,7 +41,6 @@ my $section_types = {
"OBJ_FILES" => "list",
"REQUIRED_SUBSYSTEMS" => "list",
- "TARGET_DEPS" => "list",
"ENABLE" => "bool",
"NOPROTO" => "bool",
@@ -53,7 +51,6 @@ my $section_types = {
"OBJ_FILES" => "list",
"REQUIRED_SUBSYSTEMS" => "list",
- "TARGET_DEPS" => "list",
"ENABLE" => "bool",
"NOPROTO" => "bool",
@@ -65,12 +62,15 @@ my $section_types = {
"MAJOR_VERSION" => "string",
"MINOR_VERSION" => "string",
"RELEASE_VERSION" => "string",
+
+ "INIT_FUNCTION" => "string",
"INIT_OBJ_FILES" => "list",
"ADD_OBJ_FILES" => "list",
"OBJ_FILES" => "list",
+ "DESCRIPTION" => "string",
+
"REQUIRED_SUBSYSTEMS" => "list",
- "TARGET_DEPS" => "list",
"ENABLE" => "bool",
"NOPROTO" => "bool",
diff --git a/source4/build/smb_build/env.pm b/source4/build/smb_build/env.pm
index b3dcbb8456..8acd7dd932 100644
--- a/source4/build/smb_build/env.pm
+++ b/source4/build/smb_build/env.pm
@@ -50,9 +50,9 @@ sub _set_config($$)
}
}
-sub PkgConfig($$$$$$)
+sub PkgConfig($$$$$$$)
{
- my ($self,$path,$name,$libs,$cflags,$version) = @_;
+ my ($self,$path,$name,$libs,$cflags,$version,$desc) = @_;
print __FILE__.": creating $path\n";
@@ -67,9 +67,12 @@ includedir=$self->{config}->{includedir}
__EOF__
print OUT "Name: $name\n";
+ if (defined($desc)) {
+ print OUT "Description: $desc\n";
+ }
print OUT "Version: $version\n";
- print OUT "Libs: $libs\n";
- print OUT "Cflags: $cflags\n";
+ print OUT "Libs: -L\${libdir} $libs\n";
+ print OUT "Cflags: -I\${includedir} $cflags\n";
close(OUT);
}
diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm
index e685f41157..88d7c24af8 100644
--- a/source4/build/smb_build/input.pm
+++ b/source4/build/smb_build/input.pm
@@ -39,7 +39,7 @@ sub check_subsystem($$)
{
my ($INPUT, $subsys) = @_;
if ($subsys->{ENABLE} ne "YES") {
- printf("Subsystem: %s disabled!\n",$subsys->{NAME});
+ printf("Subsystem `%s' disabled\n",$subsys->{NAME});
return;
}
@@ -54,7 +54,6 @@ sub check_module($$)
die("Module $mod->{NAME} does not have a SUBSYSTEM set") if not defined($mod->{SUBSYSTEM});
-
($mod->{DEFAULT_BUILD} = "STATIC") if not defined($mod->{DEFAULT_BUILD});
my $use_default = 0;
@@ -62,7 +61,6 @@ sub check_module($$)
if (!(defined($INPUT->{$mod->{SUBSYSTEM}}))) {
$mod->{BUILD} = "NOT";
$mod->{ENABLE} = "NO";
- printf("Module: %s...PARENT SUBSYSTEM ($mod->{SUBSYSTEM}) DISABLED\n",$mod->{NAME});
return;
}
@@ -85,15 +83,13 @@ sub check_module($$)
$mod->{OUTPUT_TYPE} = "SHARED_LIBRARY";
$mod->{INSTALLDIR} = "LIBDIR/$mod->{SUBSYSTEM}";
push (@{$mod->{REQUIRED_SUBSYSTEMS}}, $mod->{SUBSYSTEM});
- printf("Module: %s...shared\n",$mod->{NAME});
} elsif ($mod->{CHOSEN_BUILD} eq "STATIC") {
$mod->{ENABLE} = "YES";
push (@{$INPUT->{$mod->{SUBSYSTEM}}{REQUIRED_SUBSYSTEMS}}, $mod->{NAME});
- printf("Module: %s...static\n",$mod->{NAME});
$mod->{OUTPUT_TYPE} = $subsystem_output_type;
} else {
$mod->{ENABLE} = "NO";
- printf("Module: %s...not\n",$mod->{NAME});
+ printf("Module `%s' disabled\n",$mod->{NAME});
return;
}
}
@@ -103,12 +99,18 @@ sub check_library($$)
my ($INPUT, $lib) = @_;
if ($lib->{ENABLE} ne "YES") {
- printf("Library: %s...disabled\n",$lib->{NAME});
+ printf("Library `%s' disabled\n",$lib->{NAME});
return;
}
+
$lib->{OUTPUT_TYPE} = $library_output_type;
+ unless (defined($lib->{MAJOR_VERSION})) {
+ print "$lib->{NAME}: Please specify MAJOR_VERSION\n";
+ return;
+ }
+
$lib->{INSTALLDIR} = "LIBDIR";
}
@@ -117,7 +119,7 @@ sub check_binary($$)
my ($INPUT, $bin) = @_;
if ($bin->{ENABLE} ne "YES") {
- printf("Binary: %s...disabled\n",$bin->{NAME});
+ printf("Binary `%s' disabled\n",$bin->{NAME});
return;
}
@@ -133,8 +135,11 @@ sub calc_unique_deps($$)
foreach my $dep (@{$deps}) {
if (not defined($udeps->{$$dep->{NAME}})) {
- $udeps->{$$dep->{NAME}} = "BUSY";
- calc_unique_deps($$dep->{DEPENDENCIES}, $udeps);
+ if (defined ($$dep->{OUTPUT_TYPE}) && (($$dep->{OUTPUT_TYPE} eq "OBJ_LIST")
+ or ($$dep->{OUTPUT_TYPE} eq "MERGEDOBJ"))) {
+ $udeps->{$$dep->{NAME}} = "BUSY";
+ calc_unique_deps($$dep->{DEPENDENCIES}, $udeps);
+ }
$udeps->{$$dep->{NAME}} = $$dep;
}
}
diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl
index 85e48e6ed9..a207062d34 100644
--- a/source4/build/smb_build/main.pl
+++ b/source4/build/smb_build/main.pl
@@ -30,7 +30,8 @@ if (defined($ENV{"SUBSYSTEM_OUTPUT_TYPE"})) {
if (defined($ENV{"LIBRARY_OUTPUT_TYPE"})) {
$smb_build::input::library_output_type = $ENV{LIBRARY_OUTPUT_TYPE};
} elsif ($config::config{BLDSHARED} eq "true") {
- # FIXME: This should really be SHARED_LIBRARY
+ #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";
} elsif ($config::config{BLDMERGED} eq "true") {
$smb_build::input::library_output_type = "MERGEDOBJ";
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index be49a612c9..a84d336716 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -91,6 +91,11 @@ sub _prepare_compiler_linker($)
{
my ($self) = @_;
+ my $devld = "";
+ if ($self->{developer}) {
+ $devld = " \$(DEVEL_LDFLAGS)";
+ }
+
$self->output(<< "__EOD__"
SHELL=$self->{config}->{SHELL}
@@ -104,14 +109,15 @@ HOSTCC=$self->{config}->{HOSTCC}
CPP=$self->{config}->{CPP}
CPPFLAGS=$self->{config}->{CPPFLAGS}
-LD=$self->{config}->{LD}
-LD_FLAGS=$self->{config}->{LDFLAGS}
+DEVEL_LDFLAGS=-Wl,-rpath,bin/
+LD=$self->{config}->{LD}
+LDFLAGS=$self->{config}->{LDFLAGS} -Lbin/$devld
STLD=$self->{config}->{AR}
-STLD_FLAGS=-rc
+STLD_FLAGS=-rc -Lbin/
SHLD=$self->{config}->{CC}
-SHLD_FLAGS=$self->{config}->{LDSHFLAGS}
+SHLD_FLAGS=$self->{config}->{LDSHFLAGS} -Lbin/$devld
SONAMEFLAG=$self->{config}->{SONAMEFLAG}
SHLIBEXT=$self->{config}->{SHLIBEXT}
@@ -236,7 +242,7 @@ sub SharedLibrary($$)
{
my ($self,$ctx) = @_;
- push (@{$self->{shared_libs}}, $ctx->{OUTPUT});
+ push (@{$self->{shared_libs}}, "bin/$ctx->{LIBRARY_NAME}");
$self->_prepare_obj_list($ctx->{TYPE}, $ctx);
$self->_prepare_cflags($ctx->{TYPE}, $ctx);
@@ -374,7 +380,7 @@ BINARY_$ctx->{NAME}_LINK_FLAGS =$tmpflag
#
bin/$ctx->{BINARY}: bin/.dummy \$(BINARY_$ctx->{NAME}_DEPEND_LIST) \$(BINARY_$ctx->{NAME}_OBJS)
\@echo Linking \$\@
- \@\$(CC) \$(LD_FLAGS) -o \$\@ \\
+ \@\$(CC) \$(LDFLAGS) -o \$\@ \\
\$\(BINARY_$ctx->{NAME}_LINK_FLAGS) \\
\$\(BINARY_$ctx->{NAME}_LINK_LIST) \\
\$\(BINARY_$ctx->{NAME}_LINK_FLAGS)
@@ -399,11 +405,23 @@ sub PkgConfig($$)
{
my ($self,$ctx) = @_;
- my $path = "$ctx->{BASEDIR}/$ctx->{NAME}.pc";
+ my $link_name = $ctx->{NAME};
+
+ $link_name =~ s/^LIB//g;
+ $link_name = lc($link_name);
+
+ my $path = "$ctx->{BASEDIR}/$link_name.pc";
push (@{$self->{pc_files}}, $path);
- smb_build::env::PkgConfig($self,$path,$ctx->{NAME},"FIXME",join(' ', @{$ctx->{CFLAGS}}), "$ctx->{MAJOR_VERSION}.$ctx->{MINOR_VERSION}.$ctx->{RELEASE_VERSION}");
+ smb_build::env::PkgConfig($self,
+ $path,
+ $link_name,
+ $ctx->{OUTPUT},
+ join(' ', @{$ctx->{CFLAGS}}),
+ "$ctx->{MAJOR_VERSION}.$ctx->{MINOR_VERSION}.$ctx->{RELEASE_VERSION}",
+ $ctx->{DESCRIPTION}
+ );
}
sub ProtoHeader($$)
diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm
index b1edf02c94..2dc74562f6 100644
--- a/source4/build/smb_build/output.pm
+++ b/source4/build/smb_build/output.pm
@@ -44,32 +44,42 @@ sub generate_objlist($)
sub generate_shared_library($)
{
my $lib = shift;
+ my $link_name;
@{$lib->{DEPEND_LIST}} = ();
@{$lib->{LINK_LIST}} = ("\$($lib->{TYPE}_$lib->{NAME}\_OBJS)");
- $lib->{LIBRARY_NAME} = lc($lib->{NAME}).".so";
- $lib->{TARGET} = "bin/lib$lib->{LIBRARY_NAME}";
+
+ $link_name = $lib->{NAME};
+ $link_name =~ s/^LIB//;
+ $link_name = lc($link_name);
+
+ $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}";
$lib->{LIBRARY_REALNAME} = $lib->{LIBRARY_SONAME}.".$lib->{MINOR_VERSION}.$lib->{RELEASE_VERSION}";
- $lib->{TARGET} = "bin/lib$lib->{LIBRARY_REALNAME}";
+ $lib->{TARGET} = "bin/$lib->{LIBRARY_REALNAME}";
@{$lib->{LINK_FLAGS}} = ("\$(SONAMEFLAG)$lib->{LIBRARY_SONAME}");
}
- $lib->{OUTPUT} = "-l".lc($lib->{NAME});
+ $lib->{OUTPUT} = "-l$link_name";
}
sub generate_static_library($)
{
my $lib = shift;
+ my $link_name;
@{$lib->{DEPEND_LIST}} = ();
- $lib->{LIBRARY_NAME} = lc($lib->{NAME}).".a";
+ $link_name = $lib->{NAME};
+ $link_name =~ s/^LIB//;
+
+ $lib->{LIBRARY_NAME} = "lib".lc($link_name).".a";
@{$lib->{LINK_LIST}} = ("\$($lib->{TYPE}_$lib->{NAME}\_OBJS)");
@{$lib->{LINK_FLAGS}} = ();
- $lib->{TARGET} = "bin/lib$lib->{LIBRARY_NAME}";
- $lib->{OUTPUT} = "-l".lc($lib->{NAME});
+ $lib->{TARGET} = "bin/$lib->{LIBRARY_NAME}";
+ $lib->{OUTPUT} = "-l".lc($link_name);
}
sub generate_binary($)
@@ -145,8 +155,11 @@ sub create_output($)
push(@{$part->{LINK_LIST}}, $elem->{OUTPUT}) if defined($elem->{OUTPUT});
push(@{$part->{LINK_FLAGS}}, @{$elem->{LIBS}}) if defined($elem->{LIBS});
push(@{$part->{LINK_FLAGS}},@{$elem->{LDFLAGS}}) if defined($elem->{LDFLAGS});
- push(@{$part->{DEPEND_LIST}}, $elem->{TARGET}) if defined($elem->{TARGET});
-
+ if (defined($elem->{OUTPUT_TYPE}) and ($elem->{OUTPUT_TYPE} eq "SHARED_LIBRARY")) {
+ push(@{$part->{DEPEND_LIST}}, "bin/$elem->{LIBRARY_NAME}");
+ } else {
+ push(@{$part->{DEPEND_LIST}}, $elem->{TARGET}) if defined($elem->{TARGET});
+ }
push(@{$part->{SUBSYSTEM_INIT_FUNCTIONS}}, $elem->{INIT_FUNCTION}) if
$part->{OUTPUT_TYPE} eq "BINARY" and
defined($elem->{INIT_FUNCTION}) and