1999-09-14 02:03:19 +00:00
|
|
|
# -*-perl-*-
|
|
|
|
|
2005-06-09 19:19:20 +00:00
|
|
|
# Updated 16 June 1993 variable "MAKE" is default was environment override
|
1999-09-14 02:03:19 +00:00
|
|
|
# For make 3.63 and above
|
|
|
|
|
|
|
|
$description = "The following test creates a makefile to verify
|
|
|
|
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";
|
|
|
|
|
|
|
|
|
2005-06-09 19:19:20 +00:00
|
|
|
# TEST 0
|
1999-09-14 02:03:19 +00:00
|
|
|
|
|
|
|
# On WIN32 systems, the user's path is found in %Path% ($Path)
|
|
|
|
#
|
1999-09-17 03:15:37 +00:00
|
|
|
$pathvar = (($port_type eq 'Windows') ? "Path" : "PATH");
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2005-06-09 19:19:20 +00:00
|
|
|
run_make_test("
|
1999-09-14 02:03:19 +00:00
|
|
|
null :=
|
|
|
|
space = ' '
|
2005-06-09 19:19:20 +00:00
|
|
|
auto_var = udef space CC null $pathvar".' MAKE foo CFLAGS WHITE @ <
|
|
|
|
foo = bletch null @ garf
|
|
|
|
av = $(foreach var, $(auto_var), $(origin $(var)) )
|
1999-09-14 02:03:19 +00:00
|
|
|
override WHITE := BLACK
|
2005-06-09 19:19:20 +00:00
|
|
|
for_var = $(addsuffix .c,foo $(null) $(foo) $(space) $(av) )
|
|
|
|
fe = $(foreach var2, $(for_var),$(subst .c,.o, $(var2) ) )
|
1999-09-14 02:03:19 +00:00
|
|
|
all: auto for2
|
2005-06-09 19:19:20 +00:00
|
|
|
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
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2005-06-09 19:19:20 +00:00
|
|
|
x := BAD
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2005-06-09 19:19:20 +00:00
|
|
|
define mktarget
|
|
|
|
target: x := $(x)
|
|
|
|
target: ; @echo "$(x)"
|
|
|
|
endef
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2005-06-09 19:19:20 +00:00
|
|
|
x := GLOBAL
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2005-06-09 19:19:20 +00:00
|
|
|
$(foreach x,FOREACH,$(eval $(value mktarget)))',
|
|
|
|
'',
|
|
|
|
'FOREACH');
|
1999-09-14 02:03:19 +00:00
|
|
|
|
|
|
|
1;
|