From c38ee94dcbbf2ba5b4ade626b42a4e77264aa240 Mon Sep 17 00:00:00 2001 From: "kestes%walrus.com" Date: Mon, 9 Dec 2002 18:02:32 +0000 Subject: [PATCH] portability fix for xargs record the arguments to ./configure find all the full paths for build commands on build machine git-svn-id: svn://10.0.0.236/trunk@134982 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/tinderbox2/configure | 110 ++++++++++++++++++++------ 1 file changed, 85 insertions(+), 25 deletions(-) diff --git a/mozilla/webtools/tinderbox2/configure b/mozilla/webtools/tinderbox2/configure index 4bebc469c99..c5e527191a3 100755 --- a/mozilla/webtools/tinderbox2/configure +++ b/mozilla/webtools/tinderbox2/configure @@ -79,10 +79,43 @@ $tinder_version = '0.09'; @replacements = qw( prefix cgibin_prefix html_prefix builddir config_script + xargs_single CONFIGURE_ARGS ); -@cmds = qw(perl); +@cmds = ( + # commands tinderbox uses + 'perl', + + # these commands are used by the Makefile not by tinderbox + + 'find', + 'egrep', + 'xargs', + 'rm', + 'echo', + 'mkdir', + 'chmod', + + ); + +# xargs takes one of these arguments +# this is very OS specific + +@XARGS_SINGLE_ARGS = ('-l1', '-L1', '-n1'); + + +@ORIG_ARGS = @ARGV; +$PROGRAM = $0; + +$CONFIGURE_ARGS= ( + "# Configure was run like this:\n\n". + "# \t". + $PROGRAM. + "\t\'". + join ("\' \\\n\#\t\'", @ORIG_ARGS). + "\'". + ""); Getopt::Long::config('require_order', 'auto_abbrev', 'ignore_case'); @@ -100,11 +133,47 @@ GetOptions( usage() if $help; +for my $cmd (@cmds) { + + my $variable = $cmd.'_cmd'; + + my $explicit_cmd = $$variable; + + if ($explicit_cmd) { + # Use explicitly set command path if defined + $full_cmd = $explicit_cmd; + } else { + + # Search for command in the $PATH and assume that this is in the + # same place on the machine where the files are installed. + + $full_cmd=`which $cmd 2> /dev/null`; + chomp($full_cmd); + + if ($? != 0) { + print STDERR "Could not find program: $cmd\n"; + exit 9; + } + } + + $CMD{$cmd} = $full_cmd; +} + +my $arg; +foreach $arg (@XARGS_SINGLE_ARGS) { + my $output = `$CMD{'echo'} /bin/true | $CMD{'xargs'} $arg $CMD{'echo'}`; + if ($output eq "/bin/true\n") { + $xargs_single=$arg; + last; + } +} + # Build Makefile #------------------------------------------------------------ # Build a makefile to copy our executables into place and perform # subsitutions on them. + print STDERR "Building Makefile\n"; open(MAKEFILE_IN, ") { # Set the library search path with suitable interposing directories. @@ -247,35 +320,22 @@ while (<>) { s!\#perlflags\#!$perl_flags!; s!\#tinder_version\#!$tinder_version!; - # Hard code various executable paths into the source for security reasons. EOF4 + ; -for my $cmd (@cmds) { - my $variable = $cmd.'_cmd'; - - my $explicit_cmd = $$variable; - - if ($explicit_cmd) { - # Use explicitly set command path if defined - $full_cmd = $explicit_cmd; - } else { - - # Search for command in the $PATH and assume that this is in the - # same place on the machine where the files are installed. - - $full_cmd=`which $cmd 2> /dev/null`; - chomp($full_cmd); - - if ($? != 0) { - print STDERR "Could not find program: $cmd\n"; - exit 9; - } - } - - print CONFIG_SCRIPT " s!\#$cmd\#!$full_cmd!;"; +{ + print CONFIG_SCRIPT " # Hard code various executable paths into "; + print CONFIG_SCRIPT "the source for security reasons.\n"; + foreach $cmd (sort keys %CMD) { + my $full_cmd = $CMD{$cmd}; + print CONFIG_SCRIPT " s!\#$cmd\#!$full_cmd!;\n"; + } + print CONFIG_SCRIPT "\n"; + print CONFIG_SCRIPT " s!\#xargs_single\#!$xargs_single!;\n"; } + print CONFIG_SCRIPT <