add make-4.3.tar.gz

This commit is contained in:
ahgamut 2021-10-26 23:19:30 +05:30 committed by Justine Tunney
parent 0a0997a872
commit 19f70a154e
458 changed files with 239669 additions and 0 deletions

View file

@ -0,0 +1,35 @@
# -*-perl-*-
$description = "The following test creates a makefile to override part\n"
."of one Makefile with Another Makefile with the .DEFAULT\n"
."rule.";
$details = "This tests the use of the .DEFAULT special target to say that \n"
."to remake any target that cannot be made fram the information\n"
."in the containing makefile, make should look in another makefile\n"
."This test gives this makefile the target bar which is not \n"
."defined here but passes the target bar on to another makefile\n"
."which does have the target bar defined.\n";
create_file('defsub.mk', q!
bar: ; @echo Executing rule BAR
!);
run_make_test(q!
foo:; @echo Executing rule FOO
.DEFAULT: ; @$(MAKE) -f defsub.mk $@
!,
'bar',"#MAKE#[1]: Entering directory '#PWD#'\n"
. "Executing rule BAR\n"
. "#MAKE#[1]: Leaving directory '#PWD#'\n");
unlink('defsub.mk');
1;

View file

@ -0,0 +1,22 @@
#! -*-perl-*-
$description = "Test the behaviour of the .DELETE_ON_ERROR target.";
$details = "";
run_make_test('
.DELETE_ON_ERROR:
all: ; exit 1 > $@
',
'', "exit 1 > all\n#MAKE#: *** [#MAKEFILE#:3: all] Error 1\n#MAKE#: *** Deleting file 'all'", 512);
run_make_test('
.DELETE_ON_ERROR:
all: foo.x ;
%.x : %.q ; echo > $@
%.q : ; exit 1 > $@
',
'', "exit 1 > foo.q\n#MAKE#: *** [#MAKEFILE#:5: foo.q] Error 1\n#MAKE#: *** Deleting file 'foo.q'", 512);
# This tells the test driver that the perl test script executed properly.
1;

View file

@ -0,0 +1,19 @@
# -*-perl-*-
$description = "The following tests rules without Commands or Dependencies.";
# Create a file named "clean". This is the same name as the target clean
# and tricks the target into thinking that it is up to date. (Unless you
# use the .PHONY target.
touch('clean');
run_make_test(qq!
.IGNORE :
clean: FORCE ; $CMD_rmfile clean
FORCE:
!,
'', "$CMD_rmfile clean");
rmfiles('clean');
1;

View file

@ -0,0 +1,108 @@
# -*-perl-*-
$description = "Test the behaviour of the .INTERMEDIATE target.";
$details = "\
Test the behavior of the .INTERMEDIATE special target.
Create a makefile where a file would not normally be considered
intermediate, then specify it as .INTERMEDIATE. Build and ensure it's
deleted properly. Rebuild to ensure that it's not created if it doesn't
exist but doesn't need to be built. Change the original and ensure
that the intermediate file and the ultimate target are both rebuilt, and
that the intermediate file is again deleted.
Try this with implicit rules and explicit rules: both should work.\n";
open(MAKEFILE,"> $makefile");
print MAKEFILE <<'EOF';
.INTERMEDIATE: foo.e bar.e
# Implicit rule test
%.d : %.e ; cp $< $@
%.e : %.f ; cp $< $@
foo.d: foo.e
# Explicit rule test
foo.c: foo.e bar.e; cat $^ > $@
EOF
close(MAKEFILE);
# TEST #0
&utouch(-20, 'foo.f', 'bar.f');
&run_make_with_options($makefile,'foo.d',&get_logfile);
$answer = "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n";
&compare_output($answer, &get_logfile(1));
# TEST #1
&run_make_with_options($makefile,'foo.d',&get_logfile);
$answer = "$make_name: 'foo.d' is up to date.\n";
&compare_output($answer, &get_logfile(1));
# TEST #2
&utouch(-10, 'foo.d');
&touch('foo.f');
&run_make_with_options($makefile,'foo.d',&get_logfile);
$answer = "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n";
&compare_output($answer, &get_logfile(1));
# TEST #3
&run_make_with_options($makefile,'foo.c',&get_logfile);
$answer = "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\nrm foo.e bar.e\n";
&compare_output($answer, &get_logfile(1));
# TEST #4
&run_make_with_options($makefile,'foo.c',&get_logfile);
$answer = "$make_name: 'foo.c' is up to date.\n";
&compare_output($answer, &get_logfile(1));
# TEST #5
&utouch(-10, 'foo.c');
&touch('foo.f');
&run_make_with_options($makefile,'foo.c',&get_logfile);
$answer = "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\nrm foo.e bar.e\n";
&compare_output($answer, &get_logfile(1));
# TEST #6 -- added for PR/1669: don't remove files mentioned on the cmd line.
&run_make_with_options($makefile,'foo.e',&get_logfile);
$answer = "cp foo.f foo.e\n";
&compare_output($answer, &get_logfile(1));
unlink('foo.f', 'foo.e', 'foo.d', 'foo.c', 'bar.f', 'bar.e', 'bar.d', 'bar.c');
# TEST #7 -- added for PR/1423
$makefile2 = &get_tmpfile;
open(MAKEFILE, "> $makefile2");
print MAKEFILE <<'EOF';
all: foo
foo.a: ; touch $@
%: %.a ; touch $@
.INTERMEDIATE: foo.a
EOF
close(MAKEFILE);
&run_make_with_options($makefile2, '-R', &get_logfile);
$answer = "touch foo.a\ntouch foo\nrm foo.a\n";
&compare_output($answer, &get_logfile(1));
unlink('foo');
# This tells the test driver that the perl test script executed properly.
1;

View file

@ -0,0 +1,94 @@
# -*-perl-*-
$description = "Test the behaviour of the .ONESHELL target.";
$details = "";
my $multi_ok = 0;
if ($port_type ne 'W32') {
# Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
# separate arguments.
my $t = `$sh_name -e -c true 2>/dev/null`;
my $multi_ok = $? == 0;
}
# Simple
run_make_test(q!
.ONESHELL:
all:
a=$$$$
[ 0"$$a" -eq "$$$$" ] || echo fail
!,
'', 'a=$$
[ 0"$a" -eq "$$" ] || echo fail
');
# Simple but use multi-word SHELLFLAGS
if ($multi_ok) {
run_make_test(q!
.ONESHELL:
.SHELLFLAGS = -e -c
all:
a=$$$$
[ 0"$$a" -eq "$$$$" ] || echo fail
!,
'', 'a=$$
[ 0"$a" -eq "$$" ] || echo fail
');
}
# Again, but this time with inner prefix chars
run_make_test(q!
.ONESHELL:
all:
a=$$$$
@-+ [ 0"$$a" -eq "$$$$" ] || echo fail
!,
'', 'a=$$
[ 0"$a" -eq "$$" ] || echo fail
');
# This time with outer prefix chars
run_make_test(q!
.ONESHELL:
all:
@a=$$$$
[ 0"$$a" -eq "$$$$" ] || echo fail
!,
'', '');
# This time with outer and inner prefix chars
run_make_test(q!
.ONESHELL:
all:
@a=$$$$
-@ +[ 0"$$a" -eq "$$$$" ] || echo fail
!,
'', '');
# Now try using a different interpreter
# This doesn't work on Windows right now
if ($port_type ne 'W32') {
run_make_test(q!
.RECIPEPREFIX = >
.ONESHELL:
SHELL = #PERL#
.SHELLFLAGS = -e
all:
> @$$a=5
> +7;
> @y=qw(a b c);
>print "a = $$a, y = (@y)\n";
!,
'', "a = 12, y = (a b c)\n");
}
1;

View file

@ -0,0 +1,42 @@
# -*-perl-*-
$description = "The following tests the use of a PHONY target. It makes\n"
."sure that the rules under a target get executed even if\n"
."a filename of the same name of the target exists in the\n"
."directory.\n";
$details = "This makefile in this test declares the target clean to be a \n"
."PHONY target. We then create a file named \"clean\" in the \n"
."directory. Although this file exists, the rule under the target\n"
."clean should still execute because of it's phony status.";
$example = "EXAMPLE_FILE";
touch($example);
# Create a file named "clean". This is the same name as the target clean
# and tricks the target into thinking that it is up to date. (Unless you
# use the .PHONY target.
touch('clean');
open(MAKEFILE, "> $makefile");
print MAKEFILE qq!
.PHONY : clean
all: ; \@echo This makefile did not clean the dir ... good
clean: ; $CMD_rmfile $example clean
!;
close(MAKEFILE);
$answer = "$CMD_rmfile $example clean\n";
&run_make_with_options($makefile,"clean",&get_logfile);
if (-f $example) {
$test_passed = 0;
}
&compare_output($answer,&get_logfile(1));
# Just in case
unlink($example, 'clean');
1;

View file

@ -0,0 +1,55 @@
# -*-perl-*-
$description = "Test the behaviour of the .POSIX target.";
$details = "";
# Ensure turning on .POSIX enables the -e flag for the shell
# We can't assume the exit value of "false" because on different systems it's
# different.
my $script = 'false; true';
my $flags = '-ec';
my $out = `$sh_name $flags '$script' 2>&1`;
my $err = $? >> 8;
run_make_test(qq!
.POSIX:
all: ; \@$script
!,
'', "#MAKE#: *** [#MAKEFILE#:3: all] Error $err\n", 512);
# User settings must override .POSIX
$flags = '-xc';
$out = `$sh_name $flags '$script' 2>&1`;
run_make_test(qq!
.SHELLFLAGS = $flags
.POSIX:
all: ; \@$script
!,
'', $out);
# Test the default value of various POSIX-specific variables
my %POSIX = (AR => 'ar', ARFLAGS => '-rv',
YACC => 'yacc', YFLAGS => '',
LEX => 'lex', LFLAGS => '',
LDFLAGS => '',
CC => 'c99', CFLAGS => '-O1',
FC => 'fort77', FFLAGS => '-O1',
SCCSFLAGS => '', SCCSGETFLAGS => '-s');
my $make = join('', map { "\t\@echo '$_=\$($_)'\n" } sort keys %POSIX);
my $r = join('', map { "$_=$POSIX{$_}\n"} sort keys %POSIX);
run_make_test(qq!
.POSIX:
all:
$make
!,
'', $r);
# Make sure that local settings take precedence
%extraENV = map { $_ => "xx-$_" } keys %POSIX;
$r = join('', map { "$_=xx-$_\n"} sort keys %POSIX);
run_make_test(undef, '', $r);
# This tells the test driver that the perl test script executed properly.
1;

View file

@ -0,0 +1,189 @@
#! -*-perl-*-
$description = "Test the behaviour of the .SECONDARY target.";
$details = "\
Test the behavior of the .SECONDARY special target.
Create a makefile where a file would not normally be considered
intermediate, then specify it as .SECONDARY. Build and note that it's
not automatically deleted. Delete the file. Rebuild to ensure that
it's not created if it doesn't exist but doesn't need to be built.
Change the original and ensure that the secondary file and the ultimate
target are both rebuilt, and that the secondary file is not deleted.
Try this with implicit rules and explicit rules: both should work.\n";
open(MAKEFILE,"> $makefile");
print MAKEFILE <<'EOF';
.SECONDARY: foo.e
# Implicit rule test
%.d : %.e ; cp $< $@
%.e : %.f ; cp $< $@
foo.d: foo.e
# Explicit rule test
foo.c: foo.e ; cp $< $@
EOF
close(MAKEFILE);
# TEST #1
&utouch(-20, 'foo.f');
&run_make_with_options($makefile,'foo.d',&get_logfile);
$answer = "cp foo.f foo.e\ncp foo.e foo.d\n";
&compare_output($answer, &get_logfile(1));
# TEST #2
unlink('foo.e');
&run_make_with_options($makefile,'foo.d',&get_logfile);
$answer = "$make_name: 'foo.d' is up to date.\n";
&compare_output($answer, &get_logfile(1));
# TEST #3
&utouch(-10, 'foo.d');
&touch('foo.f');
&run_make_with_options($makefile,'foo.d',&get_logfile);
$answer = "cp foo.f foo.e\ncp foo.e foo.d\n";
&compare_output($answer, &get_logfile(1));
# TEST #4
&run_make_with_options($makefile,'foo.c',&get_logfile);
$answer = "cp foo.e foo.c\n";
&compare_output($answer, &get_logfile(1));
# TEST #5
unlink('foo.e');
&run_make_with_options($makefile,'foo.c',&get_logfile);
$answer = "$make_name: 'foo.c' is up to date.\n";
&compare_output($answer, &get_logfile(1));
# TEST #6
&utouch(-10, 'foo.c');
&touch('foo.f');
&run_make_with_options($makefile,'foo.c',&get_logfile);
$answer = "cp foo.f foo.e\ncp foo.e foo.c\n";
&compare_output($answer, &get_logfile(1));
unlink('foo.f', 'foo.e', 'foo.d', 'foo.c');
# TEST #7 -- test the "global" .SECONDARY, with no targets.
$makefile2 = &get_tmpfile;
open(MAKEFILE, "> $makefile2");
print MAKEFILE <<'EOF';
.SECONDARY:
final: intermediate
intermediate: source
final intermediate source: ; echo $< > $@
EOF
close(MAKEFILE);
&utouch(-10, 'source');
touch('final');
&run_make_with_options($makefile2, '', &get_logfile);
$answer = "$make_name: 'final' is up to date.\n";
&compare_output($answer, &get_logfile(1));
unlink('source', 'final', 'intermediate');
# TEST #8 -- test the "global" .SECONDARY, with .PHONY.
touch('version2');
run_make_test('
.PHONY: version
.SECONDARY:
version2: version ; @echo GOOD
all: version2',
'all', 'GOOD');
unlink('version2');
# TEST #9 -- Savannah bug #15919
# The original fix for this bug caused a new bug, shown here.
touch(qw(1.a 2.a));
run_make_test('
%.c : %.b ; cp $< $@
%.b : %.a ; cp $< $@
all : 1.c 2.c
2.a: 1.c', '-rR -j',
'cp 1.a 1.b
cp 1.b 1.c
cp 2.a 2.b
cp 2.b 2.c
rm 2.b 1.b');
unlink(qw(1.a 2.a 1.c 2.c));
# TEST #10 -- Savannah bug #15919
touch('test.0');
run_make_test('
.SECONDARY : test.1 test.2 test.3
test : test.4
%.4 : %.int %.3 ; touch $@
%.int : %.3 %.2 ; touch $@
%.3 : | %.2 ; touch $@
%.2 : %.1 ; touch $@
%.1 : %.0 ; touch $@', '-rR -j 2',
'touch test.1
touch test.2
touch test.3
touch test.int
touch test.4
rm test.int');
# After a touch of test.0 it should give the same output, except we don't need
# to rebuild test.3 (order-only)
sleep(1);
touch('test.0');
run_make_test(undef, '-rR -j 2',
'touch test.1
touch test.2
touch test.int
touch test.4
rm test.int');
# With both test.0 and test.3 updated it should still build everything except
# test.3
sleep(1);
touch('test.0', 'test.3');
run_make_test(undef, '-rR -j 2',
'touch test.1
touch test.2
touch test.int
touch test.4
rm test.int');
unlink(qw(test.0 test.1 test.2 test.3 test.4));
# This tells the test driver that the perl test script executed properly.
1;

View file

@ -0,0 +1,33 @@
# -*-perl-*-
$description = "Test the special target .SILENT.";
run_make_test(q!
.PHONY: M a b
M: a b
.SILENT : b
a b: ; echo $@
!,
'', "echo a\na\nb");
run_make_test(q!
.PHONY: M a b
M: a b
.SILENT:
a b: ; echo $@
!,
'', "a\nb");
# SV 54740 : don't inherit .SILENT settings in sub-makes
run_make_test(q!
.PHONY: M r a b
r: a b ; @$(MAKE) -f #MAKEFILE# M V=x
a b: ; echo $@
V =
$V.SILENT:
M: a b
!,
'--no-print-directory', "a\nb\necho a\na\necho b\nb");
1;

View file

@ -0,0 +1,31 @@
# -*-perl-*-
$description = "The following test creates a makefile to delete a \n"
."file in the directory. It tests to see if make will \n"
."NOT execute the command unless the rule is given in \n"
."the make command line.";
$example = "EXAMPLE_FILE";
open(MAKEFILE,"> $makefile");
print MAKEFILE qq!
all: ; \@echo This makefile did not clean the dir... good
clean: ; $CMD_rmfile $example
!;
close(MAKEFILE);
touch($example);
run_make_with_options($makefile,"",&get_logfile,0);
$answer = "This makefile did not clean the dir... good\n";
compare_output($answer,&get_logfile(1)) || error("abort");
$answer = "$CMD_rmfile $example\n";
run_make_with_options($makefile,"clean",&get_logfile,0);
if (-f $example) {
$test_passed = 0;
}
compare_output($answer,&get_logfile(1)) || error("abort");
1;