dev/gnu-make, libs/freetype2: vendor as full-fork recipes (path=source, patches baked)

This commit is contained in:
2026-08-01 04:43:37 +03:00
parent e99f220c6a
commit cca1a820f0
1289 changed files with 927111 additions and 10 deletions
@@ -0,0 +1,84 @@
# -*-perl-*-
$description = "Test the abspath functions.";
$details = "";
# Someone needs to rewrite this to be portable for Windows
$port_type eq 'W32' and return -1;
run_make_test('
ifneq ($(realpath $(abspath .)),$(CURDIR))
$(warning .: abs="$(abspath .)" real="$(realpath $(abspath .))" curdir="$(CURDIR)")
endif
ifneq ($(realpath $(abspath ./)),$(CURDIR))
$(warning ./: abs="$(abspath ./)" real="$(realpath $(abspath ./))" curdir="$(CURDIR)")
endif
ifneq ($(realpath $(abspath .///)),$(CURDIR))
$(warning .///: abs="$(abspath .///)" real="$(realpath $(abspath .///))" curdir="$(CURDIR)")
endif
ifneq ($(abspath /),/)
$(warning /: abspath="$(abspath /)")
endif
ifneq ($(abspath ///),/)
$(warning ///: abspath="$(abspath ///)")
endif
ifneq ($(abspath /.),/)
$(warning /.: abspath="$(abspath /.)")
endif
ifneq ($(abspath ///.),/)
$(warning ///.: abspath="$(abspath ///.)")
endif
ifneq ($(abspath /./),/)
$(warning /./: abspath="$(abspath /./)")
endif
ifneq ($(abspath /.///),/)
$(warning /.///: abspath="$(abspath /.///)")
endif
ifneq ($(abspath /..),/)
$(warning /..: abspath="$(abspath /..)")
endif
ifneq ($(abspath ///..),/)
$(warning ///..: abspath="$(abspath ///..)")
endif
ifneq ($(abspath /../),/)
$(warning /../: abspath="$(abspath /../)")
endif
ifneq ($(abspath /..///),/)
$(warning /..///: abspath="$(abspath /..///)")
endif
ifneq ($(abspath /foo/bar/..),/foo)
$(warning /foo/bar/..: abspath="$(abspath /foo/bar/..)")
endif
ifneq ($(abspath /foo/bar/../../../baz),/baz)
$(warning /foo/bar/../../../baz: abspath="$(abspath /foo/bar/../../../baz)")
endif
ifneq ($(abspath /foo/bar/../ /..),/foo /)
$(warning /foo/bar/../ /..: abspath="$(abspath /foo/bar/../ /..)")
endif
.PHONY: all
all: ; @:
',
'',
'');
# This tells the test driver that the perl test script executed properly.
1;
@@ -0,0 +1,44 @@
$description = "The following test creates a makefile to test the addprefix "
."function.";
$details = "";
# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
# THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF
# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
# EXAMPLE: $makefile2 = &get_tmpfile;
open(MAKEFILE,"> $makefile");
# The Contents of the MAKEFILE ...
print MAKEFILE "string := \$(addprefix src${pathsep},a.b.z.foo hacks) \n"
."all: \n"
."\t\@echo \$(string) \n";
# END of Contents of MAKEFILE
close(MAKEFILE);
&run_make_with_options($makefile,"",&get_logfile,0);
# Create the answer to what should be produced by this Makefile
$answer = "src${pathsep}a.b.z.foo src${pathsep}hacks\n";
# COMPARE RESULTS
# In this call to compare output, you should use the call &get_logfile(1)
# to send the name of the last logfile created. You may also use
# the special call &get_logfile(1) which returns the same as &get_logfile(1).
&compare_output($answer,&get_logfile(1));
# This tells the test driver that the perl test script executed properly.
1;
@@ -0,0 +1,36 @@
# -*-perl-*-
$description = "Test the addsuffix function.";
$details = "";
open(MAKEFILE,"> $makefile");
# The Contents of the MAKEFILE ...
print MAKEFILE <<EOMAKE;
string := \$(addsuffix .c,src${pathsep}a.b.z.foo hacks)
one: ; \@echo \$(string)
two: ; \@echo \$(addsuffix foo,)
EOMAKE
close(MAKEFILE);
# TEST 0
&run_make_with_options($makefile, "", &get_logfile);
$answer = "src${pathsep}a.b.z.foo.c hacks.c\n";
&compare_output($answer,&get_logfile(1));
# TEST 1
&run_make_with_options($makefile, "two", &get_logfile);
$answer = "\n";
&compare_output($answer,&get_logfile(1));
# This tells the test driver that the perl test script executed properly.
1;
@@ -0,0 +1,50 @@
# -*-perl-*-
$description = "Test the and & or functions.\n";
$details = "Try various uses of and & or to ensure they all give the correct
results.\n";
# TEST #0
# For $(and ...), it will either be empty or the last value
run_make_test('
NEQ = $(subst $1,,$2)
f =
t = true
all:
@echo 1 $(and ,$t)
@echo 2 $(and $t)
@echo 3 $(and $t,)
@echo 4 $(and z,true,$f,false)
@echo 5 $(and $t,$f,$(info bad short-circuit))
@echo 6 $(and $(call NEQ,a,b),true)
@echo 7 $(and $(call NEQ,a,a),true)
@echo 8 $(and z,true,fal,se) hi
@echo 9 $(and ,true,fal,se)there
@echo 10 $(and $(e) ,$t)',
'',
"1\n2 true\n3\n4\n5\n6 true\n7\n8 se hi\n9 there\n10\n");
# TEST #1
# For $(or ...), it will either be empty or the first true value
run_make_test('
NEQ = $(subst $1,,$2)
f =
t = true
all:
@echo 1 $(or , )
@echo 2 $(or $t)
@echo 3 $(or ,$t)
@echo 4 $(or z,true,$f,false)
@echo 5 $(or $t,$(info bad short-circuit))
@echo 6 $(or $(info short-circuit),$t)
@echo 7 $(or $(call NEQ,a,b),true)
@echo 8 $(or $(call NEQ,a,a),true)
@echo 9 $(or z,true,fal,se) hi
@echo 10 $(or ,true,fal,se)there
@echo 11 $(or $(e) ,$f)',
'',
"short-circuit\n1\n2 true\n3 true\n4 z\n5 true\n6 true\n7 b\n8 true\n9 z hi\n10 truethere\n11\n");
1;
@@ -0,0 +1,44 @@
$description = "The following test creates a makefile to test the suffix "
."function.";
$details = "";
# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
# THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF
# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
# EXAMPLE: $makefile2 = &get_tmpfile;
open(MAKEFILE,"> $makefile");
# The Contents of the MAKEFILE ...
print MAKEFILE "string := \$(basename src${pathsep}a.b.z.foo.c src${pathsep}hacks src.bar${pathsep}a.b.z.foo.c src.bar${pathsep}hacks hacks) \n"
."all: \n"
."\t\@echo \$(string) \n";
# END of Contents of MAKEFILE
close(MAKEFILE);
&run_make_with_options($makefile,"",&get_logfile,0);
# Create the answer to what should be produced by this Makefile
$answer = "src${pathsep}a.b.z.foo src${pathsep}hacks src.bar${pathsep}a.b.z.foo src.bar${pathsep}hacks hacks\n";
# COMPARE RESULTS
# In this call to compare output, you should use the call &get_logfile(1)
# to send the name of the last logfile created. You may also use
# the special call &get_logfile(1) which returns the same as &get_logfile(1).
&compare_output($answer,&get_logfile(1));
# This tells the test driver that the perl test script executed properly.
1;
@@ -0,0 +1,92 @@
# -*-perl-*-
$description = "Test the call function.\n";
$details = "Try various uses of call and ensure they all give the correct
results.\n";
run_make_test(q!
# Simple, just reverse two things
#
reverse = $2 $1
# A complex 'map' function, using recursive 'call'.
#
map = $(foreach a,$2,$(call $1,$a))
# Test using a builtin; this is silly as it's simpler to do without call
#
my-notdir = $(call notdir,$(1))
# Test using non-expanded builtins
#
my-foreach = $(foreach $(1),$(2),$(3))
my-if = $(if $(1),$(2),$(3))
# Test recursive invocations of call with different arguments
#
one = $(1) $(2) $(3)
two = $(call one,$(1),foo,$(2))
# Test recursion on the user-defined function. As a special case make
# won't error due to this.
# Implement transitive closure using $(call ...)
#
DEP_foo = bar baz quux
DEP_baz = quux blarp
rest = $(wordlist 2,$(words ${1}),${1})
tclose = $(if $1,$(firstword $1)\
$(call tclose,$(sort ${DEP_$(firstword $1)} $(call rest,$1))))
all: ; @echo '$(call reverse,bar,foo)'; \
echo '$(call map,origin,MAKE reverse map)'; \
echo '$(call my-notdir,a/b c/d e/f)'; \
echo '$(call my-foreach)'; \
echo '$(call my-foreach,a,,,)'; \
echo '$(call my-if,a,b,c)'; \
echo '$(call two,bar,baz)'; \
echo '$(call tclose,foo)';
!,
"", "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\nfoo bar baz blarp quux \n");
# These won't work because call expands all its arguments first, before
# passing them on, then marks them as resolved/simple, so they're not
# expanded again by the function.
#
# echo '$(call my-foreach,a,x y z,$$(a)$$(a))'; \
# echo '$(call my-if,,$$(info don't print this),$$(info do print this))'
#
# $answer = "xx yy zz\ndo print this\n";
# TEST eclipsing of arguments when invoking sub-calls
run_make_test(q!
all = $1 $2 $3 $4 $5 $6 $7 $8 $9
level1 = $(call all,$1,$2,$3,$4,$5)
level2 = $(call level1,$1,$2,$3)
level3 = $(call level2,$1,$2,$3,$4,$5)
all:
@echo $(call all,1,2,3,4,5,6,7,8,9,10,11)
@echo $(call level1,1,2,3,4,5,6,7,8)
@echo $(call level2,1,2,3,4,5,6,7,8)
@echo $(call level3,1,2,3,4,5,6,7,8)
!,
"", "1 2 3 4 5 6 7 8 9\n1 2 3 4 5\n1 2 3\n1 2 3\n");
# Ensure that variables are defined in global scope even in a $(call ...)
delete $ENV{X123};
run_make_test('
tst = $(eval export X123)
$(call tst)
all: ; @echo "$${X123-not set}"
',
'', "\n");
1;
### Local Variables:
### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
### End:
@@ -0,0 +1,44 @@
$description = "The following test creates a makefile to test the dir "
."function.";
$details = "";
# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
# THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF
# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
# EXAMPLE: $makefile2 = &get_tmpfile;
open(MAKEFILE,"> $makefile");
# The Contents of the MAKEFILE ...
print MAKEFILE "string := \$(dir src${pathsep}foo.c hacks) \n"
."all: \n"
."\t\@echo \$(string) \n";
# END of Contents of MAKEFILE
close(MAKEFILE);
&run_make_with_options($makefile,"",&get_logfile,0);
# Create the answer to what should be produced by this Makefile
$answer = "src${pathsep} .${pathsep}\n";
# COMPARE RESULTS
# In this call to compare output, you should use the call &get_logfile(1)
# to send the name of the last logfile created. You may also use
# the special call &get_logfile(1) which returns the same as &get_logfile(1).
&compare_output($answer,&get_logfile(1));
# This tells the test driver that the perl test script executed properly.
1;
@@ -0,0 +1,71 @@
# -*-Perl-*-
$description = "\
The following test creates a makefile to test the error function.";
$details = "";
open(MAKEFILE,"> $makefile");
print MAKEFILE 'err = $(error Error found!)
ifdef ERROR1
$(error error is $(ERROR1))
endif
ifdef ERROR2
$(error error is $(ERROR2))
endif
ifdef ERROR3
all: some; @echo $(error error is $(ERROR3))
endif
ifdef ERROR4
all: some; @echo error is $(ERROR4)
@echo $(error error is $(ERROR4))
endif
some: ; @echo Some stuff
testvar: ; @: $(err)
';
close(MAKEFILE);
# Test #1
&run_make_with_options($makefile, "ERROR1=yes", &get_logfile, 512);
$answer = "$makefile:4: *** error is yes. Stop.\n";
&compare_output($answer,&get_logfile(1));
# Test #2
&run_make_with_options($makefile, "ERROR2=no", &get_logfile, 512);
$answer = "$makefile:8: *** error is no. Stop.\n";
&compare_output($answer,&get_logfile(1));
# Test #3
&run_make_with_options($makefile, "ERROR3=maybe", &get_logfile, 512);
$answer = "Some stuff\n$makefile:12: *** error is maybe. Stop.\n";
&compare_output($answer,&get_logfile(1));
# Test #4
&run_make_with_options($makefile, "ERROR4=definitely", &get_logfile, 512);
$answer = "Some stuff\n$makefile:17: *** error is definitely. Stop.\n";
&compare_output($answer,&get_logfile(1));
# Test #5
&run_make_with_options($makefile, "testvar", &get_logfile, 512);
$answer = "$makefile:22: *** Error found!. Stop.\n";
&compare_output($answer,&get_logfile(1));
# This tells the test driver that the perl test script executed properly.
1;
### Local Variables:
### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
### End:
@@ -0,0 +1,169 @@
# -*-perl-*-
$description = "Test the eval function.";
$details = "This is a test of the eval function in GNU make.
This function will evaluate inline makefile syntax and incorporate the
results into its internal database.\n";
open(MAKEFILE,"> $makefile");
print MAKEFILE <<'EOF';
define Y
all:: ; @echo $AA
A = B
endef
X = $(eval $(value Y))
$(eval $(shell echo A = A))
$(eval $(Y))
$(eval A = C)
$(eval $(X))
EOF
close(MAKEFILE);
&run_make_with_options($makefile, "", &get_logfile);
# Create the answer to what should be produced by this Makefile
$answer = "AA\nBA\n";
&compare_output($answer,&get_logfile(1));
# Test to make sure defining variables when we have extra scope pushed works
# as expected.
$makefile2 = &get_tmpfile;
open(MAKEFILE,"> $makefile2");
print MAKEFILE <<'EOF';
VARS = A B
VARSET = $(1) = $(2)
$(foreach v,$(VARS),$(eval $(call VARSET,$v,$v)))
all: ; @echo A = $(A) B = $(B)
EOF
close(MAKEFILE);
&run_make_with_options($makefile2, "", &get_logfile);
# Create the answer to what should be produced by this Makefile
$answer = "A = A B = B\n";
&compare_output($answer,&get_logfile(1));
# Test to make sure eval'ing inside conditionals works properly
$makefile3 = &get_tmpfile;
open(MAKEFILE,"> $makefile3");
print MAKEFILE <<'EOF';
FOO = foo
all:: ; @echo it
define Y
all:: ; @echo worked
endef
ifdef BAR
$(eval $(Y))
endif
EOF
close(MAKEFILE);
&run_make_with_options($makefile3, "", &get_logfile);
$answer = "it\n";
&compare_output($answer,&get_logfile(1));
&run_make_with_options($makefile3, "BAR=1", &get_logfile);
$answer = "it\nworked\n";
&compare_output($answer,&get_logfile(1));
# TEST very recursive invocation of eval
$makefile3 = &get_tmpfile;
open(MAKEFILE,"> $makefile3");
print MAKEFILE <<'EOF';
..9 := 0 1 2 3 4 5 6 7 8 9
rev=$(eval res:=)$(foreach word,$1,$(eval res:=${word} ${res}))${res}
a:=$(call rev,${..9})
all: ; @echo '[$(a)]'
EOF
close(MAKEFILE);
&run_make_with_options($makefile3, "", &get_logfile);
$answer = "[ 9 8 7 6 5 4 3 2 1 0 ]\n";
&compare_output($answer,&get_logfile(1));
# TEST eval with no filename context.
# The trick here is that because EVAR is taken from the environment, it must
# be evaluated before every command is invoked. Make sure that works, when
# we have no file context for reading_file (bug # 6195)
$makefile4 = &get_tmpfile;
open(MAKEFILE,"> $makefile4");
print MAKEFILE <<'EOF';
EVAR = $(eval FOBAR = 1)
all: ; @echo "OK"
EOF
close(MAKEFILE);
$ENV{EVAR} = '1';
&run_make_with_options($makefile4, "", &get_logfile);
$answer = "OK\n";
&compare_output($answer,&get_logfile(1));
# Clean out previous information to allow new run_make_test() interface.
# If we ever convert all the above to run_make_test() we can remove this line.
$makefile = undef;
# Test handling of backslashes in strings to be evaled.
run_make_test('
define FOO
all: ; @echo hello \
world
endef
$(eval $(FOO))
', '', 'hello world');
run_make_test('
define FOO
all: ; @echo '."'".'he\llo'."'".'
@echo world
endef
$(eval $(FOO))
', '', 'he\llo
world');
# We don't allow new target/prerequisite relationships to be defined within a
# command script, because these are evaluated after snap_deps() and that
# causes lots of problems (like core dumps!)
# See Savannah bug # 12124.
run_make_test('deps: ; $(eval deps: foo)', '',
'#MAKEFILE#:1: *** prerequisites cannot be defined in recipes. Stop.',
512);
1;
@@ -0,0 +1,222 @@
# -*-perl-*-
$description = 'Test the $(file ...) function.';
# Test > and >>
run_make_test(q!
define A
a
b
endef
B = c d
$(file >file.out,$(A))
$(foreach L,$(B),$(file >> file.out,$L))
x:;@echo hi; cat file.out
!,
'', "hi\na\nb\nc\nd");
unlink('file.out');
# Test >> to a non-existent file
run_make_test(q!
define A
a
b
endef
$(file >> file.out,$(A))
x:;@cat file.out
!,
'', "a\nb");
unlink('file.out');
# Test > with no content
run_make_test(q!
$(file >4touch)
.PHONY:x
x:;@cat 4touch
!,
'', '');
# Test >> with no content
run_make_test(q!
$(file >>4touch)
.PHONY:x
x:;@cat 4touch
!,
'', '');
unlink('4touch');
# Test > to a read-only file
if (defined $ERR_read_only_file) {
touch('file.out');
chmod(0444, 'file.out');
run_make_test(q!
define A
a
b
endef
$(file > file.out,$(A))
x:;@cat file.out
!,
'', "#MAKEFILE#:6: *** open: file.out: $ERR_read_only_file. Stop.",
512);
unlink('file.out');
}
# Use variables for operator and filename
run_make_test(q!
define A
a
b
endef
OP = >
FN = file.out
$(file $(OP) $(FN),$(A))
x:;@cat file.out
!,
'', "a\nb");
unlink('file.out');
# Don't add newlines if one already exists
run_make_test(q!
define A
a
b
endef
$(file >file.out,$(A))
x:;@cat file.out
!,
'', "a\nb");
unlink('file.out');
# Empty text
run_make_test(q!
$(file >file.out,)
$(file >>file.out,)
x:;@cat file.out
!,
'', "\n\n");
unlink('file.out');
# Reading files
run_make_test(q!
$(file >file.out,A = foo)
X1 := $(file <file.out)
$(file >>file.out,B = bar)
$(eval $(file <file.out))
x:;@echo '$(X1)'; echo '$(A)'; echo '$(B)'
!,
'', "A = foo\nfoo\nbar\n");
unlink('file.out');
# Read an empty file.
touch("file.out");
run_make_test(q!# empty file
X1 := x$(file <file.out)y
x:;@echo '$(X1)'
!,
'', "xy\n");
unlink('file.out');
# Read a file whose full contents is a newline.
create_file('file.out', "\n");
run_make_test(q!# <nl>
X1 := x$(file <file.out)y
x:;@echo '$(X1)'
!,
'', "xy\n");
unlink('file.out');
# Read a file which does not end with a newline.
create_file('file.out', "hello");
# echo prints a trailig newline, because run_make_test appends a newline.
run_make_test(q!# hello
X1 := x$(file <file.out)y
x:;@echo $(X1)
!,
'', "xhelloy\n");
unlink('file.out');
# Read a file which ends with a newline.
create_file('file.out', "hello\n");
# echo prints a trailig newline, because run_make_test appends a newline.
run_make_test(q!# hello<nl>
X1 := x$(file <file.out)y
x:;@echo '$(X1)'
!,
'', "xhelloy\n");
unlink('file.out');
# Read a file which ends with multiple newlines.
create_file('file.out', "hello\n\n");
run_make_test(q!# hello<nl><nl>
X1 := x$(file <file.out)y
export X1
x:;@echo "$$X1"
!,
'', "xhello\ny\n");
unlink('file.out');
# Read a file whose contents exceed 200 bytes.
# 200 is the initial size of variable_buffer.
# File bigger than 200 bytes causes a realloc.
# The size of the file in this test not only exceeds 200 bytes, it exceeds 65k.
# Use $(info ...) here to avoid command line limitations
my $s = "hello world, hello world, hello world, hello world, hello world";
my $answer = $s x 2000;
create_file('file.out', $answer);
run_make_test(q!# <hugestring>
X1 := x$(file <file.out)y
x:;@$(info $(X1))
!,
'', "x${answer}y\n#MAKE#: 'x' is up to date.\n");
unlink('file.out');
# Reading from non-existent file
run_make_test(q!
X1 := $(file <file.out)
x:;@echo '$(X1)';
!,
'', "\n");
# Extra arguments in read mode
run_make_test(q!
X1 := $(file <file.out,foo)
x:;@echo '$(X1)';
!,
'', "#MAKEFILE#:2: *** file: too many arguments. Stop.\n", 512);
# Missing filename
run_make_test('$(file >)', '',
"#MAKEFILE#:1: *** file: missing filename. Stop.\n", 512);
run_make_test('$(file >>)', '',
"#MAKEFILE#:1: *** file: missing filename. Stop.\n", 512);
run_make_test('$(file <)', '',
"#MAKEFILE#:1: *** file: missing filename. Stop.\n", 512);
# Bad call
run_make_test('$(file foo)', '',
"#MAKEFILE#:1: *** file: invalid file operation: foo. Stop.\n", 512);
1;
@@ -0,0 +1,58 @@
# -*-perl-*-
$description = "Test the filter and filter-out functions.";
$details = "The makefile created in this test has two variables. The
filter-out function is first used to discard names ending in
.o with a single simple pattern. The second filter-out function
augments the simple pattern with three literal names, which are
also added to the text argument. This tests an internal hash table
which is only used if there are multiple literals present in both
the pattern and text arguments. The result of both filter-out
functions is the same single .elc name.\n";
# Basic test -- filter
run_make_test(q!
files1 := $(filter %.o, foo.elc bar.o lose.o)
files2 := $(filter %.o foo.i, foo.i bar.i lose.i foo.elc bar.o lose.o)
all: ; @echo '$(files1) $(files2)'
!,
'', "bar.o lose.o foo.i bar.o lose.o\n");
# Basic test -- filter-out
run_make_test(q!
files1 := $(filter-out %.o, foo.elc bar.o lose.o)
files2 := $(filter-out foo.i bar.i lose.i %.o, foo.i bar.i lose.i foo.elc bar.o lose.o)
all: ; @echo '$(files1) $(files2)'
!,
'', "foo.elc foo.elc\n");
# Force use of hash (see function.c:func_filter_filterout for params)
my $base = 'foo.1 foo.2 foo.3 foo.4 foo.5 foo.6 foo.7 foo.8 foo.9 foo.10';
my $base10 = join(' ', ($base) x 10);
my $out3 = join(' ', ('foo.3') x 10);
my $out456 = join(' ', ('foo.4 foo.5 foo.6') x 10);
run_make_test("words := $base10" . q!
files1 := $(filter %.3, $(words))
files2 := $(filter %.4 foo.5 foo.6, $(words))
all: ; @echo '$(files1) $(files2)'
!,
'', "$out3 $out456\n");
# Escaped patterns
run_make_test(q!all:;@echo '$(filter foo\%bar,foo%bar fooXbar)'!,
'', "foo%bar\n");
run_make_test(q!all:;@echo '$(filter foo\%\%\\\\\%\%bar,foo%%\\%%bar fooX\\Ybar)'!,
'', "foo%%\\%%bar\n");
run_make_test(q!
X = $(filter foo\\\\\%bar,foo\%bar foo\Xbar)
all:;@echo '$(X)'!,
'', "foo\\%bar\n");
1;
@@ -0,0 +1,47 @@
$description = "The following test creates a makefile to test the findstring "
."function.";
$details = "";
# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
# THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF
# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
# EXAMPLE: $makefile2 = &get_tmpfile;
open(MAKEFILE,"> $makefile");
# The Contents of the MAKEFILE ...
print MAKEFILE "string := \$(findstring port, reporter)\n"
."all: \n"
."\t\@echo \$(string) \n";
# END of Contents of MAKEFILE
close(MAKEFILE);
&run_make_with_options($makefile,
"",
&get_logfile,
0);
# Create the answer to what should be produced by this Makefile
$answer = "port\n";
# COMPARE RESULTS
# In this call to compare output, you should use the call &get_logfile(1)
# to send the name of the last logfile created. You may also use
# the special call &get_logfile(1) which returns the same as &get_logfile(1).
&compare_output($answer,&get_logfile(1));
# This tells the test driver that the perl test script executed properly.
1;
@@ -0,0 +1,44 @@
# -*-perl-*-
$description = "Test the flavor function.";
$details = "";
# Test #1: Test general logic.
#
run_make_test('
s := s
r = r
$(info u $(flavor u))
$(info s $(flavor s))
$(info r $(flavor r))
ra += ra
rc ?= rc
$(info ra $(flavor ra))
$(info rc $(flavor rc))
s += s
r += r
$(info s $(flavor s))
$(info r $(flavor r))
.PHONY: all
all:;@:
',
'',
'u undefined
s simple
r recursive
ra recursive
rc recursive
s simple
r recursive');
# This tells the test driver that the perl test script executed properly.
1;
@@ -0,0 +1,93 @@
# -*-perl-*-
# $Id$
$description = "Test the foreach function.";
$details = "This is a test of the foreach function in gnu make.
This function starts with a space separated list of
names and a variable. Each name in the list is subsituted
into the variable and the given text evaluated. The general
form of the command is $(foreach var,\$list,\$text). Several
types of foreach loops are tested\n";
# TEST 0
# Set an environment variable that we can test in the makefile.
$ENV{FOOFOO} = 'foo foo';
run_make_test("space = ' '".'
null :=
auto_var = udef space CC null FOOFOO MAKE foo CFLAGS WHITE @ <
foo = bletch null @ garf
av = $(foreach var, $(auto_var), $(origin $(var)) )
override WHITE := BLACK
for_var = $(addsuffix .c,foo $(null) $(foo) $(space) $(av) )
fe = $(foreach var2, $(for_var),$(subst .c,.o, $(var2) ) )
all: auto for2
auto : ; @echo $(av)
for2: ; @echo $(fe)',
'-e WHITE=WHITE CFLAGS=',
"undefined file default file environment default file command line override automatic automatic
foo.o bletch.o null.o @.o garf.o .o .o undefined.o file.o default.o file.o environment.o default.o file.o command.o line.o override.o automatic.o automatic.o");
# TEST 1: Test that foreach variables take precedence over global
# variables in a global scope (like inside an eval). Tests bug #11913
run_make_test('
.PHONY: all target
all: target
x := BAD
define mktarget
target: x := $(x)
target: ; @echo "$(x)"
endef
x := GLOBAL
$(foreach x,FOREACH,$(eval $(value mktarget)))',
'',
'FOREACH');
# Allow variable names with trailing space
run_make_test(q!
$(foreach \
a \
, b c d \
, $(info $a))
all:;@:
!,
"", "b\nc\nd\n");
# Allow empty variable names. We still expand the body.
run_make_test('
x = $(foreach ,1 2 3,a)
y := $x
all: ; @echo $y',
'', "a a a\n");
# Check some error conditions.
run_make_test('
x = $(foreach )
y = $x
all: ; @echo $y',
'',
"#MAKEFILE#:2: *** insufficient number of arguments (1) to function 'foreach'. Stop.",
512);
run_make_test('
x = $(foreach x,y)
y := $x
all: ; @echo $y',
'',
"#MAKEFILE#:2: *** insufficient number of arguments (2) to function 'foreach'. Stop.",
512);
1;
@@ -0,0 +1,116 @@
# -*-perl-*-
$description = 'Test the $(guile ...) function.';
$details = 'This only works on systems that support it.';
# If this instance of make doesn't support GNU Guile, skip it
# This detects if guile is loaded using the "load" directive
# $makefile = get_tmpfile();
# open(MAKEFILE, "> $makefile") || die "Failed to open $makefile: $!\n";
# print MAKEFILE q!
# -load guile
# all: ; @echo $(filter guile,$(.LOADED))
# !;
# close(MAKEFILE) || die "Failed to write $makefile: $!\n";
# $cmd = subst_make_string("#MAKEPATH# -f $makefile");
# $log = get_logfile(0);
# $code = run_command_with_output($log, $cmd);
# read_file_into_string ($log) eq "guile\n" and $FEATURES{guile} = 1;
# If we don't have Guile support, never mind.
exists $FEATURES{guile} or return -1;
# Guile and Valgrind don't play together at all.
$valgrind and return -1;
# Verify simple data type conversions
# Currently we don't support vectors:
# echo '$(guile (vector 1 2 3))'; \
run_make_test(q!
x:;@echo '$(guile #f)'; \
echo '$(guile #t)'; \
echo '$(guile #\c)'; \
echo '$(guile 1234)'; \
echo '$(guile 'foo)'; \
echo '$(guile "bar")'; \
echo '$(guile (cons 'a 'b))'; \
echo '$(guile '(a b (c . d) 1 (2) 3))'
!,
'', "\n#t\nc\n1234\nfoo\nbar\na b\na b c d 1 2 3");
# Verify guile functions in variables -- SV 43378
run_make_test(q!
res := $(guile #f) \
$(guile #t) \
$(guile #\c) \
$(guile 1234) \
$(guile 'foo) \
$(guile "bar") \
$(guile (cons 'a 'b)) \
$(guile '(a b (c . d) 1 (2) 3))
x:;@echo '$(res)'
!,
'', " #t c 1234 foo bar a b a b c d 1 2 3");
# Verify the gmk-expand function
run_make_test(q!
VAR = $(guile (gmk-expand "$(shell echo hi)"))
x:;@echo '$(VAR)'
!,
'', "hi");
# Verify the gmk-eval function
# Prove that the string is expanded only once (by eval)
run_make_test(q!
TEST = bye
EVAL = VAR = $(TEST) $(shell echo there)
$(guile (gmk-eval "$(value EVAL)"))
TEST = hi
x:;@echo '$(VAR)'
!,
'', "hi there");
# Verify the gmk-eval function with a list
run_make_test(q!
$(guile (gmk-eval '(VAR = 1 (2) () 3)))
x:;@echo '$(VAR)'
!,
'', "1 2 3");
# Verify the gmk-var function
run_make_test(q!
VALUE = hi $(shell echo there)
VAR = $(guile (gmk-var "VALUE"))
x:;@echo '$(VAR)'
!,
'', "hi there");
# Verify the gmk-var function with a symbol
run_make_test(q!
VALUE = hi $(shell echo there)
VAR = $(guile (gmk-var 'VALUE))
x:;@echo '$(VAR)'
!,
'', "hi there");
# Write a Guile program using define and run it
run_make_test(q!
# Define the "fib" function in Guile
define fib
;; A procedure for counting the n:th Fibonacci number
;; See SICP, p. 37
(define (fib n)
(cond ((= n 0) 0)
((= n 1) 1)
(else (+ (fib (- n 1))
(fib (- n 2))))))
endef
$(guile $(fib))
# Now run it
x:;@echo $(guile (fib $(FIB)))
!,
'FIB=10', "55");
1;
@@ -0,0 +1,33 @@
# -*-perl-*-
$description = "Test the if function.\n";
$details = "Try various uses of if and ensure they all give the correct
results.\n";
open(MAKEFILE, "> $makefile");
print MAKEFILE <<EOMAKE;
NEQ = \$(subst \$1,,\$2)
e =
all:
\t\@echo 1 \$(if ,true,false)
\t\@echo 2 \$(if ,true,)
\t\@echo 3 \$(if ,true)
\t\@echo 4 \$(if z,true,false)
\t\@echo 5 \$(if z,true,\$(shell echo hi))
\t\@echo 6 \$(if ,\$(shell echo hi),false)
\t\@echo 7 \$(if \$(call NEQ,a,b),true,false)
\t\@echo 8 \$(if \$(call NEQ,a,a),true,false)
\t\@echo 9 \$(if z,true,fal,se) hi
\t\@echo 10 \$(if ,true,fal,se)there
\t\@echo 11 \$(if \$(e) ,true,false)
EOMAKE
close(MAKEFILE);
&run_make_with_options($makefile, "", &get_logfile);
$answer = "1 false\n2\n3\n4 true\n5 true\n6 false\n7 true\n8 false\n9 true hi\n10 fal,sethere\n11 false\n";
&compare_output($answer, &get_logfile(1));
1;
@@ -0,0 +1,72 @@
# -*-perl-*-
$description = "Test the intcmp function.\n";
$details = "Try various uses of intcmp and ensure they all give the correct
results.\n";
run_make_test('# Negative
n = -10
# Zero
z = 0
# Positive
p = 888
min = -9223372036854775808
max = 9223372036854775807
huge = 8857889956778499040639527525992734031025567913257255490371761260681427
.RECIPEPREFIX = >
all:
> @echo 0_1 $(intcmp $n,$n)
> @echo 0_2 $(intcmp $z,$z)
> @echo 0_3 $(intcmp -$z,$z)
> @echo 0_4 $(intcmp $p,$p)
> @echo 0_5 $(intcmp $n,$z)
> @echo 0_6 $(intcmp $z,$n)
> @echo 1_1 $(intcmp $n,$n,$(shell echo lt))
> @echo 1_2 $(intcmp $n,$z,$(shell echo lt))
> @echo 1_3 $(intcmp $z,$n,$(shell echo lt))
> @echo 2_1 $(intcmp $n,$p,lt,ge)
> @echo 2_2 $(intcmp $z,$z,lt,ge)
> @echo 2_3 $(intcmp $p,$n,lt,ge)
> @echo 3_0 $(intcmp $p,$n,lt,eq,)
> @echo 3_1 $(intcmp $z,$p,lt,eq,gt)
> @echo 3_2 $(intcmp $p,$z,lt,eq,gt)
> @echo 3_3 $(intcmp $p,$p,lt,eq,gt)
> @echo 4_0 $(intcmp $(min),$(max),lt,eq,gt)
> @echo 4_1 $(intcmp $(max),$(min),lt,eq,gt)
> @echo 4_2 $(intcmp $(min),$(min),lt,eq,gt)
> @echo 4_3 $(intcmp $(max),$(max),lt,eq,gt)
> @echo 5_0 $(intcmp -$(huge),$(huge),lt,eq,gt)
> @echo 5_1 $(intcmp $(huge),-$(huge),lt,eq,gt)
> @echo 5_2 $(intcmp -$(huge),-$(huge),lt,eq,gt)
> @echo 5_3 $(intcmp +$(huge),$(huge),lt,eq,gt)
', '', "0_1 -10\n0_2 0\n0_3 0\n0_4 888\n0_5\n0_6\n1_1\n1_2 lt\n1_3\n2_1 lt\n2_2 ge\n2_3 ge\n3_0\n3_1 lt\n3_2 gt\n3_3 eq\n4_0 lt\n4_1 gt\n4_2 eq\n4_3 eq\n5_0 lt\n5_1 gt\n5_2 eq\n5_3 eq\n");
# Test error conditions
run_make_test('
intcmp-e1: ; @echo $(intcmp 12a,1,foo)
intcmp-e2: ; @echo $(intcmp 0,,foo)
intcmp-e3: ; @echo $(intcmp -1,)
intcmp-e4: ; @echo $(intcmp ,55)',
'intcmp-e1',
"#MAKEFILE#:2: *** non-numeric first argument to 'intcmp' function: '12a'. Stop.",
512);
run_make_test(undef,
'intcmp-e2',
"#MAKEFILE#:3: *** non-numeric second argument to 'intcmp' function: empty value. Stop.",
512);
run_make_test(undef,
'intcmp-e3',
"#MAKEFILE#:4: *** non-numeric second argument to 'intcmp' function: empty value. Stop.",
512);
run_make_test(undef,
'intcmp-e4',
"#MAKEFILE#:5: *** non-numeric first argument to 'intcmp' function: empty value. Stop.",
512);
# This tells the test driver that the perl test script executed properly.
1;
@@ -0,0 +1,44 @@
$description = "The following test creates a makefile to test the join "
."function.";
$details = "";
# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
# THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF
# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
# EXAMPLE: $makefile2 = &get_tmpfile;
open(MAKEFILE,"> $makefile");
# The Contents of the MAKEFILE ...
print MAKEFILE "string := \$(join a b c,foo hacks .pl1) \n"
."all: \n"
."\t\@echo \$(string) \n";
# END of Contents of MAKEFILE
close(MAKEFILE);
&run_make_with_options($makefile,"",&get_logfile,0);
# Create the answer to what should be produced by this Makefile
$answer = "afoo bhacks c.pl1\n";
# COMPARE RESULTS
# In this call to compare output, you should use the call &get_logfile(1)
# to send the name of the last logfile created. You may also use
# the special call &get_logfile(1) which returns the same as &get_logfile(1).
&compare_output($answer,&get_logfile(1));
# This tells the test driver that the perl test script executed properly.
1;
@@ -0,0 +1,111 @@
# -*-perl-*-
# $Id$
$description = "Test the let function.";
$details = "This is a test of the let function in gnu make.
This function destructures a list of values and binds each
value to a variable name in a list of variable names.
Superfluous variable names are assigned the empty string and
the remaining values are assigned to the last variable name.
The binding holds for the duration of the evaluation of the
given text and no longer. The general form of the command
is $(let \$vars,\$list,\$text). Several types of let
assignments are tested\n";
# check for mismatched var and list word counts
run_make_test(q!
a = bad
b = news
x = $(let a b,1 2,$a $b)
y = $(let a,1 2,$a)
z = $(let a b,1,$a $b)
all:;@echo 'a=,$a,' 'b=,$b,' 'x=,$x,' 'y=,$y,' 'z=,$z,'
!,
'', "a=,bad, b=,news, x=,1 2, y=,1 2, z=,1 ,\n");
# check for whitespace
run_make_test(q!
a = bad
b = news
x = $(let a b, 1 2 ,+$a+$b+)
y = $(let a, 1 2 ,+$a+)
z = $(let a b, 1 ,+$a+$b+)
all:;@echo 'a=,$a,' 'b=,$b,' 'x=,$x,' 'y=,$y,' 'z=,$z,'
!,
'', "a=,bad, b=,news, x=,+1+2 +, y=,+1 2 +, z=,+1++,\n");
# Allow empty variable names and empty value list.
# We still expand the list and body.
run_make_test('
null =
v = $(let ,$(info blankvar),abc)
x = $(let $(null),$(info side-effect),abc)
y = $(let y,,$ydef)
all: ; @echo $v/$x/$y',
'', "blankvar\nside-effect\nabc/abc/def\n");
# The example macro from the manual.
run_make_test('
reverse = $(let first rest,$1,$(if $(rest),$(call reverse,$(rest)) )$(first))
all: ; @echo $(call reverse, \
moe miny meeny eeny \
)',
'', "eeny meeny miny moe\n");
# Set an environment variable that we can test in the makefile.
$ENV{FOOFOO} = 'foo foo';
# Verify masking: expansion outside the scope of let is unaffected.
run_make_test('
auto_var = \
udef \
CC \
FOOFOO \
MAKE \
foo \
CFLAGS \
WHITE \
@ \
<
av = $(foreach var, $(auto_var), $(origin $(var)) )
foo = bletch null @ garf
override WHITE := BLACK
define mktarget
target: foo := $(foo)
target: ; @echo $(AR)_$(foo)_
endef
all: auto target
auto: ; @echo $(let $(auto_var),,$(av)) $(av)
$(let AR foo,bar foo ,$(eval $(value mktarget)))',
'-e WHITE=WHITE CFLAGS=',
"automatic automatic automatic automatic automatic automatic automatic automatic automatic undefined default environment default file command line override automatic automatic
ar_foo _
");
# Check some error conditions.
run_make_test('
x = $(let )
y = $x
all: ; @echo $y',
'',
"#MAKEFILE#:2: *** insufficient number of arguments (1) to function 'let'. Stop.",
512);
run_make_test('
x = $(let x,y)
y := $x
all: ; @echo $y',
'',
"#MAKEFILE#:2: *** insufficient number of arguments (2) to function 'let'. Stop.",
512);
1;
@@ -0,0 +1,44 @@
$description = "The following test creates a makefile to test the notdir "
."function.";
$details = "";
# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
# THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF
# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
# EXAMPLE: $makefile2 = &get_tmpfile;
open(MAKEFILE,"> $makefile");
# The Contents of the MAKEFILE ...
print MAKEFILE "string := \$(notdir ${pathsep}src${pathsep}foo.c hacks) \n"
."all: \n"
."\t\@echo \$(string) \n";
# END of Contents of MAKEFILE
close(MAKEFILE);
&run_make_with_options($makefile,"",&get_logfile,0);
# Create the answer to what should be produced by this Makefile
$answer = "foo.c hacks\n";
# COMPARE RESULTS
# In this call to compare output, you should use the call &get_logfile(1)
# to send the name of the last logfile created. You may also use
# the special call &get_logfile(1) which returns the same as &get_logfile(1).
&compare_output($answer,&get_logfile(1));
# This tells the test driver that the perl test script executed properly.
1;
@@ -0,0 +1,49 @@
# -*-perl-*-
$description = "Test the origin function.";
$details = "This is a test of the origin function in gnu make.
This function will report on where a variable was
defined per the following list:
'undefined' never defined
'default' default definition
'environment' environment var without -e
'environment override' environment var with -e
'file' defined in makefile
'command line' defined on the command line
'override' defined by override in makefile
'automatic' Automatic variable\n";
# Set an environment variable
$ENV{MAKETEST} = 1;
run_make_test('
foo := bletch garf
auto_var = undefined CC MAKETEST MAKE foo CFLAGS WHITE @
av = $(foreach var, $(auto_var), $(origin $(var)) )
override WHITE := BLACK
.RECIPEPREFIX = >
all: auto
> @echo $(origin undefined)
> @echo $(origin CC)
> @echo $(origin MAKETEST)
> @echo $(origin MAKE)
> @echo $(origin foo)
> @echo $(origin CFLAGS)
> @echo $(origin WHITE)
> @echo $(origin @)
auto :
> @echo $(av)',
'-e WHITE=WHITE CFLAGS=',
'undefined default environment default file command line override automatic
undefined
default
environment
default
file
command line
override
automatic');
1;
@@ -0,0 +1,92 @@
# -*-perl-*-
$description = "Test the realpath functions.";
$details = "";
# Check the local directory's realpath
run_make_test('
ifneq ($(realpath .),$(CURDIR))
$(warning $(realpath .) != $(CURDIR))
endif
ifneq ($(realpath ./),$(CURDIR))
$(warning $(realpath ./) != $(CURDIR))
endif
ifneq ($(realpath .///),$(CURDIR))
$(warning $(realpath .///) != $(CURDIR))
endif
.PHONY: all
all: ; @:
',
'', '');
# Find the realpath to the root of the partition
create_file('root.mk', 'all:;$(info $(realpath /))');
my $root = `$make_path -sf root.mk`;
unlink('root.mk');
chomp $root;
my $tst = '
ifneq ($(realpath /.),#ROOT#)
$(warning $(realpath /.) != #ROOT#)
endif
ifneq ($(realpath /./),#ROOT#)
$(warning $(realpath /./) != #ROOT#)
endif
ifneq ($(realpath /.///),#ROOT#)
$(warning $(realpath /.///) != #ROOT#)
endif
ifneq ($(realpath /..),#ROOT#)
$(warning $(realpath /..) != #ROOT#)
endif
ifneq ($(realpath /../),#ROOT#)
$(warning $(realpath /../) != #ROOT#)
endif
ifneq ($(realpath /..///),#ROOT#)
$(warning $(realpath /..///) != #ROOT#)
endif
ifneq ($(realpath . /..),$(CURDIR) #ROOT#)
$(warning $(realpath . /..) != $(CURDIR) #ROOT#)
endif
.PHONY: all
all: ; @:
';
$tst =~ s/#ROOT#/$root/g;
run_make_test($tst, '', '');
# On Windows platforms "//" means something special. So, don't do these tests
# there.
if ($port_type ne 'W32') {
$tst = '
ifneq ($(realpath ///),#ROOT#)
$(warning $(realpath ///) != #ROOT#)
endif
ifneq ($(realpath ///.),#ROOT#)
$(warning $(realpath ///.) != #ROOT#)
endif
ifneq ($(realpath ///..),#ROOT#)
$(warning $(realpath ///..) != #ROOT#)
endif
.PHONY: all
all: ; @:';
$tst =~ s/#ROOT#/$root/g;
run_make_test($tst, '', '');
}
# This tells the test driver that the perl test script executed properly.
1;
@@ -0,0 +1,214 @@
# -*-perl-*-
$description = 'Test the $(shell ...) function.';
$details = '';
# Test standard shell
run_make_test('.PHONY: all
OUT := $(shell echo hi)
all: ; @echo $(OUT)
','','hi');
# Test shells inside rules.
run_make_test('.PHONY: all
all: ; @echo $(shell echo hi)
','','hi');
# Verify .SHELLSTATUS
run_make_test('.PHONY: all
PRE := $(.SHELLSTATUS)
$(shell exit 0)
OK := $(.SHELLSTATUS)
$(shell exit 1)
BAD := $(.SHELLSTATUS)
all: ; @echo PRE=$(PRE) OK=$(OK) BAD=$(BAD)
','','PRE= OK=0 BAD=1');
# Test unescaped comment characters in shells. Savannah bug #20513
run_make_test(q!
FOO := $(shell echo '#')
foo: ; echo '$(FOO)'
!,
'', "echo '#'\n#\n");
# Test that exported variables are passed to $(shell ...)
$ENV{FOO} = 'baz';
run_make_test(q!
OUT = $(shell echo $$FOO)
foo: ; @echo '$(OUT)'
!,
'', 'baz');
$ENV{FOO} = 'baz';
run_make_test(q!
FOO = bar
OUT = $(shell echo $$FOO)
foo: ; @echo '$(OUT)'
!,
'', 'bar');
run_make_test(q!
export FOO = bar
OUT = $(shell echo $$FOO)
foo: ; @echo '$(OUT)'
!,
'', 'bar');
# Test shells inside exported environment variables, simply expanded.
run_make_test('
export HI := $(shell echo hi)
.PHONY: all
all: ; @echo $$HI
',
'','hi');
# Test shells inside exported environment variables. See SV 10593
run_make_test('
export HI = $(shell echo hi)
.PHONY: all
all: ; @echo $$HI
',
'',"hi");
$ENV{HI} = 'foo';
run_make_test('
HI = $(shell echo hi)
.PHONY: all
all: ; @echo $$HI
',
'',"hi");
$ENV{HI} = 'foo';
run_make_test('
HI = $(shell echo hi)
bad := $(HI)
.PHONY: all
all: ; @echo $$HI $(bad)
',
'',"hi hi");
# SV 63016: Exported variable that contains a variable containing $(shell...)
run_make_test('
HI = $(shell echo hi)
export bad = $(HI)
.PHONY: all
all:; : $(HI)
',
'',": hi");
$ENV{HI} = 'outer';
run_make_test('
export HI = $(shell echo $$HI)
.PHONY: all
all:; @echo $$HI
',
'',"outer");
$ENV{HI} = 'outer';
run_make_test('
export HI = $(shell echo $$HI)
.PHONY: all
all:; : $(HI)
',
'',": outer");
if ($port_type ne 'W32') {
# Test shell errors in recipes including offset
# This needs to be ported to Windows, or else Windows error messages
# need to converted to look like more normal make errors.
run_make_test('
.RECIPEPREFIX = >
all:
>@echo hi
>$(shell ./basdfdfsed there)
>@echo $(.SHELLSTATUS)
',
'', "#MAKE#: ./basdfdfsed: $ERR_no_such_file\nhi\n127\n");
run_make_test('
$(shell ./basdfdfsed where)
all: ; @echo $(.SHELLSTATUS)
',
'', "#MAKE#: ./basdfdfsed: $ERR_no_such_file\n127\n");
# Test SHELLSTATUS for kill.
# This test could be ported to Windows, using taskkill ... ?
# Figure out the exit code for SIGINT
my $pid = fork();
if (! $pid) {
exec('kill -2 $$') or die "exec: Cannot execute sleep\n";
}
waitpid($pid, 0);
# .SHELLSTATUS for a signal gives 128 + the signal number
my $ret = $?;
if ($ret > 255) {
# Solaris 10 perl 5.8.4 puts signal number + 128 into the high 8 bits.
$ret >>= 8;
}
$ret |= 128;
run_make_test('.PHONY: all
$(shell kill -2 $$$$)
STAT := $(.SHELLSTATUS)
all: ; @echo STAT=$(STAT)
','',"STAT=$ret\n");
# Test that not-found errors can be redirected
if ($ERR_command_not_found) {
$_ = $ERR_command_not_found;
s/#CMDNAME#/bad-command/g;
run_make_test(q!
out := $(shell bad-command 2>&1)
all: ; @echo '$(.SHELLSTATUS): $(out)'
!,
'', "127: $_\n");
}
# If we're using pipes for jobserver, then we will close them and not
# allow them to be available to sub-makes invoked via $(shell ...)
if (exists $FEATURES{'jobserver'}) {
run_make_test(q!
ifeq ($(ELT),)
default:; @$(MAKE) -f #MAKEFILE# ELT=1
else ifeq ($(ELT),1)
OUTPUT := $(shell $(MAKE) -f #MAKEFILE# ELT=2)
$(info $(OUTPUT))
default:;: $(ELT)
else
default:;: $(ELT)
endif
!,
'--no-print-directory -j2 --jobserver-style=pipe', "#MAKE#[2]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.\n: 2\n: 1");
}
# This crashes if we use vfork and don't reset environ properly
run_make_test(q!
export PATH = $(shell echo "tests:$$PATH")
foo = $(shell echo yes)
all:;echo $(foo)
!,
'', "echo yes\nyes\n");
}
# If we're not using pipes for jobserver, then they are available in sub-makes
# invoked by $(shell ...)
if ($port_type eq 'W32' || exists $FEATURES{'jobserver-fifo'}) {
run_make_test(q!
ifeq ($(ELT),)
default:; @$(MAKE) -f #MAKEFILE# ELT=1
else ifeq ($(ELT),1)
OUTPUT := $(shell $(MAKE) -f #MAKEFILE# ELT=2)
$(info $(OUTPUT))
default:;: $(ELT)
else
default:;: $(ELT)
endif
!,
'--no-print-directory -j2', ": 2\n: 1");
}
1;
@@ -0,0 +1,51 @@
# -*-perl-*-
$description = "The following test creates a makefile to verify
the ability of make to sort lists of object. Sort
will also remove any duplicate entries. This will also
be tested.";
$details = "The make file is built with a list of object in a random order
and includes some duplicates. Make should sort all of the elements
remove all duplicates\n";
run_make_test('
foo := moon_light days
foo1:= jazz
bar := captured
bar2 = boy end, has rise A midnight
bar3:= $(foo)
s1 := _by
s2 := _and_a
t1 := $(addsuffix $(s1), $(bar) )
t2 := $(addsuffix $(s2), $(foo1) )
t3 := $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2)
t4 := $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3)
t5 := $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4)
t6 := $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5)
t7 := $(t6) $(t6) $(t6)
p1 := $(addprefix $(foo1), $(s2) )
blank:=
all:
@echo $(sort $(bar2) $(foo) $(addsuffix $(s1), $(bar) ) $(t2) $(bar2) $(bar3))
@echo $(sort $(blank) $(foo) $(bar2) $(t1) $(p1) )
@echo $(sort $(foo) $(bar2) $(t1) $(t4) $(t5) $(t7) $(t6) )
',
'', 'A boy captured_by days end, has jazz_and_a midnight moon_light rise
A boy captured_by days end, has jazz_and_a midnight moon_light rise
A boy captured_by days end, has jazz_and_a midnight moon_light rise
');
# Test with non-space/tab whitespace. Note that you can't see the
# original bug except using valgrind.
run_make_test("FOO = a b\tc\rd\fe \f \f \f \f \ff
all: ; \@echo \$(words \$(sort \$(FOO)))\n",
'', "6\n");
1;
### Local Variables:
### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
### End:
@@ -0,0 +1,57 @@
# -*-perl-*-
$description = "The following test creates a makefile to verify
the ability of make to strip white space from lists of object.\n";
$details = "The make file is built with a list of objects that contain white space
These are then run through the strip command to remove it. This is then
verified by echoing the result.\n";
open(MAKEFILE,"> $makefile");
# The Contents of the MAKEFILE ...
print MAKEFILE <<'EOMAKE';
TEST1 := "Is this TERMINAL fun? What makes you believe is this terminal fun? JAPAN is a WONDERFUL planet -- I wonder if we will ever reach their level of COMPARATIVE SHOPPING..."
E :=
TEST2 := $E try this and this $E
define TEST3
and these test out
some
blank lines
endef
.PHONY: all
all:
@echo '$(strip $(TEST1) )'
@echo '$(strip $(TEST2) )'
@echo '$(strip $(TEST3) )'
space: ; @echo '$(strip ) $(strip )'
EOMAKE
# END of Contents of MAKEFILE
close(MAKEFILE);
&run_make_with_options($makefile,"",&get_logfile);
$answer = "\"Is this TERMINAL fun? What makes you believe is this terminal fun? JAPAN is a WONDERFUL planet -- I wonder if we will ever reach their level of COMPARATIVE SHOPPING...\"
try this and this
and these test out some blank lines
";
&compare_output($answer,&get_logfile(1));
&run_make_with_options($makefile,"space",&get_logfile);
$answer = " \n";
&compare_output($answer,&get_logfile(1));
1;
@@ -0,0 +1,38 @@
# -*-perl-*-
$description = "Test the subst and patsubst functions";
$details = "";
# Generic patsubst test: test both the function and variable form.
run_make_test('
foo := a.o b.o c.o
bar := $(foo:.o=.c)
bar2:= $(foo:%.o=%.c)
bar3:= $(patsubst %.c,%.o,x.c.c bar.c)
all:;@echo $(bar); echo $(bar2); echo $(bar3)',
'',
'a.c b.c c.c
a.c b.c c.c
x.c.o bar.o');
# Patsubst without '%'--shouldn't match because the whole word has to match
# in patsubst. Based on a bug report by Markus Mauhart <qwe123@chello.at>
run_make_test('all:;@echo $(patsubst Foo,Repl,FooFoo)', '', 'FooFoo');
# Variable subst where a pattern matches multiple times in a single word.
# Based on a bug report by Markus Mauhart <qwe123@chello.at>
run_make_test('
A := fooBARfooBARfoo
all:;@echo $(A:fooBARfoo=REPL)', '', 'fooBARREPL');
1;
@@ -0,0 +1,57 @@
$description = "The following test creates a makefile to test the suffix\n"
."function. \n";
$details = "The suffix function will return the string following the last _._\n"
."the list provided. It will provide all of the unique suffixes found\n"
."in the list. The long strings are sorted to remove duplicates.\n";
# IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
# THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF
# HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
# EXAMPLE: $makefile2 = &get_tmpfile;
open(MAKEFILE,"> $makefile");
# The Contents of the MAKEFILE ...
print MAKEFILE "string := word.pl general_test2.pl1 FORCE.pl word.pl3 generic_test.perl /tmp.c/bar foo.baz/bar.c MAKEFILES_variable.c\n"
."string2 := \$(string) \$(string) \$(string) \$(string) \$(string) \$(string) \$(string)\n"
."string3 := \$(string2) \$(string2) \$(string2) \$(string2) \$(string2) \$(string2) \$(string2)\n"
."string4 := \$(string3) \$(string3) \$(string3) \$(string3) \$(string3) \$(string3) \$(string3)\n"
."all: \n"
."\t\@echo \$(suffix \$(string)) \n"
."\t\@echo \$(sort \$(suffix \$(string4))) \n"
."\t\@echo \$(suffix \$(string) a.out) \n"
."\t\@echo \$(sort \$(suffix \$(string3))) \n";
# END of Contents of MAKEFILE
close(MAKEFILE);
&run_make_with_options($makefile,"",&get_logfile,0);
# Create the answer to what should be produced by this Makefile
# COMPARE RESULTS
$answer = ".pl .pl1 .pl .pl3 .perl .c .c\n"
.".c .perl .pl .pl1 .pl3\n"
.".pl .pl1 .pl .pl3 .perl .c .c .out\n"
.".c .perl .pl .pl1 .pl3\n";
# In this call to compare output, you should use the call &get_logfile(1)
# to send the name of the last logfile created. You may also use
# the special call &get_logfile(1) which returns the same as &get_logfile(1).
&compare_output($answer,&get_logfile(1));
# This tells the test driver that the perl test script executed properly.
1;
@@ -0,0 +1,30 @@
# -*-perl-*-
$description = "Test the value function.";
$details = "This is a test of the value function in GNU make.
This function will evaluate to the value of the named variable with no
further expansion performed on it.\n";
open(MAKEFILE,"> $makefile");
print MAKEFILE <<'EOF';
export FOO = foo
recurse = FOO = $FOO
static := FOO = $(value FOO)
all: ; @echo $(recurse) $(value recurse) $(static) $(value static)
EOF
close(MAKEFILE);
&run_make_with_options($makefile, "", &get_logfile);
# Create the answer to what should be produced by this Makefile
$answer = "FOO = OO FOO = foo FOO = foo FOO = foo\n";
&compare_output($answer,&get_logfile(1));
1;
@@ -0,0 +1,83 @@
# -*-Perl-*-
$description = "\
The following test creates a makefile to test the warning function.";
$details = "";
open(MAKEFILE,"> $makefile");
print MAKEFILE <<'EOF';
ifdef WARNING1
$(warning warning is $(WARNING1))
endif
ifdef WARNING2
$(warning warning is $(WARNING2))
endif
ifdef WARNING3
all: some; @echo hi $(warning warning is $(WARNING3))
endif
ifdef WARNING4
all: some; @echo hi
@echo there $(warning warning is $(WARNING4))
endif
some: ; @echo Some stuff
EOF
close(MAKEFILE);
# Test #1
&run_make_with_options($makefile, "WARNING1=yes", &get_logfile, 0);
$answer = "$makefile:2: warning is yes\nSome stuff\n";
&compare_output($answer,&get_logfile(1));
# Test #2
&run_make_with_options($makefile, "WARNING2=no", &get_logfile, 0);
$answer = "$makefile:6: warning is no\nSome stuff\n";
&compare_output($answer,&get_logfile(1));
# Test #3
&run_make_with_options($makefile, "WARNING3=maybe", &get_logfile, 0);
$answer = "Some stuff\n$makefile:10: warning is maybe\nhi\n";
&compare_output($answer,&get_logfile(1));
# Test #4
&run_make_with_options($makefile, "WARNING4=definitely", &get_logfile, 0);
$answer = "Some stuff\n$makefile:15: warning is definitely\nhi\nthere\n";
&compare_output($answer,&get_logfile(1));
# Test linenumber offset
run_make_test(q!
all: one two
$(warning in $@ line 3)
@true
$(warning in $@ line 5)
one two:
$(warning in $@ line 8)
@true
$(warning in $@ line 10)
!,
'', "#MAKEFILE#:8: in one line 8
#MAKEFILE#:10: in one line 10
#MAKEFILE#:8: in two line 8
#MAKEFILE#:10: in two line 10
#MAKEFILE#:3: in all line 3
#MAKEFILE#:5: in all line 5\n");
# This tells the test driver that the perl test script executed properly.
1;
### Local Variables:
### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
### End:
@@ -0,0 +1,163 @@
# -*-perl-*-
$description = "The following test creates a makefile to test wildcard
expansions and the ability to put a command on the same
line as the target name separated by a semi-colon.";
$details = "\
This test creates 4 files by the names of 1.example,
two.example and 3.example. We execute three tests. The first
executes the print1 target which tests the '*' wildcard by
echoing all filenames by the name of '*.example'. The second
test echo's all files which match '?.example' and
[a-z0-9].example. Lastly we clean up all of the files using
the '*' wildcard as in the first test";
touch("example.1");
touch("example.two");
touch("example.3");
touch("example.for");
touch("example._");
# TEST #1
# -------
run_make_test(qq/
.PHONY: print1 print2 clean
print1: ;\@echo \$(wildcard example.*)
print2:
\t\@echo \$(wildcard example.?)
\t\@echo \$(wildcard example.[a-z0-9])
\t\@echo \$(wildcard example.[!A-Za-z_\\!])
clean:
\t$CMD_rmfile \$(wildcard example.*)
/,
'print1', "example.1 example.3 example._ example.for example.two\n");
# TEST #2
# -------
run_make_test(undef, 'print2', "example.1 example.3 example._\n"
."example.1 example.3\n"
."example.1 example.3\n");
# TEST #3
# -------
$answer = "$CMD_rmfile example.1 example.3 example._ example.for example.two";
if ($vos)
{
$answer .= " \n";
}
else
{
$answer .= "\n";
}
run_make_test(undef, 'clean', $answer);
# TEST #4: Verify that failed wildcards don't return the pattern
run_make_test(q!
all: ; @echo $(wildcard xz--y*.7)
!,
'', "\n");
# TEST #5: wildcard used to verify file existence
touch('xxx.yyy');
run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!, '', "file=xxx.yyy\n");
unlink('xxx.yyy');
run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!, '', "file=\n");
# TEST #7: verify that when the input pattern has a trailing slash wildcard
# returns only directories.
#
# Currently this doesn't work with our embedded GLOB so disable it.
# -------
if (get_config('USE_SYSTEM_GLOB') eq 'yes') {
touch("hellof");
mkdir("hellod", 0770);
mkdir("hellod/worldd", 0770);
touch("hellod/worldf");
mkdir("hellod/worldd/kend1", 0770);
mkdir("hellod/worldd/kend2", 0770);
touch("hellod/worldd/kenf1");
touch("hellod/worldd/kenf2");
run_make_test(qq!
print3:
\t\@echo \$(wildcard hello*)
\t\@echo \$(wildcard hello*/)
\t\@echo \$(wildcard hellod/world*)
\t\@echo \$(wildcard hellod/world*/)
\t\@echo \$(wildcard hello* hellod/world*)
\t\@echo \$(wildcard hello*/ hellod/world*/)
\t\@echo \$(wildcard hellod/*)
\t\@echo \$(wildcard hellod/*/)
\t\@echo \$(wildcard */world*)
\t\@echo \$(wildcard */worldd/)
\t\@echo \$(wildcard hellod/*/ken*/)
\t\@echo \$(wildcard hellod/*/ken?[12])
\t\@echo \$(wildcard hellod/*/ken?[12]/)
!, '',
"hellod hellof\n"
."hellod/\n"
."hellod/worldd hellod/worldf\n"
."hellod/worldd/\n"
."hellod hellof hellod/worldd hellod/worldf\n"
."hellod/ hellod/worldd/\n"
."hellod/worldd hellod/worldf\n"
."hellod/worldd/\n"
."hellod/worldd hellod/worldf\n"
."hellod/worldd/\n"
."hellod/worldd/kend1/ hellod/worldd/kend2/\n"
."hellod/worldd/kend1 hellod/worldd/kend2 "
."hellod/worldd/kenf1 hellod/worldd/kenf2\n"
."hellod/worldd/kend1/ hellod/worldd/kend2/\n");
unlink('hellof', 'hellod/worldf', 'hellod/worldd/kenf1',
'hellod/worldd/kenf2');
foreach $d ('hellod/worldd/kend1', 'hellod/worldd/kend2', 'hellod/worldd',
'hellod') {
rmdir($d);
}
}
if ($port_type ne 'W32') {
# Check wildcard on the root directory
run_make_test('print4: ; @echo $(wildcard /)', '', "/\n");
}
if ($port_type ne 'W32' && eval { symlink("",""); 1 }) {
# TEST #6: check for wildcards matching directories
# See SV 53465
my $dir = '__rdir';
my $lnk = '__ldir';
mkdir($dir, 0777);
symlink($dir, $lnk);
run_make_test(qq!all: ; \@echo \$(wildcard $lnk*/.)!, '', "$lnk/.");
unlink($lnk);
rmdir($dir);
# Test for dangling symlinks
# This doesn't work with the built-in glob... needs to be updated!
if (get_config('USE_SYSTEM_GLOB') eq 'yes') {
symlink($dir, $lnk);
run_make_test(qq!all: ; \@echo \$(wildcard $lnk)!, '', "$lnk");
unlink($lnk);
}
}
1;
@@ -0,0 +1,175 @@
# -*-perl-*-
$description = "\
Test the word, words, wordlist, firstword, and lastword functions.\n";
$details = "\
Produce a variable with a large number of words in it,
determine the number of words, and then read each one back.\n";
run_make_test('
string := word.pl general_test2.pl FORCE.pl word.pl generic_test.perl MAKEFILES_variable.pl
string2 := $(string) $(string) $(string) $(string) $(string) $(string) $(string)
string3 := $(string2) $(string2) $(string2) $(string2) $(string2) $(string2) $(string2)
string4 := $(string3) $(string3) $(string3) $(string3) $(string3) $(string3) $(string3)
.RECIPEPREFIX = >
all:
> @echo $(words $(string))
> @echo $(words $(string4))
> @echo $(word 1, $(string))
> @echo $(word 100, $(string))
> @echo $(word 1 , $(string))
> @echo $(word 1000, $(string3))
> @echo $(word 9223372036854775807, $(string2))
> @echo $(wordlist 3, 4, $(string))
> @echo $(wordlist 4, 3, $(string))
> @echo $(wordlist 1 , 6 , $(string))
> @echo $(wordlist 5,7, $(string))
> @echo $(wordlist 100, 110, $(string))
> @echo $(wordlist 7, 10, $(string2))
> @echo $(wordlist 9223372036854775807, 0, $(string2))
', '', "6\n"
."2058\n"
."word.pl\n"
."\n"
."word.pl\n"
."\n"
."\n"
."FORCE.pl word.pl\n"
."\n"
."word.pl general_test2.pl FORCE.pl word.pl generic_test.perl MAKEFILES_variable.pl\n"
."generic_test.perl MAKEFILES_variable.pl\n"
."\n"
."word.pl general_test2.pl FORCE.pl word.pl\n"
."\n"
);
# Test error conditions
run_make_test('FOO = foo bar biz baz
word-e1: ; @echo $(word ,$(FOO))
word-e2: ; @echo $(word abc ,$(FOO))
word-e3: ; @echo $(word 1a,$(FOO))
word-e4: ; @echo $(word 9999999999999999999,$(FOO))
wordlist-e1: ; @echo $(wordlist ,,$(FOO))
wordlist-e2: ; @echo $(wordlist abc ,,$(FOO))
wordlist-e3: ; @echo $(wordlist 1, 12a ,$(FOO))',
'word-e1',
"#MAKEFILE#:3: *** invalid first argument to 'word' function: empty value. Stop.",
512);
run_make_test(undef,
'word-e2',
"#MAKEFILE#:4: *** invalid first argument to 'word' function: 'abc '. Stop.",
512);
run_make_test(undef,
'word-e3',
"#MAKEFILE#:5: *** invalid first argument to 'word' function: '1a'. Stop.",
512);
run_make_test(undef,
'word-e4',
"#MAKEFILE#:6: *** invalid first argument to 'word' function: '9999999999999999999' out of range. Stop.",
512);
run_make_test(undef,
'wordlist-e1',
"#MAKEFILE#:8: *** invalid first argument to 'wordlist' function: empty value. Stop.",
512);
run_make_test(undef,
'wordlist-e2',
"#MAKEFILE#:9: *** invalid first argument to 'wordlist' function: 'abc '. Stop.",
512);
run_make_test(undef,
'wordlist-e3',
"#MAKEFILE#:10: *** invalid second argument to 'wordlist' function: ' 12a '. Stop.",
512);
# Test error conditions again, but this time in a variable reference
run_make_test('FOO = foo bar biz baz
W = $(word $x,$(FOO))
WL = $(wordlist $s,$e,$(FOO))
word-e: ; @echo $(W)
wordlist-e: ; @echo $(WL)',
'word-e x=',
"#MAKEFILE#:3: *** invalid first argument to 'word' function: empty value. Stop.",
512);
run_make_test(undef,
'word-e x=abc',
"#MAKEFILE#:3: *** invalid first argument to 'word' function: 'abc'. Stop.",
512);
run_make_test(undef,
'word-e x=0',
"#MAKEFILE#:3: *** first argument to 'word' function must be greater than 0. Stop.",
512);
run_make_test(undef,
'wordlist-e s= e=',
"#MAKEFILE#:4: *** invalid first argument to 'wordlist' function: empty value. Stop.",
512);
run_make_test(undef,
'wordlist-e s=abc e=',
"#MAKEFILE#:4: *** invalid first argument to 'wordlist' function: 'abc'. Stop.",
512);
run_make_test(undef,
'wordlist-e s=4 e=12a',
"#MAKEFILE#:4: *** invalid second argument to 'wordlist' function: '12a'. Stop.",
512);
run_make_test(undef,
'wordlist-e s=0 e=12',
"#MAKEFILE#:4: *** invalid first argument to 'wordlist' function: '0'. Stop.",
512);
run_make_test(undef,
'wordlist-e s=1 e=-1',
"#MAKEFILE#:4: *** invalid second argument to 'wordlist' function: '-1'. Stop.",
512);
# TEST #8 -- test $(firstword )
#
run_make_test('
void :=
list := $(void) foo bar baz #
a := $(word 1,$(list))
b := $(firstword $(list))
.PHONY: all
all: ; @test "$a" = "$b" && echo $a
',
'',
'foo');
# TEST #9 -- test $(lastword )
#
run_make_test('
void :=
list := $(void) foo bar baz #
a := $(word $(words $(list)),$(list))
b := $(lastword $(list))
.PHONY: all
all: ; @test "$a" = "$b" && echo $a
',
'',
'baz');
# This tells the test driver that the perl test script executed properly.
1;