2004-09-22 04:23:12 +08:00
|
|
|
#!/usr/bin/env perl
|
1999-09-14 10:03:19 +08:00
|
|
|
# -*-perl-*-
|
|
|
|
|
|
|
|
# Test driver for the Make test suite
|
|
|
|
|
|
|
|
# Usage: run_make_tests [testname]
|
|
|
|
# [-debug]
|
|
|
|
# [-help]
|
|
|
|
# [-verbose]
|
|
|
|
# [-keep]
|
|
|
|
# [-make <make prog>]
|
|
|
|
# (and others)
|
|
|
|
|
2019-05-19 23:57:14 +08:00
|
|
|
# Copyright (C) 1992-2019 Free Software Foundation, Inc.
|
2006-02-12 04:00:39 +08:00
|
|
|
# This file is part of GNU Make.
|
|
|
|
#
|
2007-07-05 03:35:15 +08:00
|
|
|
# GNU Make is free software; you can redistribute it and/or modify it under
|
|
|
|
# the terms of the GNU General Public License as published by the Free Software
|
|
|
|
# Foundation; either version 3 of the License, or (at your option) any later
|
|
|
|
# version.
|
2006-02-12 04:00:39 +08:00
|
|
|
#
|
|
|
|
# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
|
2007-07-05 03:35:15 +08:00
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
# details.
|
2006-02-12 04:00:39 +08:00
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along with
|
2007-07-05 03:35:15 +08:00
|
|
|
# this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-02-12 04:00:39 +08:00
|
|
|
|
2010-08-14 10:50:14 +08:00
|
|
|
%FEATURES = ();
|
2009-06-10 10:21:09 +08:00
|
|
|
|
2002-07-11 14:38:57 +08:00
|
|
|
$valgrind = 0; # invoke make with valgrind
|
2009-06-10 10:21:09 +08:00
|
|
|
$valgrind_args = '';
|
2012-03-04 06:12:46 +08:00
|
|
|
$memcheck_args = '--num-callers=15 --tool=memcheck --leak-check=full --suppressions=guile.supp';
|
2009-09-17 01:07:01 +08:00
|
|
|
$massif_args = '--num-callers=15 --tool=massif --alloc-fn=xmalloc --alloc-fn=xcalloc --alloc-fn=xrealloc --alloc-fn=xstrdup --alloc-fn=xstrndup';
|
2005-02-26 09:41:48 +08:00
|
|
|
$pure_log = undef;
|
2002-07-11 14:38:57 +08:00
|
|
|
|
2013-02-25 14:38:36 +08:00
|
|
|
# The location of the GNU make source directory
|
|
|
|
$srcdir = '';
|
|
|
|
|
2009-06-10 10:21:09 +08:00
|
|
|
$command_string = '';
|
|
|
|
|
2009-09-29 07:08:49 +08:00
|
|
|
$all_tests = 0;
|
|
|
|
|
2016-12-24 02:33:58 +08:00
|
|
|
# Shell commands
|
|
|
|
|
2017-04-18 03:37:57 +08:00
|
|
|
$sh_name = '/bin/sh';
|
|
|
|
$is_posix_sh = 1;
|
|
|
|
|
2016-12-24 02:33:58 +08:00
|
|
|
$CMD_rmfile = 'rm -f';
|
|
|
|
|
2014-04-02 08:31:57 +08:00
|
|
|
# rmdir broken in some Perls on VMS.
|
|
|
|
if ($^O eq 'VMS')
|
|
|
|
{
|
|
|
|
require VMS::Filespec;
|
|
|
|
VMS::Filespec->import();
|
|
|
|
|
|
|
|
sub vms_rmdir {
|
|
|
|
my $vms_file = vmspath($_[0]);
|
|
|
|
$vms_file = fileify($vms_file);
|
|
|
|
my $ret = unlink(vmsify($vms_file));
|
|
|
|
return $ret
|
|
|
|
};
|
|
|
|
|
|
|
|
*CORE::GLOBAL::rmdir = \&vms_rmdir;
|
2016-12-24 02:33:58 +08:00
|
|
|
|
|
|
|
$CMD_rmfile = 'delete_file -no_ask';
|
2014-04-02 08:31:57 +08:00
|
|
|
}
|
|
|
|
|
2017-05-28 02:24:33 +08:00
|
|
|
use FindBin;
|
|
|
|
use lib "$FindBin::Bin";
|
|
|
|
|
1999-09-14 10:03:19 +08:00
|
|
|
require "test_driver.pl";
|
2018-08-05 00:18:39 +08:00
|
|
|
|
|
|
|
%CONFIG_FLAGS = ();
|
|
|
|
|
|
|
|
my $statnm = "$FindBin::Bin/../config.status";
|
|
|
|
if (open(my $fh, '<', $statnm)) {
|
|
|
|
while (my $line = <$fh>) {
|
|
|
|
$line =~ m/^[SD]\["([^\"]+)"\]=" *(.*)"/ and $CONFIG_FLAGS{$1} = $2;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
warn "Failed to open $statnm: $!";
|
Remove unsupported build facilities.
Over time the non-standard build and install systems (nmake files,
smake files, Visual Studio project files, etc.) have atrophied and
maintaining them is not worth the effort, for such a simple utility
as make. Remove all the non-standard build tool support and unify
OS-specific build rules under a basic set of (GNU make) makefiles.
Preserve the existing bootstrapping scripts (for POSIX, Windows,
and MS-DOS). Also the existing VMS build scripts are left unchanged:
I don't have enough experience with VMS to venture into this area.
Perhaps one of the VMS maintainers might like to determine whether
conversion would be appropriate.
Rather than create libraries for w32 and glob (non-POSIX), simply
link the object files directly to remove the complexity.
* NEWS: Update with user-facing notes.
* Makefile.am: Clean up to use the latest automake best practices.
Build Windows code directly from the root makefile to avoid recursion.
* README.Amiga, README.DOS.template, README.W32.template: Updated.
* INSTALL: Point readers at the README.git file.
* maintMakefile: Remove obsolete files. Create Basic.mk file.
* Basic.mk.template, mk/*.mk: Create basic GNU make-based makefiles.
* build_w32.bat: Copy Basic.mk to Makefile
* configure.ac: We no longer need AM_PROG_AR.
* dosbuild.bat: Rename to builddos.bat. Incorporate configure.bat.
* Makefile.DOS.template: Remove.
* NMakefile.template, w32/subproc/NMakefile: Remove.
* SMakefile.template, glob/SMakefile, glob/SCOPTIONS, make.lnk: Remove.
* configure.bat, glob/configure.bat: Remove.
* w32/Makefile.am: Remove.
* make_msvc_net2003.sln, make_msvc_net2003.vcproj: Remove.
2017-11-13 06:44:38 +08:00
|
|
|
}
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2005-08-31 21:38:17 +08:00
|
|
|
# Some target systems might not have the POSIX module...
|
|
|
|
$has_POSIX = eval { require "POSIX.pm" };
|
|
|
|
|
2002-07-11 14:38:57 +08:00
|
|
|
#$SIG{INT} = sub { print STDERR "Caught a signal!\n"; die @_; };
|
|
|
|
|
1999-09-14 10:03:19 +08:00
|
|
|
sub valid_option
|
|
|
|
{
|
|
|
|
local($option) = @_;
|
2002-07-11 14:38:57 +08:00
|
|
|
|
2009-09-29 07:08:49 +08:00
|
|
|
if ($option =~ /^-make([-_]?path)?$/i) {
|
|
|
|
$make_path = shift @argv;
|
|
|
|
if (!-f $make_path) {
|
|
|
|
print "$option $make_path: Not found.\n";
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-02-25 14:38:36 +08:00
|
|
|
if ($option =~ /^-srcdir$/i) {
|
|
|
|
$srcdir = shift @argv;
|
Rework directory structure to use GNU-recommended "src" directory.
Move the source code (other than glob) into the "src" subdirectory.
Update all scripting and recommendations to support this change.
* *.c, *.h, w32/*: Move to src/
* configure.ac, Makefile.am, maintMakefile: Locate new source files.
* Basic.mk.template, mk/*: Update for new source file locations.
* NEWS, README.DOS.template: Update for new locations.
* build.template, build_w32.bat, builddos.bat: Ditto.
* po/POTFILES.in: Ditto
* tests/run_make_tests.pl, tests/scripts/features/load*: Ditto.
* make.1: Move to doc.
* mk/VMS.mk: Add support for building on VMS (hopefully).
* makefile.vms, prepare_w32.bat: Remove.
* SCOPTIONS: Update to define HAVE_CONFIG_H
2017-11-20 02:49:26 +08:00
|
|
|
if (! -f "$srcdir/src/gnumake.h") {
|
2013-02-25 14:38:36 +08:00
|
|
|
print "$option $srcdir: Not a valid GNU make source directory.\n";
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-09-29 07:08:49 +08:00
|
|
|
if ($option =~ /^-all([-_]?tests)?$/i) {
|
|
|
|
$all_tests = 1;
|
|
|
|
return 1;
|
1999-09-14 10:03:19 +08:00
|
|
|
}
|
1999-09-17 11:15:37 +08:00
|
|
|
|
2009-06-10 10:21:09 +08:00
|
|
|
if ($option =~ /^-(valgrind|memcheck)$/i) {
|
|
|
|
$valgrind = 1;
|
|
|
|
$valgrind_args = $memcheck_args;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($option =~ /^-massif$/i) {
|
|
|
|
$valgrind = 1;
|
|
|
|
$valgrind_args = $massif_args;
|
|
|
|
return 1;
|
2002-07-11 14:38:57 +08:00
|
|
|
}
|
|
|
|
|
2005-02-28 15:48:22 +08:00
|
|
|
# This doesn't work--it _should_! Someone badly needs to fix this.
|
1999-09-17 11:15:37 +08:00
|
|
|
#
|
|
|
|
# elsif ($option =~ /^-work([-_]?dir)?$/)
|
|
|
|
# {
|
|
|
|
# $workdir = shift @argv;
|
|
|
|
# return 1;
|
|
|
|
# }
|
1999-09-14 10:03:19 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-05-17 03:16:52 +08:00
|
|
|
|
|
|
|
# This is an "all-in-one" function. Arguments are as follows:
|
|
|
|
#
|
2004-09-21 13:39:04 +08:00
|
|
|
# [0] (string): The makefile to be tested. undef means use the last one.
|
2004-05-17 03:16:52 +08:00
|
|
|
# [1] (string): Arguments to pass to make.
|
|
|
|
# [2] (string): Answer we should get back.
|
|
|
|
# [3] (integer): Exit code we expect. A missing code means 0 (success)
|
|
|
|
|
2004-09-21 13:39:04 +08:00
|
|
|
$old_makefile = undef;
|
|
|
|
|
2012-10-29 15:05:21 +08:00
|
|
|
sub subst_make_string
|
|
|
|
{
|
|
|
|
local $_ = shift;
|
|
|
|
$makefile and s/#MAKEFILE#/$makefile/g;
|
|
|
|
s/#MAKEPATH#/$mkpath/g;
|
|
|
|
s/#MAKE#/$make_name/g;
|
|
|
|
s/#PERL#/$perl_name/g;
|
|
|
|
s/#PWD#/$pwd/g;
|
|
|
|
return $_;
|
|
|
|
}
|
|
|
|
|
2004-05-17 03:16:52 +08:00
|
|
|
sub run_make_test
|
1999-09-14 10:03:19 +08:00
|
|
|
{
|
2007-07-14 10:57:46 +08:00
|
|
|
local ($makestring, $options, $answer, $err_code, $timeout) = @_;
|
2016-04-04 13:16:13 +08:00
|
|
|
my @call = caller;
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2004-09-21 13:39:04 +08:00
|
|
|
# If the user specified a makefile string, create a new makefile to contain
|
|
|
|
# it. If the first value is not defined, use the last one (if there is
|
|
|
|
# one).
|
|
|
|
|
|
|
|
if (! defined $makestring) {
|
|
|
|
defined $old_makefile
|
|
|
|
|| die "run_make_test(undef) invoked before run_make_test('...')\n";
|
|
|
|
$makefile = $old_makefile;
|
|
|
|
} else {
|
|
|
|
if (! defined($makefile)) {
|
|
|
|
$makefile = &get_tmpfile();
|
|
|
|
}
|
|
|
|
|
2012-10-29 15:05:21 +08:00
|
|
|
# Make sure it ends in a newline and substitute any special tokens.
|
2004-09-22 12:36:17 +08:00
|
|
|
$makestring && $makestring !~ /\n$/s and $makestring .= "\n";
|
2012-10-29 15:05:21 +08:00
|
|
|
$makestring = subst_make_string($makestring);
|
2004-09-21 13:39:04 +08:00
|
|
|
|
|
|
|
# Populate the makefile!
|
|
|
|
open(MAKEFILE, "> $makefile") || die "Failed to open $makefile: $!\n";
|
|
|
|
print MAKEFILE $makestring;
|
|
|
|
close(MAKEFILE) || die "Failed to write $makefile: $!\n";
|
2004-05-17 03:16:52 +08:00
|
|
|
}
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2004-09-21 13:39:04 +08:00
|
|
|
# Do the same processing on $answer as we did on $makestring.
|
2013-09-16 04:41:42 +08:00
|
|
|
if (defined $answer) {
|
|
|
|
$answer && $answer !~ /\n$/s and $answer .= "\n";
|
|
|
|
$answer = subst_make_string($answer);
|
|
|
|
}
|
2002-07-11 14:38:57 +08:00
|
|
|
|
2007-07-14 10:57:46 +08:00
|
|
|
run_make_with_options($makefile, $options, &get_logfile(0),
|
2016-04-04 13:16:13 +08:00
|
|
|
$err_code, $timeout, @call);
|
2004-05-17 03:16:52 +08:00
|
|
|
&compare_output($answer, &get_logfile(1));
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2004-09-21 13:39:04 +08:00
|
|
|
$old_makefile = $makefile;
|
2004-05-17 03:16:52 +08:00
|
|
|
$makefile = undef;
|
|
|
|
}
|
|
|
|
|
2017-04-18 03:37:57 +08:00
|
|
|
sub add_options {
|
|
|
|
my $cmd = shift;
|
|
|
|
|
|
|
|
foreach (@_) {
|
|
|
|
if (ref($cmd)) {
|
|
|
|
push(@$cmd, ref($_) ? @$_ : $_);
|
|
|
|
} else {
|
|
|
|
$cmd .= ' '.(ref($_) ? "@$_" : $_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $cmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub create_command {
|
|
|
|
return !$_[0] || ref($_[0]) ? [$make_path] : $make_path;
|
|
|
|
}
|
|
|
|
|
2004-05-17 03:16:52 +08:00
|
|
|
# The old-fashioned way...
|
2017-04-18 03:37:57 +08:00
|
|
|
# $options can be a scalar (string) or a ref to an array of options
|
|
|
|
# If it's a scalar the entire argument is passed to system/exec etc. as
|
|
|
|
# a single string. If it's a ref then the array is passed to system/exec.
|
|
|
|
# Using a ref should be preferred as it's more portable but all the older
|
|
|
|
# invocations use strings.
|
2004-05-17 03:16:52 +08:00
|
|
|
sub run_make_with_options {
|
2016-04-04 13:16:13 +08:00
|
|
|
my ($filename,$options,$logname,$expected_code,$timeout,@call) = @_;
|
|
|
|
@call = caller unless @call;
|
2017-04-18 03:37:57 +08:00
|
|
|
my $code;
|
|
|
|
my $command = create_command($options);
|
2004-05-17 03:16:52 +08:00
|
|
|
|
|
|
|
$expected_code = 0 unless defined($expected_code);
|
|
|
|
|
|
|
|
# Reset to reflect this one test.
|
|
|
|
$test_passed = 1;
|
|
|
|
|
|
|
|
if ($filename) {
|
2017-04-18 03:37:57 +08:00
|
|
|
$command = add_options($command, '-f', $filename);
|
2004-05-17 03:16:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($options) {
|
2017-04-18 03:37:57 +08:00
|
|
|
if (!ref($options) && $^O eq 'VMS') {
|
2014-04-02 08:31:57 +08:00
|
|
|
# Try to make sure arguments are properly quoted.
|
|
|
|
# This does not handle all cases.
|
2017-04-18 03:37:57 +08:00
|
|
|
# We should convert the tests to use array refs not strings
|
2014-04-02 08:31:57 +08:00
|
|
|
|
|
|
|
# VMS uses double quotes instead of single quotes.
|
|
|
|
$options =~ s/\'/\"/g;
|
|
|
|
|
|
|
|
# If the leading quote is inside non-whitespace, then the
|
|
|
|
# quote must be doubled, because it will be enclosed in another
|
|
|
|
# set of quotes.
|
|
|
|
$options =~ s/(\S)(\".*\")/$1\"$2\"/g;
|
|
|
|
|
|
|
|
# Options must be quoted to preserve case if not already quoted.
|
|
|
|
$options =~ s/(\S+)/\"$1\"/g;
|
|
|
|
|
|
|
|
# Special fixup for embedded quotes.
|
|
|
|
$options =~ s/(\"\".+)\"(\s+)\"(.+\"\")/$1$2$3/g;
|
|
|
|
|
|
|
|
$options =~ s/(\A)(?:\"\")(.+)(?:\"\")/$1\"$2\"/g;
|
|
|
|
|
|
|
|
# Special fixup for misc/general4 test.
|
|
|
|
$options =~ s/""\@echo" "cc""/\@echo cc"/;
|
|
|
|
$options =~ s/"\@echo link"""/\@echo link"/;
|
|
|
|
|
|
|
|
# Remove shell escapes expected to be removed by bash
|
|
|
|
if ($options !~ /path=pre/) {
|
|
|
|
$options =~ s/\\//g;
|
|
|
|
}
|
|
|
|
|
|
|
|
# special fixup for options/eval
|
|
|
|
$options =~ s/"--eval=\$\(info" "eval/"--eval=\$\(info eval/;
|
|
|
|
|
|
|
|
print ("Options fixup = -$options-\n") if $debug;
|
|
|
|
}
|
2017-04-18 03:37:57 +08:00
|
|
|
|
|
|
|
$command = add_options($command, $options);
|
2004-05-17 03:16:52 +08:00
|
|
|
}
|
|
|
|
|
2017-04-18 03:37:57 +08:00
|
|
|
my $cmdstr = ref($command) ? "'".join("' '", @$command)."'" : $command;
|
|
|
|
|
2016-04-04 13:16:13 +08:00
|
|
|
if (@call) {
|
2017-04-18 03:37:57 +08:00
|
|
|
$command_string = "#$call[1]:$call[2]\n$cmdstr\n";
|
|
|
|
} else {
|
|
|
|
$command_string = $cmdstr;
|
2016-04-04 13:16:13 +08:00
|
|
|
}
|
2009-06-10 10:21:09 +08:00
|
|
|
|
2004-05-17 03:16:52 +08:00
|
|
|
if ($valgrind) {
|
2017-04-18 03:37:57 +08:00
|
|
|
print VALGRIND "\n\nExecuting: $cmdstr\n";
|
2004-05-17 03:16:52 +08:00
|
|
|
}
|
|
|
|
|
2007-07-14 10:57:46 +08:00
|
|
|
{
|
|
|
|
my $old_timeout = $test_timeout;
|
2009-06-10 10:21:09 +08:00
|
|
|
$timeout and $test_timeout = $timeout;
|
|
|
|
|
|
|
|
# If valgrind is enabled, turn off the timeout check
|
|
|
|
$valgrind and $test_timeout = 0;
|
2007-07-14 10:57:46 +08:00
|
|
|
|
2017-04-18 03:37:57 +08:00
|
|
|
if (ref($command)) {
|
|
|
|
$code = run_command_with_output($logname, @$command);
|
|
|
|
} else {
|
|
|
|
$code = run_command_with_output($logname, $command);
|
|
|
|
}
|
2007-07-14 10:57:46 +08:00
|
|
|
$test_timeout = $old_timeout;
|
|
|
|
}
|
2004-05-17 03:16:52 +08:00
|
|
|
|
|
|
|
# Check to see if we have Purify errors. If so, keep the logfile.
|
|
|
|
# For this to work you need to build with the Purify flag -exit-status=yes
|
|
|
|
|
|
|
|
if ($pure_log && -f $pure_log) {
|
|
|
|
if ($code & 0x7000) {
|
|
|
|
$code &= ~0x7000;
|
|
|
|
|
|
|
|
# If we have a purify log, save it
|
|
|
|
$tn = $pure_testname . ($num_of_logfiles ? ".$num_of_logfiles" : "");
|
|
|
|
print("Renaming purify log file to $tn\n") if $debug;
|
|
|
|
rename($pure_log, "$tn")
|
|
|
|
|| die "Can't rename $log to $tn: $!\n";
|
|
|
|
++$purify_errors;
|
|
|
|
} else {
|
|
|
|
unlink($pure_log);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($code != $expected_code) {
|
2017-04-18 03:37:57 +08:00
|
|
|
print "Error running $make_path (expected $expected_code; got $code): $cmdstr\n";
|
2004-05-17 03:16:52 +08:00
|
|
|
$test_passed = 0;
|
2009-06-10 10:21:09 +08:00
|
|
|
$runf = &get_runfile;
|
|
|
|
&create_file (&get_runfile, $command_string);
|
2004-05-17 03:16:52 +08:00
|
|
|
# If it's a SIGINT, stop here
|
|
|
|
if ($code & 127) {
|
|
|
|
print STDERR "\nCaught signal ".($code & 127)."!\n";
|
2009-06-10 10:21:09 +08:00
|
|
|
($code & 127) == 2 and exit($code);
|
2004-05-17 03:16:52 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($profile & $vos) {
|
|
|
|
system "add_profile $make_path";
|
|
|
|
}
|
|
|
|
|
2009-06-10 10:21:09 +08:00
|
|
|
return 1;
|
1999-09-14 10:03:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub print_usage
|
|
|
|
{
|
2007-03-20 11:02:26 +08:00
|
|
|
&print_standard_usage ("run_make_tests",
|
2013-02-25 14:38:36 +08:00
|
|
|
"[-make MAKE_PATHNAME] [-srcdir SRCDIR] [-memcheck] [-massif]",);
|
1999-09-14 10:03:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub print_help
|
|
|
|
{
|
2009-06-10 10:21:09 +08:00
|
|
|
&print_standard_help (
|
2013-02-25 14:38:36 +08:00
|
|
|
"-make",
|
2009-06-10 10:21:09 +08:00
|
|
|
"\tYou may specify the pathname of the copy of make to run.",
|
2013-02-25 14:38:36 +08:00
|
|
|
"-srcdir",
|
|
|
|
"\tSpecify the make source directory.",
|
2009-06-10 10:21:09 +08:00
|
|
|
"-valgrind",
|
|
|
|
"-memcheck",
|
|
|
|
"\tRun the test suite under valgrind's memcheck tool.",
|
|
|
|
"\tChange the default valgrind args with the VALGRIND_ARGS env var.",
|
|
|
|
"-massif",
|
|
|
|
"\tRun the test suite under valgrind's massif toool.",
|
|
|
|
"\tChange the default valgrind args with the VALGRIND_ARGS env var."
|
|
|
|
);
|
1999-09-14 10:03:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub get_this_pwd {
|
2005-08-31 21:38:17 +08:00
|
|
|
if ($has_POSIX) {
|
|
|
|
$__pwd = POSIX::getcwd();
|
|
|
|
} elsif ($vos) {
|
1999-09-16 06:23:35 +08:00
|
|
|
$__pwd = `++(current_dir)`;
|
2005-08-31 21:38:17 +08:00
|
|
|
} else {
|
|
|
|
# No idea... just try using pwd as a last resort.
|
1999-09-16 06:23:35 +08:00
|
|
|
chop ($__pwd = `pwd`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $__pwd;
|
1999-09-14 10:03:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub set_defaults
|
|
|
|
{
|
|
|
|
# $profile = 1;
|
|
|
|
$testee = "GNU make";
|
|
|
|
$make_path = "make";
|
|
|
|
$tmpfilesuffix = "mk";
|
|
|
|
$pwd = &get_this_pwd;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub set_more_defaults
|
|
|
|
{
|
|
|
|
local($string);
|
|
|
|
local($index);
|
|
|
|
|
2000-02-05 15:50:47 +08:00
|
|
|
# On DOS/Windows system the filesystem apparently can't track
|
|
|
|
# timestamps with second granularity (!!). Change the sleep time
|
|
|
|
# needed to force a file to be considered "old".
|
2003-05-02 09:44:59 +08:00
|
|
|
$wtime = $port_type eq 'UNIX' ? 1 : $port_type eq 'OS/2' ? 2 : 4;
|
2000-02-05 15:50:47 +08:00
|
|
|
|
1999-09-17 11:15:37 +08:00
|
|
|
# Find the full pathname of Make. For DOS systems this is more
|
2005-02-28 15:48:22 +08:00
|
|
|
# complicated, so we ask make itself.
|
2014-04-02 08:31:57 +08:00
|
|
|
if ($osname eq 'VMS') {
|
2014-10-07 10:46:34 +08:00
|
|
|
$port_type = 'VMS-DCL' unless defined $ENV{"SHELL"};
|
2014-04-02 08:31:57 +08:00
|
|
|
# On VMS pre-setup make to be found with simply 'make'.
|
|
|
|
$make_path = 'make';
|
|
|
|
} else {
|
2017-04-18 03:37:57 +08:00
|
|
|
create_file('make.mk', 'all:;$(info $(MAKE))');
|
|
|
|
my $mk = `$make_path -sf make.mk`;
|
|
|
|
unlink('make.mk');
|
2014-04-02 08:31:57 +08:00
|
|
|
chop $mk;
|
2017-04-18 03:37:57 +08:00
|
|
|
$mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE)\n";
|
2014-04-02 08:31:57 +08:00
|
|
|
$make_path = $mk;
|
|
|
|
}
|
1999-09-17 11:15:37 +08:00
|
|
|
|
2017-04-18 03:37:57 +08:00
|
|
|
# Ask make what shell to use
|
|
|
|
create_file('shell.mk', 'all:;$(info $(SHELL))');
|
|
|
|
$sh_name = `$make_path -sf shell.mk`;
|
|
|
|
unlink('shell.mk');
|
|
|
|
chop $sh_name;
|
|
|
|
if (! $sh_name) {
|
|
|
|
print "Cannot determine shell\n";
|
|
|
|
$is_posix_sh = 0;
|
|
|
|
} else {
|
|
|
|
my $o = `$sh_name -c ': do nothing' 2>&1`;
|
|
|
|
$is_posix_sh = $? == 0 && $o == '';
|
|
|
|
}
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2017-04-18 03:37:57 +08:00
|
|
|
$string = `$make_path -v`;
|
|
|
|
$string =~ /^(GNU Make [^,\n]*)/ or die "$make_path is not GNU make. Version:\n$string";
|
1999-09-16 06:23:35 +08:00
|
|
|
$testee_version = "$1\n";
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2017-04-18 03:37:57 +08:00
|
|
|
create_file('null.mk', '');
|
|
|
|
|
2014-04-02 08:31:57 +08:00
|
|
|
my $redir = '2>&1';
|
|
|
|
$redir = '' if os_name eq 'VMS';
|
2019-09-03 12:09:51 +08:00
|
|
|
$string = `$make_path -f null.mk $redir`;
|
1999-09-14 10:03:19 +08:00
|
|
|
if ($string =~ /(.*): \*\*\* No targets\. Stop\./) {
|
|
|
|
$make_name = $1;
|
|
|
|
}
|
|
|
|
else {
|
2013-02-25 14:38:36 +08:00
|
|
|
$make_path =~ /^(?:.*$pathsep)?(.+)$/;
|
|
|
|
$make_name = $1;
|
1999-09-14 10:03:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# prepend pwd if this is a relative path (ie, does not
|
|
|
|
# start with a slash, but contains one). Thanks for the
|
|
|
|
# clue, Roland.
|
|
|
|
|
|
|
|
if (index ($make_path, ":") != 1 && index ($make_path, "/") > 0)
|
|
|
|
{
|
|
|
|
$mkpath = "$pwd$pathsep$make_path";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$mkpath = $make_path;
|
|
|
|
}
|
|
|
|
|
2013-02-25 14:38:36 +08:00
|
|
|
# If srcdir wasn't provided on the command line, see if the
|
|
|
|
# location of the make program gives us a clue. Don't fail if not;
|
|
|
|
# we'll assume it's been installed into /usr/include or wherever.
|
|
|
|
if (! $srcdir) {
|
|
|
|
$make_path =~ /^(.*$pathsep)?/;
|
|
|
|
my $d = $1 || '../';
|
Rework directory structure to use GNU-recommended "src" directory.
Move the source code (other than glob) into the "src" subdirectory.
Update all scripting and recommendations to support this change.
* *.c, *.h, w32/*: Move to src/
* configure.ac, Makefile.am, maintMakefile: Locate new source files.
* Basic.mk.template, mk/*: Update for new source file locations.
* NEWS, README.DOS.template: Update for new locations.
* build.template, build_w32.bat, builddos.bat: Ditto.
* po/POTFILES.in: Ditto
* tests/run_make_tests.pl, tests/scripts/features/load*: Ditto.
* make.1: Move to doc.
* mk/VMS.mk: Add support for building on VMS (hopefully).
* makefile.vms, prepare_w32.bat: Remove.
* SCOPTIONS: Update to define HAVE_CONFIG_H
2017-11-20 02:49:26 +08:00
|
|
|
-f "${d}/src/gnumake.h" and $srcdir = $d;
|
2013-02-25 14:38:36 +08:00
|
|
|
}
|
|
|
|
|
2013-09-22 23:28:46 +08:00
|
|
|
# Not with the make program, so see if we can get it out of the makefile
|
|
|
|
if (! $srcdir && open(MF, "< ../Makefile")) {
|
|
|
|
local $/ = undef;
|
|
|
|
$_ = <MF>;
|
|
|
|
close(MF);
|
|
|
|
/^abs_srcdir\s*=\s*(.*?)\s*$/m;
|
Rework directory structure to use GNU-recommended "src" directory.
Move the source code (other than glob) into the "src" subdirectory.
Update all scripting and recommendations to support this change.
* *.c, *.h, w32/*: Move to src/
* configure.ac, Makefile.am, maintMakefile: Locate new source files.
* Basic.mk.template, mk/*: Update for new source file locations.
* NEWS, README.DOS.template: Update for new locations.
* build.template, build_w32.bat, builddos.bat: Ditto.
* po/POTFILES.in: Ditto
* tests/run_make_tests.pl, tests/scripts/features/load*: Ditto.
* make.1: Move to doc.
* mk/VMS.mk: Add support for building on VMS (hopefully).
* makefile.vms, prepare_w32.bat: Remove.
* SCOPTIONS: Update to define HAVE_CONFIG_H
2017-11-20 02:49:26 +08:00
|
|
|
-f "$1/src/gnumake.h" and $srcdir = $1;
|
2013-09-22 23:28:46 +08:00
|
|
|
}
|
|
|
|
|
1999-09-14 10:03:19 +08:00
|
|
|
# Get Purify log info--if any.
|
|
|
|
|
2005-02-26 09:41:48 +08:00
|
|
|
if (exists $ENV{PURIFYOPTIONS}
|
|
|
|
&& $ENV{PURIFYOPTIONS} =~ /.*-logfile=([^ ]+)/) {
|
|
|
|
$pure_log = $1 || '';
|
|
|
|
$pure_log =~ s/%v/$make_name/;
|
|
|
|
$purify_errors = 0;
|
|
|
|
}
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2019-09-03 12:09:51 +08:00
|
|
|
$string = `$make_path -j 2 -f null.mk $redir`;
|
1999-09-14 10:03:19 +08:00
|
|
|
if ($string =~ /not supported/) {
|
|
|
|
$parallel_jobs = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$parallel_jobs = 1;
|
|
|
|
}
|
2002-07-11 14:38:57 +08:00
|
|
|
|
2017-04-18 03:37:57 +08:00
|
|
|
unlink('null.mk');
|
|
|
|
|
|
|
|
create_file('features.mk', 'all:;$(info $(.FEATURES))');
|
|
|
|
%FEATURES = map { $_ => 1 } split /\s+/, `$make_path -sf features.mk`;
|
|
|
|
unlink('features.mk');
|
2010-08-14 10:50:14 +08:00
|
|
|
|
2002-07-11 14:38:57 +08:00
|
|
|
# Set up for valgrind, if requested.
|
|
|
|
|
2016-03-23 13:26:55 +08:00
|
|
|
$make_command = $make_path;
|
|
|
|
|
2002-07-11 14:38:57 +08:00
|
|
|
if ($valgrind) {
|
2009-06-10 10:21:09 +08:00
|
|
|
my $args = $valgrind_args;
|
2002-07-11 14:38:57 +08:00
|
|
|
open(VALGRIND, "> valgrind.out")
|
|
|
|
|| die "Cannot open valgrind.out: $!\n";
|
|
|
|
# -q --leak-check=yes
|
2009-06-10 10:21:09 +08:00
|
|
|
exists $ENV{VALGRIND_ARGS} and $args = $ENV{VALGRIND_ARGS};
|
|
|
|
$make_path = "valgrind --log-fd=".fileno(VALGRIND)." $args $make_path";
|
2002-07-11 14:38:57 +08:00
|
|
|
# F_SETFD is 2
|
|
|
|
fcntl(VALGRIND, 2, 0) or die "fcntl(setfd) failed: $!\n";
|
|
|
|
system("echo Starting on `date` 1>&".fileno(VALGRIND));
|
|
|
|
print "Enabled valgrind support.\n";
|
|
|
|
}
|
2017-04-18 03:37:57 +08:00
|
|
|
|
|
|
|
if ($debug) {
|
|
|
|
print "Port type: $port_type\n";
|
|
|
|
print "Make path: $make_path\n";
|
|
|
|
print "Shell path: $sh_name".($is_posix_sh ? ' (POSIX)' : '')."\n";
|
|
|
|
print "#PWD#: $pwd\n";
|
|
|
|
print "#PERL#: $perl_name\n";
|
|
|
|
print "#MAKEPATH#: $mkpath\n";
|
|
|
|
print "#MAKE#: $make_name\n";
|
|
|
|
}
|
1999-09-14 10:03:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub setup_for_test
|
|
|
|
{
|
1999-09-16 06:23:35 +08:00
|
|
|
$makefile = &get_tmpfile;
|
|
|
|
if (-f $makefile) {
|
|
|
|
unlink $makefile;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get rid of any Purify logs.
|
|
|
|
if ($pure_log) {
|
|
|
|
($pure_testname = $testname) =~ tr,/,_,;
|
|
|
|
$pure_testname = "$pure_log.$pure_testname";
|
|
|
|
system("rm -f $pure_testname*");
|
|
|
|
print("Purify testfiles are: $pure_testname*\n") if $debug;
|
|
|
|
}
|
1999-09-14 10:03:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
exit !&toplevel;
|