/[make]/make/tests/scripts/functions/foreach
ViewVC logotype

Diff of /make/tests/scripts/functions/foreach

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by psmith, Fri Sep 17 03:16:06 1999 UTC revision 1.3 by psmith, Thu Jun 9 19:19:20 2005 UTC
# Line 1  Line 1 
1  #                                                                    -*-perl-*-  #                                                                    -*-perl-*-
2    
3  # Updated 6.16.93  variable "MAKE" is default was environment override  # Updated 16 June 1993 variable "MAKE" is default was environment override
4  # For make 3.63 and above  # For make 3.63 and above
5    
6  $description = "The following test creates a makefile to verify  $description = "The following test creates a makefile to verify
# Line 14  form of the command is $(foreach var,$li Line 14  form of the command is $(foreach var,$li
14  types of foreach loops are tested\n";  types of foreach loops are tested\n";
15    
16    
17  open(MAKEFILE,"> $makefile");  # TEST 0
   
 # The Contents of the MAKEFILE ...  
18    
19  # On WIN32 systems, the user's path is found in %Path% ($Path)  # On WIN32 systems, the user's path is found in %Path% ($Path)
20  #  #
21  $pathvar = (($port_type eq 'Windows') ? "Path" : "PATH");  $pathvar = (($port_type eq 'Windows') ? "Path" : "PATH");
22    
23  print MAKEFILE <<EOF;  run_make_test("
 foo = bletch null \@ garf  
24  null :=  null :=
25  space = ' '  space = ' '
26  auto_var = udef space CC null $pathvar MAKE foo CFLAGS WHITE \@ <  auto_var = udef space CC null $pathvar".' MAKE foo CFLAGS WHITE @ <
27  av = \$(foreach var, \$(auto_var), \$(origin \$(var)) )  foo = bletch null @ garf
28    av = $(foreach var, $(auto_var), $(origin $(var)) )
29  override WHITE := BLACK  override WHITE := BLACK
30  for_var = \$(addsuffix .c,foo \$(null) \$(foo) \$(space) \$(av) )  for_var = $(addsuffix .c,foo $(null) $(foo) $(space) $(av) )
31  fe = \$(foreach var2, \$(for_var),\$(subst .c,.o, \$(var2) ) )  fe = $(foreach var2, $(for_var),$(subst .c,.o, $(var2) ) )
32  all: auto for2  all: auto for2
33  auto :  auto : ; @echo $(av)
34  \t\@echo \$(av)  for2: ; @echo $(fe)',
35  for2:                '-e WHITE=WHITE CFLAGS=',
36  \t\@echo \$(fe)                "undefined file default file environment default file command line override automatic automatic
37  EOF  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");
38    
39  close(MAKEFILE);  
40    # TEST 1: Test that foreach variables take precedence over global
41  &run_make_with_options($makefile,  # variables in a global scope (like inside an eval).  Tests bug #11913
42                        "-e WHITE=WHITE CFLAGS=",  
43                        &get_logfile);  run_make_test('
44    .PHONY: all target
45  # Create the answer to what should be produced by this Makefile  all: target
46  $answer = "undefined file default file environment default file command line override automatic automatic  
47  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\n";  x := BAD
48    
49    define mktarget
50    target: x := $(x)
51    target: ; @echo "$(x)"
52    endef
53    
54    x := GLOBAL
55    
56  &compare_output($answer,&get_logfile(1));  $(foreach x,FOREACH,$(eval $(value mktarget)))',
57                  '',
58                  'FOREACH');
59    
60  1;  1;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26