summaryrefslogtreecommitdiff
path: root/source4/build/smb_build
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-07-21 21:27:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:29:54 -0500
commitc84512f0e1c1dd6ac0cb3e9b5e2fbb2f3c0d4eb1 (patch)
tree81abe1ecfa802a9d77ec4aa27e7b3df134d7e2e2 /source4/build/smb_build
parent2a65d17e06da3b1f1f78d9586fd82a79ba2f73a6 (diff)
downloadsamba-c84512f0e1c1dd6ac0cb3e9b5e2fbb2f3c0d4eb1.tar.gz
samba-c84512f0e1c1dd6ac0cb3e9b5e2fbb2f3c0d4eb1.tar.bz2
samba-c84512f0e1c1dd6ac0cb3e9b5e2fbb2f3c0d4eb1.zip
r8690: Code cleanups, improvements necessary for dependencies (not added yet)
(This used to be commit 7384b3c4a1450ad63356dcf586e3a7e7335f8e6d)
Diffstat (limited to 'source4/build/smb_build')
-rw-r--r--source4/build/smb_build/config_mk.pm3
-rw-r--r--source4/build/smb_build/input.pm56
-rw-r--r--source4/build/smb_build/main.pm12
-rw-r--r--source4/build/smb_build/makefile.pm58
-rw-r--r--source4/build/smb_build/smb_build_h.pm5
5 files changed, 45 insertions, 89 deletions
diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm
index 0ac45cfefa..ba8badc3d1 100644
--- a/source4/build/smb_build/config_mk.pm
+++ b/source4/build/smb_build/config_mk.pm
@@ -154,8 +154,7 @@ sub _parse_config_mk($)
sub import_file($$)
{
- my $input = shift;
- my $filename = shift;
+ my ($input, $filename) = @_;
my $result = _parse_config_mk($filename);
diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm
index aeab3cb8a6..d469550a76 100644
--- a/source4/build/smb_build/input.pm
+++ b/source4/build/smb_build/input.pm
@@ -15,40 +15,26 @@ my $srcdir = ".";
sub strtrim($)
{
- my $str = shift;
- my @ar = ();
-
- $str =~ s/^[\t\n ]*//g;
-
- $str =~ s/[\t\n ]*$//g;
-
- return $str;
+ $_ = shift;
+ s/^[\t\n ]*//g;
+ s/[\t\n ]*$//g;
+ return $_;
}
sub str2array($)
{
- my $str = shift;
- my @ar = ();
-
- $str =~ s/^[\t\n ]*//g;
-
- $str =~ s/[\t\n ]*$//g;
-
- $str =~ s/([\t\n ]+)/ /g;
-
- if (length($str)==0) {
- return ();
- }
+ $_ = shift;
+ s/^[\t\n ]*//g;
+ s/[\t\n ]*$//g;
+ s/([\t\n ]+)/ /g;
- @ar = split(/[ \t\n]/,$str);
-
- return @ar;
+ return () if (length($_)==0);
+ return split /[ \t\n]/;
}
sub check_subsystem($$)
{
- my $INPUT = shift;
- my $subsys = shift;
+ my ($INPUT, $subsys) = @_;
if ($subsys->{ENABLE} ne "YES") {
printf("Subsystem: %s disabled!\n",$subsys->{NAME});
return;
@@ -61,8 +47,7 @@ sub check_subsystem($$)
sub check_module($$)
{
- my $INPUT = shift;
- my $mod = shift;
+ my ($INPUT, $mod) = @_;
die("Module $mod->{NAME} does not have a SUBSYSTEM set") if not defined($mod->{SUBSYSTEM});
@@ -105,8 +90,7 @@ sub check_module($$)
sub check_library($$)
{
- my $INPUT = shift;
- my $lib = shift;
+ my ($INPUT, $lib) = @_;
if ($lib->{ENABLE} ne "YES") {
printf("Library: %s...disabled\n",$lib->{NAME});
@@ -118,8 +102,7 @@ sub check_library($$)
sub check_target($$)
{
- my $INPUT = shift;
- my $bin = shift;
+ my ($INPUT, $bin) = @_;
if (!defined($bin->{CMD})) {
print "CMD not defined for target!\n";
@@ -130,8 +113,7 @@ sub check_target($$)
sub check_binary($$)
{
- my $INPUT = shift;
- my $bin = shift;
+ my ($INPUT, $bin) = @_;
if ($bin->{ENABLE} ne "YES") {
printf("Binary: %s...disabled\n",$bin->{NAME});
@@ -143,10 +125,10 @@ sub check_binary($$)
$bin->{OUTPUT_TYPE} = "BINARY";
}
-sub calc_unique_deps
+sub calc_unique_deps($$)
{
- my $deps = shift;
- my $udeps = shift;
+ sub calc_unique_deps($$);
+ my ($deps, $udeps) = @_;
foreach my $dep (@{$deps}) {
if (not defined($udeps->{$$dep->{NAME}})) {
@@ -157,8 +139,6 @@ sub calc_unique_deps
}
}
-
-
###########################################################
# This function checks the input from the configure script
#
diff --git a/source4/build/smb_build/main.pm b/source4/build/smb_build/main.pm
index 6e027af45a..950d02a2f6 100644
--- a/source4/build/smb_build/main.pm
+++ b/source4/build/smb_build/main.pm
@@ -18,15 +18,17 @@ my $config_list = "config.list";
sub smb_build_main($$)
{
- my $INPUT = shift;
- my $settings = shift;
+ my ($INPUT, $settings) = @_;
- my @mkfiles = split('\n', `grep -v ^# $config_list`);
+ open(IN, $config_list) or die("Can't open $config_list: $!");
+ my @mkfiles = grep{!/^#/} <IN>;
+ close(IN);
$| = 1;
- for my $mkfile (@mkfiles) {
- config_mk::import_file($INPUT, $mkfile);
+ foreach (@mkfiles) {
+ s/\n//g;
+ config_mk::import_file($INPUT, $_);
}
my $DEPEND = input::check($INPUT);
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index 8a157d8032..38d93f636c 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -252,16 +252,12 @@ __EOD__
sub array2oneperline($)
{
my $array = shift;
- my $i;
my $output = "";
- foreach my $str (@{$array}) {
- if (!defined($str)) {
- next;
- }
+ foreach (@$array) {
+ next unless defined($_);
- $output .= " \\\n\t\t";
- $output .= $str;
+ $output .= " \\\n\t\t$_";
}
return $output;
@@ -273,13 +269,10 @@ sub array2oneline($)
my $i;
my $output = "";
- foreach my $str (@{$array}) {
- if (!defined($str)) {
- next;
- }
+ foreach (@{$array}) {
+ next unless defined($_);
- $output .= $str;
- $output .= " ";
+ $output .= "$_ ";
}
return $output;
@@ -298,8 +291,7 @@ sub array2oneline($)
# $output - the resulting output buffer
sub _prepare_obj_list($$)
{
- my $var = shift;
- my $ctx = shift;
+ my ($var,$ctx) = @_;
my $tmplist = array2oneperline($ctx->{OBJ_LIST});
@@ -312,8 +304,7 @@ __EOD__
sub _prepare_cflags($$)
{
- my $var = shift;
- my $ctx = shift;
+ my ($var,$ctx) = @_;
my $tmplist = array2oneperline($ctx->{CFLAGS});
@@ -354,7 +345,6 @@ sub _prepare_shared_library_rule($)
my $output;
$tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
-
$tmpshlink = array2oneperline($ctx->{LINK_LIST});
$tmpshflag = array2oneperline($ctx->{LINK_FLAGS});
@@ -401,14 +391,10 @@ sub _prepare_objlist_rule($)
my $tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
my $output;
- if (! $ctx->{TARGET}) {
- return "";
- }
+ return "" unless $ctx->{TARGET};
$output = "$ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST = $tmpdepend\n";
-
$output .= "$ctx->{TARGET}: ";
-
$output .= "\$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJS)\n";
$output .= "\t\@touch $ctx->{TARGET}\n";
@@ -444,7 +430,6 @@ sub _prepare_static_library_rule($)
my $output;
$tmpdepend = array2oneperline($ctx->{DEPEND_LIST});
-
$tmpstlink = array2oneperline($ctx->{LINK_LIST});
$tmpstflag = array2oneperline($ctx->{LINK_FLAGS});
@@ -524,8 +509,9 @@ bin/.TARGET_$ctx->{NAME}:
";
}
-sub _prepare_proto_rules()
+sub _prepare_proto_rules($)
{
+ my $settings = shift;
my $output = "";
$output .= << '__EOD__';
@@ -775,13 +761,14 @@ __EOD__
return $output;
}
-sub _prepare_rule_lists($)
+sub _prepare_rule_lists($$)
{
my $depend = shift;
+ my $settings = shift;
my $output = "";
foreach my $key (values %{$depend}) {
- next if not defined $key->{OUTPUT_TYPE};
+ next unless defined $key->{OUTPUT_TYPE};
($output .= _prepare_objlist_rule($key)) if $key->{OUTPUT_TYPE} eq "OBJLIST";
($output .= _prepare_static_library_rule($key)) if $key->{OUTPUT_TYPE} eq "STATIC_LIBRARY";
@@ -792,9 +779,7 @@ sub _prepare_rule_lists($)
my $idl_ctx;
$output .= _prepare_IDL($idl_ctx);
-
- $output .= _prepare_proto_rules();
-
+ $output .= _prepare_proto_rules($settings);
$output .= _prepare_install_rules($depend);
return $output;
@@ -810,8 +795,7 @@ sub _prepare_rule_lists($)
# $output - the resulting output buffer
sub _prepare_makefile_in($$)
{
- my $CTX = shift;
- my $settings = shift;
+ my ($CTX, $settings) = @_;
my $output;
$output = "########################################\n";
@@ -835,7 +819,6 @@ sub _prepare_makefile_in($$)
$output .= _prepare_SUFFIXES($suffix_ctx);
$output .= _prepare_dummy_MAKEDIR();
-
$output .= _prepare_std_CC_rule("c","o",'@PICFLAG@',"Compiling","Rule for std objectfiles");
$output .= _prepare_std_CC_rule("h","h.gch",'@PICFLAG@',"Precompiling","Rule for precompiled headerfiles");
@@ -843,12 +826,9 @@ sub _prepare_makefile_in($$)
$output .= _prepare_man_rule("3");
$output .= _prepare_man_rule("5");
$output .= _prepare_man_rule("7");
-
$output .= _prepare_manpages($CTX);
-
$output .= _prepare_target_settings($CTX);
-
- $output .= _prepare_rule_lists($CTX);
+ $output .= _prepare_rule_lists($CTX, $settings);
my @all = ();
@@ -872,9 +852,7 @@ sub _prepare_makefile_in($$)
# $output - the resulting output buffer
sub create_makefile_in($$$)
{
- my $CTX = shift;
- my $settings = shift;
- my $file = shift;
+ my ($CTX, $settings,$file) = @_;
open(MAKEFILE_IN,">$file") || die ("Can't open $file\n");
print MAKEFILE_IN _prepare_makefile_in($CTX, $settings);
diff --git a/source4/build/smb_build/smb_build_h.pm b/source4/build/smb_build/smb_build_h.pm
index e874c77ce8..b6af38035b 100644
--- a/source4/build/smb_build/smb_build_h.pm
+++ b/source4/build/smb_build/smb_build_h.pm
@@ -99,16 +99,13 @@ sub _prepare_smb_build_h($)
# $output - the resulting output buffer
sub create_smb_build_h($$)
{
- my $CTX = shift;
- my $file = shift;
+ my ($CTX, $file) = @_;
my $output = "/* autogenerated by config.smb_build.pl */\n";
$output .= _prepare_smb_build_h($CTX);
open(SMB_BUILD_H,"> $file") || die ("Can't open $file\n");
-
print SMB_BUILD_H $output;
-
close(SMB_BUILD_H);
print "config.smb_build.pl: creating $file\n";