VirtualBox

Ignore:
Timestamp:
Mar 14, 2018 9:28:10 PM (7 years ago)
Author:
bird
Message:

kmk: Merged in changes from GNU make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6 / https://git.savannah.gnu.org/git/make.git).

Location:
trunk/src/kmk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk

  • trunk/src/kmk/tests/run_make_tests.pl

    r2591 r3140  
    1212#                        (and others)
    1313
    14 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
    15 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
    16 # Foundation, Inc.
     14# Copyright (C) 1992-2016 Free Software Foundation, Inc.
    1715# This file is part of GNU Make.
    1816#
     
    3028# this program.  If not, see <http://www.gnu.org/licenses/>.
    3129
     30%FEATURES = ();
    3231
    3332$valgrind = 0;              # invoke make with valgrind
    3433$valgrind_args = '';
    35 $memcheck_args = '--num-callers=15 --tool=memcheck --leak-check=full';
     34$memcheck_args = '--num-callers=15 --tool=memcheck --leak-check=full --suppressions=guile.supp';
    3635$massif_args = '--num-callers=15 --tool=massif --alloc-fn=xmalloc --alloc-fn=xcalloc --alloc-fn=xrealloc --alloc-fn=xstrdup --alloc-fn=xstrndup';
    3736$pure_log = undef;
    3837
     38# The location of the GNU make source directory
     39$srcdir = '';
     40
    3941$command_string = '';
    4042
    4143$all_tests = 0;
    4244
     45# rmdir broken in some Perls on VMS.
     46if ($^O eq 'VMS')
     47{
     48  require VMS::Filespec;
     49  VMS::Filespec->import();
     50
     51  sub vms_rmdir {
     52    my $vms_file = vmspath($_[0]);
     53    $vms_file = fileify($vms_file);
     54    my $ret = unlink(vmsify($vms_file));
     55    return $ret
     56  };
     57
     58  *CORE::GLOBAL::rmdir = \&vms_rmdir;
     59}
     60
    4361require "test_driver.pl";
     62require "config-flags.pm";
    4463
    4564# Some target systems might not have the POSIX module...
     
    6180   }
    6281
     82   if ($option =~ /^-srcdir$/i) {
     83       $srcdir = shift @argv;
     84       if (! -f "$srcdir/gnumake.h") {
     85           print "$option $srcdir: Not a valid GNU make source directory.\n";
     86           exit 0;
     87       }
     88       return 1;
     89   }
     90
    6391   if ($option =~ /^-all([-_]?tests)?$/i) {
    6492       $all_tests = 1;
     
    99127$old_makefile = undef;
    100128
     129sub subst_make_string
     130{
     131    local $_ = shift;
     132    $makefile and s/#MAKEFILE#/$makefile/g;
     133    s/#MAKEPATH#/$mkpath/g;
     134    s/#MAKE#/$make_name/g;
     135    s/#PERL#/$perl_name/g;
     136    s/#PWD#/$pwd/g;
     137    return $_;
     138}
     139
    101140sub run_make_test
    102141{
    103142  local ($makestring, $options, $answer, $err_code, $timeout) = @_;
     143  my @call = caller;
    104144
    105145  # If the user specified a makefile string, create a new makefile to contain
     
    116156    }
    117157
    118     # Make sure it ends in a newline.
     158    # Make sure it ends in a newline and substitute any special tokens.
    119159    $makestring && $makestring !~ /\n$/s and $makestring .= "\n";
    120 
    121     # Replace @MAKEFILE@ with the makefile name and @MAKE@ with the path to
    122     # make
    123     $makestring =~ s/#MAKEFILE#/$makefile/g;
    124     $makestring =~ s/#MAKEPATH#/$mkpath/g;
    125     $makestring =~ s/#MAKE#/$make_name/g;
    126     $makestring =~ s/#PERL#/$perl_name/g;
    127     $makestring =~ s/#PWD#/$pwd/g;
     160    $makestring = subst_make_string($makestring);
    128161
    129162    # Populate the makefile!
     
    134167
    135168  # Do the same processing on $answer as we did on $makestring.
    136 
    137   $answer && $answer !~ /\n$/s and $answer .= "\n";
    138   $answer =~ s/#MAKEFILE#/$makefile/g;
    139   $answer =~ s/#MAKEPATH#/$mkpath/g;
    140   $answer =~ s/#MAKE#/$make_name/g;
    141   $answer =~ s/#PERL#/$perl_name/g;
    142   $answer =~ s/#PWD#/$pwd/g;
     169  if (defined $answer) {
     170      $answer && $answer !~ /\n$/s and $answer .= "\n";
     171      $answer = subst_make_string($answer);
     172  }
    143173
    144174  run_make_with_options($makefile, $options, &get_logfile(0),
    145                         $err_code, $timeout);
     175                        $err_code, $timeout, @call);
    146176  &compare_output($answer, &get_logfile(1));
    147177
     
    152182# The old-fashioned way...
    153183sub run_make_with_options {
    154   local ($filename,$options,$logname,$expected_code,$timeout) = @_;
     184  my ($filename,$options,$logname,$expected_code,$timeout,@call) = @_;
     185  @call = caller unless @call;
    155186  local($code);
    156187  local($command) = $make_path;
     
    166197
    167198  if ($options) {
     199    if ($^O eq 'VMS') {
     200      # Try to make sure arguments are properly quoted.
     201      # This does not handle all cases.
     202
     203      # VMS uses double quotes instead of single quotes.
     204      $options =~ s/\'/\"/g;
     205
     206      # If the leading quote is inside non-whitespace, then the
     207      # quote must be doubled, because it will be enclosed in another
     208      # set of quotes.
     209      $options =~ s/(\S)(\".*\")/$1\"$2\"/g;
     210
     211      # Options must be quoted to preserve case if not already quoted.
     212      $options =~ s/(\S+)/\"$1\"/g;
     213
     214      # Special fixup for embedded quotes.
     215      $options =~ s/(\"\".+)\"(\s+)\"(.+\"\")/$1$2$3/g;
     216
     217      $options =~ s/(\A)(?:\"\")(.+)(?:\"\")/$1\"$2\"/g;
     218
     219      # Special fixup for misc/general4 test.
     220      $options =~ s/""\@echo" "cc""/\@echo cc"/;
     221      $options =~ s/"\@echo link"""/\@echo link"/;
     222
     223      # Remove shell escapes expected to be removed by bash
     224      if ($options !~ /path=pre/) {
     225        $options =~ s/\\//g;
     226      }
     227
     228      # special fixup for options/eval
     229      $options =~ s/"--eval=\$\(info" "eval/"--eval=\$\(info eval/;
     230
     231      print ("Options fixup = -$options-\n") if $debug;
     232    }
    168233    $command .= " $options";
    169234  }
    170235
    171   $command_string = "$command\n";
     236  $command_string = "";
     237  if (@call) {
     238      $command_string = "#$call[1]:$call[2]\n";
     239  }
     240  $command_string .= "$command\n";
    172241
    173242  if ($valgrind) {
     
    184253
    185254      $code = &run_command_with_output($logname,$command);
    186 
    187255      $test_timeout = $old_timeout;
    188256  }
     
    229297{
    230298   &print_standard_usage ("run_make_tests",
    231                           "[-make_path make_pathname] [-memcheck] [-massif]",);
     299                          "[-make MAKE_PATHNAME] [-srcdir SRCDIR] [-memcheck] [-massif]",);
    232300}
    233301
     
    235303{
    236304   &print_standard_help (
    237         "-make_path",
     305        "-make",
    238306        "\tYou may specify the pathname of the copy of make to run.",
     307        "-srcdir",
     308        "\tSpecify the make source directory.",
    239309        "-valgrind",
    240310        "-memcheck",
     
    296366     $port_type = 'OS/2';
    297367   }
     368
     369   # VMS has a GNV Unix mode or a DCL mode.
     370   # The SHELL environment variable should not be defined in VMS-DCL mode.
     371   elsif ($osname eq 'VMS' && !defined $ENV{"SHELL"}) {
     372     $port_type = 'VMS-DCL';
     373   }
    298374   # Everything else, right now, is UNIX.  Note that we should integrate
    299375   # the VOS support into this as well and get rid of $vos; we'll do
     
    314390   # Find the full pathname of Make.  For DOS systems this is more
    315391   # complicated, so we ask make itself.
    316    my $mk = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`;
    317    chop $mk;
    318    $mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE):\n
     392   if ($osname eq 'VMS') {
     393     $port_type = 'VMS-DCL' unless defined $ENV{"SHELL"};
     394     # On VMS pre-setup make to be found with simply 'make'.
     395     $make_path = 'make';
     396   } else {
     397     my $mk = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`;
     398     chop $mk;
     399     $mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE):\n
    319400'echo \"all:;\@echo \\\$(MAKE)\" | $make_path -f-' failed!\n";
    320    $make_path = $mk;
    321    print "Make\t= `$make_path'\n" if $debug;
    322 
    323    $string = `$make_path -v -f /dev/null 2> /dev/null`;
     401     $make_path = $mk;
     402   }
     403   print "Make\t= '$make_path'\n" if $debug;
     404
     405   my $redir2 = '2> /dev/null';
     406   $redir2 = '' if os_name eq 'VMS';
     407   $string = `$make_path -v -f /dev/null $redir2`;
    324408
    325409   $string =~ /^(GNU Make [^,\n]*)/;
    326410   $testee_version = "$1\n";
    327411
    328    $string = `sh -c "$make_path -f /dev/null 2>&1"`;
     412   my $redir = '2>&1';
     413   $redir = '' if os_name eq 'VMS';
     414   $string = `sh -c "$make_path -f /dev/null $redir"`;
    329415   if ($string =~ /(.*): \*\*\* No targets\.  Stop\./) {
    330416     $make_name = $1;
    331417   }
    332418   else {
    333      if ($make_path =~ /$pathsep([^\n$pathsep]*)$/) {
    334        $make_name = $1;
    335      }
    336      else {
    337        $make_name = $make_path;
    338      }
     419     $make_path =~ /^(?:.*$pathsep)?(.+)$/;
     420     $make_name = $1;
    339421   }
    340422
     
    350432   {
    351433      $mkpath = $make_path;
     434   }
     435
     436   # If srcdir wasn't provided on the command line, see if the
     437   # location of the make program gives us a clue.  Don't fail if not;
     438   # we'll assume it's been installed into /usr/include or wherever.
     439   if (! $srcdir) {
     440       $make_path =~ /^(.*$pathsep)?/;
     441       my $d = $1 || '../';
     442       -f "${d}gnumake.h" and $srcdir = $d;
     443   }
     444
     445   # Not with the make program, so see if we can get it out of the makefile
     446   if (! $srcdir && open(MF, "< ../Makefile")) {
     447       local $/ = undef;
     448       $_ = <MF>;
     449       close(MF);
     450       /^abs_srcdir\s*=\s*(.*?)\s*$/m;
     451       -f "$1/gnumake.h" and $srcdir = $1;
    352452   }
    353453
     
    361461   }
    362462
    363    $string = `sh -c "$make_path -j 2 -f /dev/null 2>&1"`;
     463   $string = `sh -c "$make_path -j 2 -f /dev/null $redir"`;
    364464   if ($string =~ /not supported/) {
    365465     $parallel_jobs = 0;
     
    369469   }
    370470
     471   %FEATURES = map { $_ => 1 } split /\s+/, `sh -c "echo '\\\$(info \\\$(.FEATURES))' | $make_path -f- 2>/dev/null"`;
     472
    371473   # Set up for valgrind, if requested.
     474
     475   $make_command = $make_path;
    372476
    373477   if ($valgrind) {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette