1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00

Use addprefix where possible rather than perl expansion of files.

This commit is contained in:
Jelmer Vernooij 2008-02-25 15:28:55 +01:00
parent 40476bce2e
commit b136ee5d34
2 changed files with 11 additions and 48 deletions

View File

@ -263,13 +263,7 @@ sub Header($$)
return if ($#{$ctx->{PUBLIC_HEADERS}} == -1);
$self->output("PUBLIC_HEADERS +=");
foreach (@{$ctx->{PUBLIC_HEADERS}}) {
$self->output(" " . output::add_dir_str($ctx->{BASEDIR}, $_));
}
$self->output("\n");
$self->output("PUBLIC_HEADERS += \$(addprefix $ctx->{BASEDIR}/, " . join(" ", @{$ctx->{PUBLIC_HEADERS}}) . ")\n");
}
sub Binary($$)
@ -317,8 +311,7 @@ sub PythonFiles($$)
foreach (@{$ctx->{PYTHON_FILES}}) {
my $target = "bin/python/".basename($_);
my $source = output::add_dir_str($ctx->{BASEDIR}, $_);
$self->output("$target: $source\n\n");
$self->output("$target: \$(addprefix $ctx->{BASEDIR}/, $_)\n\n");
$self->output("PYTHON_PYS += $target\n");
}
}
@ -327,7 +320,7 @@ sub Manpage($$)
{
my ($self,$ctx) = @_;
$self->output("MANPAGES += " . output::add_dir_str($ctx->{BASEDIR}, $ctx->{MANPAGE}) . "\n");
$self->output("MANPAGES += \$(addprefix $ctx->{BASEDIR}/, $ctx->{MANPAGE})\n");
}
sub ProtoHeader($$)
@ -341,7 +334,7 @@ sub ProtoHeader($$)
my $pub = undef;
if (defined($ctx->{PRIVATE_PROTO_HEADER})) {
$priv = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PRIVATE_PROTO_HEADER});
$priv = "\$(addprefix $ctx->{BASEDIR}/, $ctx->{PRIVATE_PROTO_HEADER})";
$target .= $priv;
$comment .= $priv;
if (defined($ctx->{PUBLIC_PROTO_HEADER})) {
@ -351,17 +344,17 @@ sub ProtoHeader($$)
$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});
$priv = "\$(addprefix $ctx->{BASEDIR}/, $ctx->{PRIVATE_PROTO_HEADER})";
}
if (defined($ctx->{PUBLIC_PROTO_HEADER})) {
$pub = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PUBLIC_PROTO_HEADER});
$pub = "\$(addprefix $ctx->{BASEDIR}/, $ctx->{PUBLIC_PROTO_HEADER})";
$comment .= $pub;
$target .= $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});
$pub = "\$(addprefix $ctx->{BASEDIR}/, $ctx->{PUBLIC_PROTO_HEADER})";
}
$self->output("$pub: $ctx->{MK_FILE} \$($ctx->{NAME}_OBJ_LIST:.o=.c) \$(srcdir)/script/mkproto.pl\n");

View File

@ -9,38 +9,6 @@ package output;
use strict;
use smb_build::config;
sub add_dir_str($$)
{
my ($dir,$file) = @_;
my $dirsep = "/";
$dir =~ s/^\.$//g;
$dir =~ s/^\.\///g;
$dirsep = "" if ($dir eq "");
my $ret = $file;
if (substr($ret, 0, 1) ne "\$") {
$ret = "$dir$dirsep$file";
$ret =~ s/([^\/\.]+)\/\.\.\///g;
$ret =~ s/([^\/\.]+)\/\.\.\///g;
}
return $ret;
}
sub add_dir_array($$)
{
my ($dir,$files) = @_;
my @ret = ();
foreach (@{$files}) {
push (@ret, add_dir_str($dir, $_));
}
return @ret;
}
sub generate_shared_library($)
{
my $lib = shift;
@ -168,8 +136,10 @@ sub create_output($$)
next unless(defined($part->{OUTPUT_TYPE}));
# Combine object lists
my @list = add_dir_array($part->{BASEDIR}, $part->{OBJ_FILES});
push(@{$part->{OBJ_LIST}}, @list) if defined($part->{OBJ_FILES});
if (defined($part->{OBJ_FILES})) {
my $list = "\$(addprefix $part->{BASEDIR}/, " . join(" ", @{$part->{OBJ_FILES}}) . ")";
push(@{$part->{OBJ_LIST}}, $list);
}
generate_binary($part) if grep(/BINARY/, @{$part->{OUTPUT_TYPE}});
generate_shared_library($part) if grep(/SHARED_LIBRARY/, @{$part->{OUTPUT_TYPE}});